diff --git a/stella/src/emucore/CartE0.cxx b/stella/src/emucore/CartE0.cxx index 513e4d22c..f8c615fdf 100644 --- a/stella/src/emucore/CartE0.cxx +++ b/stella/src/emucore/CartE0.cxx @@ -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 @@ -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 diff --git a/stella/src/emucore/CartMC.cxx b/stella/src/emucore/CartMC.cxx index 0d7d5c6ca..151a4ec3b 100644 --- a/stella/src/emucore/CartMC.cxx +++ b/stella/src/emucore/CartMC.cxx @@ -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 @@ -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; }