Fixed load/save state support for the few remaining Cartridge types.

Some of these haven't been extensively tested, so YMMV.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@151 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2002-12-01 15:59:47 +00:00
parent 45d2942722
commit 79769a946c
2 changed files with 59 additions and 6 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: CartE0.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $
// $Id: CartE0.cxx,v 1.3 2002-12-01 15:59:46 stephena Exp $
//============================================================================
#include <assert.h>
@ -195,7 +195,6 @@ void CartridgeE0::segmentTwo(uInt16 slice)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE0::save(Serializer& out)
{
cerr << "save from CartE0 !!\n";
string cart = name();
try
@ -223,7 +222,6 @@ bool CartridgeE0::save(Serializer& out)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE0::load(Deserializer& in)
{
cerr << "load from CartE0 !!\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: CartMC.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $
// $Id: CartMC.cxx,v 1.3 2002-12-01 15:59:47 stephena Exp $
//============================================================================
#include <assert.h>
@ -222,13 +222,68 @@ void CartridgeMC::poke(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMC::save(Serializer& out)
{
cerr << "save from CartMC \n";
string cart = name();
try
{
out.putString(cart);
// The currentBlock array
out.putLong(4);
for(uInt32 i = 0; i < 4; ++i)
out.putLong(myCurrentBlock[i]);
// The 32K of RAM
out.putLong(32 * 1024);
for(uInt32 i = 0; i < 32 * 1024; ++i)
out.putLong(myRAM[i]);
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMC::load(Deserializer& in)
{
cerr << "load from CartMC \n";
string cart = name();
try
{
uInt32 limit;
if(in.getString() != cart)
return false;
// The currentBlock array
limit = (uInt32) in.getLong();
for(uInt32 i = 0; i < limit; ++i)
myCurrentBlock[i] = (uInt8) in.getLong();
// The 32K of RAM
limit = (uInt32) in.getLong();
for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getLong();
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
return true;
}