Fully tested (I hope) almost all the Cartridge types wrt. state loading and

saving.

For now, CartE0 is still being tested, and CartMC has not been implemented at
all.  This is a problem right now, since I don't have access to an MC
cartridge image.

Other than that, all the other Cartridge types are working fine with every
ROM I've thrown at the current code.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2002-05-14 15:22:28 +00:00
parent a6d9b330c3
commit 73008e9290
16 changed files with 155 additions and 69 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Cart3F.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $
// $Id: Cart3F.cxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -152,7 +152,6 @@ void Cartridge3F::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3F::save(Serializer& out)
{
cerr << "save from Cart3F !!\n";
string cart = name();
try
@ -177,7 +176,6 @@ bool Cartridge3F::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3F::load(Deserializer& in)
{
cerr << "load from Cart3F !!\n";
string cart = name();
try

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Cart4K.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $
// $Id: Cart4K.cxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -86,7 +86,6 @@ void Cartridge4K::poke(uInt16, uInt8)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::save(Serializer& out)
{
cerr << "save from Cart4K !!\n";
string cart = name();
try
@ -110,8 +109,6 @@ bool Cartridge4K::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::load(Deserializer& in)
{
cerr << "load from Cart4K !!\n";
string cart = name();
try

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartAR.cxx,v 1.3 2002-05-13 19:17:32 stephena Exp $
// $Id: CartAR.cxx,v 1.4 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -425,13 +425,134 @@ void CartridgeAR::loadIntoRAM(uInt8 load)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeAR::save(Serializer& out)
{
cerr << "save from CartAR \n";
string cart = name();
try
{
uInt32 i;
out.putString(cart);
// Indicates the offest within the image for the corresponding bank
out.putLong(2);
for(i = 0; i < 2; ++i)
out.putLong(myImageOffset[i]);
// The 6K of RAM and 2K of ROM contained in the Supercharger
out.putLong(8192);
for(i = 0; i < 8192; ++i)
out.putLong(myImage[i]);
// The 256 byte header for the current 8448 byte load
out.putLong(256);
for(i = 0; i < 256; ++i)
out.putLong(myHeader[i]);
// All of the 8448 byte loads associated with the game
// Note that the size of this array is myNumberOfLoadImages * 8448
out.putLong(myNumberOfLoadImages * 8448);
for(i = 0; i < myNumberOfLoadImages * 8448; ++i)
out.putLong(myLoadImages[i]);
// Indicates how many 8448 loads there are
out.putLong(myNumberOfLoadImages);
// 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
out.putLong(myPowerRomCycle);
// Data hold register used for writing
out.putLong(myDataHoldRegister);
// Indicates number of distinct accesses when data hold register was set
out.putLong(myNumberOfDistinctAccesses);
// Indicates if a write is pending or not
out.putBool(myWritePending);
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeAR::load(Deserializer& in)
{
cerr << "load from CartAR \n";
string cart = name();
try
{
if(in.getString() != cart)
return false;
uInt32 i, limit;
// Indicates the offest within the image for the corresponding bank
limit = (uInt32) in.getLong();
for(i = 0; i < limit; ++i)
myImageOffset[i] = (uInt32) in.getLong();
// The 6K of RAM and 2K of ROM contained in the Supercharger
limit = (uInt32) in.getLong();
for(i = 0; i < limit; ++i)
myImage[i] = (uInt8) in.getLong();
// The 256 byte header for the current 8448 byte load
limit = (uInt32) in.getLong();
for(i = 0; i < limit; ++i)
myHeader[i] = (uInt8) in.getLong();
// All of the 8448 byte loads associated with the game
// Note that the size of this array is myNumberOfLoadImages * 8448
limit = (uInt32) in.getLong();
for(i = 0; i < limit; ++i)
myLoadImages[i] = (uInt8) in.getLong();
// Indicates how many 8448 loads there are
myNumberOfLoadImages = (uInt8) in.getLong();
// 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
myPowerRomCycle = (Int32) in.getLong();
// Data hold register used for writing
myDataHoldRegister = (uInt8) in.getLong();
// Indicates number of distinct accesses when data hold register was set
myNumberOfDistinctAccesses = (uInt32) in.getLong();
// Indicates if a write is pending or not
myWritePending = in.getBool();
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
return true;
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartCV.cxx,v 1.3 2002-05-13 19:17:32 stephena Exp $
// $Id: CartCV.cxx,v 1.4 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -134,7 +134,6 @@ void CartridgeCV::poke(uInt16, uInt8)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeCV::save(Serializer& out)
{
cerr << "save from CartCV !!\n";
string cart = name();
try
@ -163,7 +162,6 @@ bool CartridgeCV::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeCV::load(Deserializer& in)
{
cerr << "load from CartCV !!\n";
string cart = name();
try

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartDPC.cxx,v 1.5 2002-05-14 10:56:03 gunfight Exp $
// $Id: CartDPC.cxx,v 1.6 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -331,14 +331,12 @@ void CartridgeDPC::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeDPC::save(Serializer& out)
{
uInt32 i;
cerr << "save from CartDPC !!\n";
string cart = name();
string cart = name();
try
{
uInt32 i;
out.putString(cart);
// Indicates which bank is currently active
@ -384,18 +382,14 @@ bool CartridgeDPC::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeDPC::load(Deserializer& in)
{
uInt32 i;
cerr << "load from CartDPC !!\n";
string cart = name();
string cart = name();
try
{
if(in.getString() != cart)
return false;
uInt32 limit;
uInt32 i, limit;
// Indicates which bank is currently active
myCurrentBank = (uInt16) in.getLong();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartE7.cxx,v 1.3 2002-05-14 10:56:03 gunfight Exp $
// $Id: CartE7.cxx,v 1.4 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -218,14 +218,12 @@ void CartridgeE7::bankRAM(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE7::save(Serializer& out)
{
uInt32 i;
cerr << "save from CartE7 !!\n";
string cart = name();
string cart = name();
try
{
uInt32 i;
out.putString(cart);
out.putLong(2);
@ -256,18 +254,14 @@ bool CartridgeE7::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE7::load(Deserializer& in)
{
uInt32 i;
cerr << "load from CartE7 !!\n";
string cart = name();
string cart = name();
try
{
if(in.getString() != cart)
return false;
uInt32 limit;
uInt32 i, limit;
limit = (uInt32) in.getLong();
for(i = 0; i < limit; ++i)

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartF4SC.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $
// $Id: CartF4SC.cxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -158,7 +158,6 @@ void CartridgeF4SC::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4SC::save(Serializer& out)
{
cerr << "save from CartF4SC !!\n";
string cart = name();
try
@ -189,7 +188,6 @@ bool CartridgeF4SC::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4SC::load(Deserializer& in)
{
cerr << "load from CartF4SC !!\n";
string cart = name();
try

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartF6.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $
// $Id: CartF6.cxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -169,7 +169,6 @@ void CartridgeF6::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6::save(Serializer& out)
{
cerr << "save from CartF6 !!\n";
string cart = name();
try
@ -195,7 +194,6 @@ bool CartridgeF6::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6::load(Deserializer& in)
{
cerr << "load from CartF6 !!\n";
string cart = name();
try

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartF6SC.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $
// $Id: CartF6SC.cxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -202,7 +202,6 @@ void CartridgeF6SC::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6SC::save(Serializer& out)
{
cerr << "save from CartF6SC !!\n";
string cart = name();
try
@ -234,7 +233,6 @@ bool CartridgeF6SC::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6SC::load(Deserializer& in)
{
cerr << "load from CartF6SC !!\n";
string cart = name();
try

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartF8.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $
// $Id: CartF8.cxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -149,7 +149,6 @@ void CartridgeF8::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8::save(Serializer& out)
{
cerr << "save from CartF8 !!\n";
string cart = name();
try
@ -175,7 +174,6 @@ bool CartridgeF8::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8::load(Deserializer& in)
{
cerr << "load from CartF8 !!\n";
string cart = name();
try

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartF8SC.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $
// $Id: CartF8SC.cxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -182,7 +182,6 @@ void CartridgeF8SC::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8SC::save(Serializer& out)
{
cerr << "save from CartF8SC !!\n";
string cart = name();
try
@ -213,7 +212,6 @@ bool CartridgeF8SC::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8SC::load(Deserializer& in)
{
cerr << "load from CartF8SC !!\n";
string cart = name();
try

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartFASC.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $
// $Id: CartFASC.cxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -192,7 +192,6 @@ void CartridgeFASC::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFASC::save(Serializer& out)
{
cerr << "save from CartFASC !!\n";
string cart = name();
try
@ -223,7 +222,6 @@ bool CartridgeFASC::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFASC::load(Deserializer& in)
{
cerr << "load from CartFASC \n";
string cart = name();
try

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartMB.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $
// $Id: CartMB.cxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -124,7 +124,6 @@ void CartridgeMB::incbank()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMB::save(Serializer& out)
{
cerr << "save from CartMB !!\n";
string cart = name();
try
@ -150,7 +149,6 @@ bool CartridgeMB::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMB::load(Deserializer& in)
{
cerr << "load from CartMB !!\n";
string cart = name();
try

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Deserializer.hxx,v 1.2 2002-05-14 10:56:03 gunfight Exp $
// $Id: Deserializer.hxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#ifndef DESERIALIZER_HXX
#define DESERIALIZER_HXX
#include "bspf.hxx"
#include "bspf.hxx"
#include <fstream>
#include <string>
@ -32,7 +32,7 @@
return.
@author Stephen Anthony
@version $Id: Deserializer.hxx,v 1.2 2002-05-14 10:56:03 gunfight Exp $
@version $Id: Deserializer.hxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
*/
class Deserializer
{

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Serializer.hxx,v 1.2 2002-05-14 10:56:03 gunfight Exp $
// $Id: Serializer.hxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#ifndef SERIALIZER_HXX
#define SERIALIZER_HXX
#include "bspf.hxx"
#include "bspf.hxx"
#include <fstream>
#include <string>
@ -33,7 +33,7 @@
Boolean values are written using a special pattern.
@author Stephen Anthony
@version $Id: Serializer.hxx,v 1.2 2002-05-14 10:56:03 gunfight Exp $
@version $Id: Serializer.hxx,v 1.3 2002-05-14 15:22:28 stephena Exp $
*/
class Serializer
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TIA.cxx,v 1.13 2002-05-13 19:17:32 stephena Exp $
// $Id: TIA.cxx,v 1.14 2002-05-14 15:22:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -285,7 +285,6 @@ void TIA::install(System& system)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TIA::save(Serializer& out)
{
cerr << "save from TIA !!\n";
string device = name();
try
@ -369,7 +368,7 @@ bool TIA::save(Serializer& out)
}
catch(...)
{
cerr << "Unknown error in TIA save state\n";
cerr << "Unknown error in save state for " << device << endl;
return false;
}
@ -379,7 +378,6 @@ bool TIA::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TIA::load(Deserializer& in)
{
cerr << "load from TIA !!\n";
string device = name();
try
@ -464,7 +462,7 @@ bool TIA::load(Deserializer& in)
}
catch(...)
{
cerr << "Unknown error in TIA load state\n";
cerr << "Unknown error in load state for " << device << endl;
return false;
}