From 8a51196556e9595997a24958a8efcf6f7048178f Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 13 May 2002 19:17:32 +0000 Subject: [PATCH] Added state save and load methods to each class derived from Device. Not all cartridges have been implemented. Some are working perfectly, such as those without RAM. Others are hopefully working, but require further testing (like bank switching). A few are not working at all, most notably CartAR and CartMC. Please test extensively. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@95 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/emucore/Cart2K.cxx | 51 ++++++++- stella/src/emucore/Cart2K.hxx | 22 +++- stella/src/emucore/Cart3F.cxx | 59 +++++++++- stella/src/emucore/Cart3F.hxx | 22 +++- stella/src/emucore/Cart4K.cxx | 54 ++++++++- stella/src/emucore/Cart4K.hxx | 22 +++- stella/src/emucore/CartAR.cxx | 18 ++- stella/src/emucore/CartAR.hxx | 22 +++- stella/src/emucore/CartCV.cxx | 68 ++++++++++- stella/src/emucore/CartCV.hxx | 22 +++- stella/src/emucore/CartDPC.cxx | 110 +++++++++++++++++- stella/src/emucore/CartDPC.hxx | 23 +++- stella/src/emucore/CartE0.cxx | 61 +++++++++- stella/src/emucore/CartE0.hxx | 22 +++- stella/src/emucore/CartE7.cxx | 81 ++++++++++++- stella/src/emucore/CartE7.hxx | 22 +++- stella/src/emucore/CartF4SC.cxx | 69 +++++++++++- stella/src/emucore/CartF4SC.hxx | 22 +++- stella/src/emucore/CartF6.cxx | 60 +++++++++- stella/src/emucore/CartF6.hxx | 22 +++- stella/src/emucore/CartF6SC.cxx | 71 +++++++++++- stella/src/emucore/CartF6SC.hxx | 22 +++- stella/src/emucore/CartF8.cxx | 60 +++++++++- stella/src/emucore/CartF8.hxx | 22 +++- stella/src/emucore/CartF8SC.cxx | 69 +++++++++++- stella/src/emucore/CartF8SC.hxx | 22 +++- stella/src/emucore/CartFASC.cxx | 69 +++++++++++- stella/src/emucore/CartFASC.hxx | 22 +++- stella/src/emucore/CartFE.cxx | 51 ++++++++- stella/src/emucore/CartFE.hxx | 22 +++- stella/src/emucore/CartMB.cxx | 61 +++++++++- stella/src/emucore/CartMB.hxx | 22 +++- stella/src/emucore/CartMC.cxx | 18 ++- stella/src/emucore/CartMC.hxx | 23 +++- stella/src/emucore/M6532.cxx | 80 ++++++++++++- stella/src/emucore/M6532.hxx | 22 +++- stella/src/emucore/TIA.cxx | 194 +++++++++++++++++++++++++++++++- stella/src/emucore/TIA.hxx | 22 +++- 38 files changed, 1662 insertions(+), 62 deletions(-) diff --git a/stella/src/emucore/Cart2K.cxx b/stella/src/emucore/Cart2K.cxx index 8a0fc3f2e..b637cdac1 100644 --- a/stella/src/emucore/Cart2K.cxx +++ b/stella/src/emucore/Cart2K.cxx @@ -13,12 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Cart2K.cxx,v 1.1.1.1 2001-12-27 19:54:18 bwmott Exp $ +// $Id: Cart2K.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "Cart2K.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cartridge2K::Cartridge2K(const uInt8* image) @@ -80,3 +83,49 @@ void Cartridge2K::poke(uInt16, uInt8) // This is ROM so poking has no effect :-) } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge2K::save(Serializer& out) +{ + string cart = name(); + + try + { + out.putString(cart); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in save state for " << cart << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge2K::load(Deserializer& in) +{ + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in load state for " << cart << endl; + return false; + } + + return true; +} diff --git a/stella/src/emucore/Cart2K.hxx b/stella/src/emucore/Cart2K.hxx index 601c16b1c..1d76ccf65 100644 --- a/stella/src/emucore/Cart2K.hxx +++ b/stella/src/emucore/Cart2K.hxx @@ -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: Cart2K.hxx,v 1.1.1.1 2001-12-27 19:54:18 bwmott Exp $ +// $Id: Cart2K.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGE2K_HXX @@ -21,6 +21,8 @@ class Cartridge2K; class System; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -31,7 +33,7 @@ class System; 2600's 4K cartridge addressing space. @author Bradford W. Mott - @version $Id: Cart2K.hxx,v 1.1.1.1 2001-12-27 19:54:18 bwmott Exp $ + @version $Id: Cart2K.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class Cartridge2K : public Cartridge { @@ -69,6 +71,22 @@ class Cartridge2K : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address diff --git a/stella/src/emucore/Cart3F.cxx b/stella/src/emucore/Cart3F.cxx index a7bdd27d7..15a1c3235 100644 --- a/stella/src/emucore/Cart3F.cxx +++ b/stella/src/emucore/Cart3F.cxx @@ -13,12 +13,15 @@ // 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.1.1.1 2001-12-27 19:54:18 bwmott Exp $ +// $Id: Cart3F.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "Cart3F.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cartridge3F::Cartridge3F(const uInt8* image, uInt32 size) @@ -146,3 +149,57 @@ void Cartridge3F::bank(uInt16 bank) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge3F::save(Serializer& out) +{ + cerr << "save from Cart3F !!\n"; + string cart = name(); + + try + { + out.putString(cart); + out.putLong(myCurrentBank); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in save state for " << cart << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge3F::load(Deserializer& in) +{ + cerr << "load from Cart3F !!\n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + myCurrentBank = (uInt16) in.getLong(); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in load state for " << cart << endl; + return false; + } + + // Now, go to the current bank + bank(myCurrentBank); + + return true; +} diff --git a/stella/src/emucore/Cart3F.hxx b/stella/src/emucore/Cart3F.hxx index 52f90a511..84a978fc1 100644 --- a/stella/src/emucore/Cart3F.hxx +++ b/stella/src/emucore/Cart3F.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Cart3F.hxx,v 1.1.1.1 2001-12-27 19:54:18 bwmott Exp $ +// $Id: Cart3F.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGE3F_HXX #define CARTRIDGE3F_HXX class Cartridge3F; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -35,7 +37,7 @@ class Cartridge3F; only used 8K this bankswitching scheme supports up to 512K. @author Bradford W. Mott - @version $Id: Cart3F.hxx,v 1.1.1.1 2001-12-27 19:54:18 bwmott Exp $ + @version $Id: Cart3F.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class Cartridge3F : public Cartridge { @@ -74,6 +76,22 @@ class Cartridge3F : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address diff --git a/stella/src/emucore/Cart4K.cxx b/stella/src/emucore/Cart4K.cxx index f5727b431..25fb8607e 100644 --- a/stella/src/emucore/Cart4K.cxx +++ b/stella/src/emucore/Cart4K.cxx @@ -13,12 +13,15 @@ // 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.1.1.1 2001-12-27 19:54:18 bwmott Exp $ +// $Id: Cart4K.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "Cart4K.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cartridge4K::Cartridge4K(const uInt8* image) @@ -80,3 +83,52 @@ void Cartridge4K::poke(uInt16, uInt8) // This is ROM so poking has no effect :-) } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge4K::save(Serializer& out) +{ + cerr << "save from Cart4K !!\n"; + string cart = name(); + + try + { + out.putString(cart); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in save state for " << cart << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge4K::load(Deserializer& in) +{ + cerr << "load from Cart4K !!\n"; + + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in load state for " << cart << endl; + return false; + } + + return true; +} diff --git a/stella/src/emucore/Cart4K.hxx b/stella/src/emucore/Cart4K.hxx index f7d6bef07..fd01df6fe 100644 --- a/stella/src/emucore/Cart4K.hxx +++ b/stella/src/emucore/Cart4K.hxx @@ -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.hxx,v 1.1.1.1 2001-12-27 19:54:18 bwmott Exp $ +// $Id: Cart4K.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGE4K_HXX @@ -21,6 +21,8 @@ class Cartridge4K; class System; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -30,7 +32,7 @@ class System; not bankswitched. @author Bradford W. Mott - @version $Id: Cart4K.hxx,v 1.1.1.1 2001-12-27 19:54:18 bwmott Exp $ + @version $Id: Cart4K.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class Cartridge4K : public Cartridge { @@ -68,6 +70,22 @@ class Cartridge4K : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. diff --git a/stella/src/emucore/CartAR.cxx b/stella/src/emucore/CartAR.cxx index 1f345aa23..3f509e963 100644 --- a/stella/src/emucore/CartAR.cxx +++ b/stella/src/emucore/CartAR.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: CartAR.cxx,v 1.2 2002-04-05 02:18:23 bwmott Exp $ +// $Id: CartAR.cxx,v 1.3 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include @@ -22,6 +22,9 @@ #include "M6502Hi.hxx" #include "Random.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeAR::CartridgeAR(const uInt8* image, uInt32 size) @@ -419,3 +422,16 @@ void CartridgeAR::loadIntoRAM(uInt8 load) cerr << "ERROR: Supercharger load is missing from ROM image...\n"; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeAR::save(Serializer& out) +{ + cerr << "save from CartAR \n"; + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeAR::load(Deserializer& in) +{ + cerr << "load from CartAR \n"; + return true; +} diff --git a/stella/src/emucore/CartAR.hxx b/stella/src/emucore/CartAR.hxx index 8736d040a..9ab6ec2f1 100644 --- a/stella/src/emucore/CartAR.hxx +++ b/stella/src/emucore/CartAR.hxx @@ -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.hxx,v 1.2 2002-04-05 02:18:23 bwmott Exp $ +// $Id: CartAR.hxx,v 1.3 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEAR_HXX @@ -21,6 +21,8 @@ class CartridgeAR; class M6502High; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -35,7 +37,7 @@ class M6502High; and one bank of ROM. All 6K of the RAM can be read and written. @author Bradford W. Mott - @version $Id: CartAR.hxx,v 1.2 2002-04-05 02:18:23 bwmott Exp $ + @version $Id: CartAR.hxx,v 1.3 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeAR : public Cartridge { @@ -81,6 +83,22 @@ class CartridgeAR : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address diff --git a/stella/src/emucore/CartCV.cxx b/stella/src/emucore/CartCV.cxx index 58882c88c..d717b2363 100644 --- a/stella/src/emucore/CartCV.cxx +++ b/stella/src/emucore/CartCV.cxx @@ -13,20 +13,22 @@ // 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.2 2002-03-18 14:40:07 gunfight Exp $ +// $Id: CartCV.cxx,v 1.3 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartCV.hxx" #include "Random.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeCV::CartridgeCV(const uInt8* image, uInt32 size) { - uInt32 addr; - - if(size == 2048) + uInt32 addr; + if(size == 2048) { // Copy the ROM image into my buffer for(uInt32 addr = 0; addr < 2048; ++addr) @@ -129,3 +131,61 @@ void CartridgeCV::poke(uInt16, uInt8) // This is ROM so poking has no effect :-) } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeCV::save(Serializer& out) +{ + cerr << "save from CartCV !!\n"; + string cart = name(); + + try + { + out.putString(cart); + + // Output RAM + out.putLong(1024); + for(uInt32 addr = 0; addr < 1024; ++addr) + out.putLong(myRAM[addr]); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in save state for " << cart << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeCV::load(Deserializer& in) +{ + cerr << "load from CartCV !!\n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + // Input RAM + uInt32 limit = (uInt32) in.getLong(); + for(uInt32 addr = 0; addr < limit; ++addr) + myRAM[addr] = (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; +} diff --git a/stella/src/emucore/CartCV.hxx b/stella/src/emucore/CartCV.hxx index cf49bdca6..faecb79bf 100644 --- a/stella/src/emucore/CartCV.hxx +++ b/stella/src/emucore/CartCV.hxx @@ -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.hxx,v 1.1 2002-01-18 15:59:40 estolberg Exp $ +// $Id: CartCV.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGECV_HXX @@ -21,6 +21,8 @@ class CartridgeCV; class System; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -33,7 +35,7 @@ class System; $F800-$FFFF ROM @author Eckhard Stolberg - @version $Id: CartCV.hxx,v 1.1 2002-01-18 15:59:40 estolberg Exp $ + @version $Id: CartCV.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeCV : public Cartridge { @@ -71,6 +73,22 @@ class CartridgeCV : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address diff --git a/stella/src/emucore/CartDPC.cxx b/stella/src/emucore/CartDPC.cxx index 27a2b32a0..0e988e448 100644 --- a/stella/src/emucore/CartDPC.cxx +++ b/stella/src/emucore/CartDPC.cxx @@ -13,12 +13,15 @@ // 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.3 2002-03-28 01:48:28 bwmott Exp $ +// $Id: CartDPC.cxx,v 1.4 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartDPC.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // This class does not emulate the music mode data fetchers of the DPC. A @@ -325,3 +328,108 @@ void CartridgeDPC::bank(uInt16 bank) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeDPC::save(Serializer& out) +{ + cerr << "save from CartDPC !!\n"; + string cart = name(); + + try + { + out.putString(cart); + + // Indicates which bank is currently active + out.putLong(myCurrentBank); + + // The bottom registers for the data fetchers + out.putLong(8); + for(uInt32 i = 0; i < 8; ++i) + out.putLong(myBottoms[i]); + + // The counter registers for the data fetchers + out.putLong(8); + for(uInt32 i = 0; i < 8; ++i) + out.putLong(myCounters[i]); + + // The flag registers for the data fetchers + out.putLong(8); + for(uInt32 i = 0; i < 8; ++i) + out.putLong(myFlags[i]); + + // The random number generator register + out.putLong(myRandomNumber); + + // The top registers for the data fetchers + out.putLong(8); + for(uInt32 i = 0; i < 8; ++i) + out.putLong(myTops[i]); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in save state for " << cart << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeDPC::load(Deserializer& in) +{ + cerr << "load from CartDPC !!\n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + uInt32 limit; + + // Indicates which bank is currently active + myCurrentBank = (uInt16) in.getLong(); + + // The bottom registers for the data fetchers + limit = (uInt32) in.getLong(); + for(uInt32 i = 0; i < limit; ++i) + myBottoms[i] = (uInt8) in.getLong(); + + // The counter registers for the data fetchers + limit = (uInt32) in.getLong(); + for(uInt32 i = 0; i < limit; ++i) + myCounters[i] = (uInt16) in.getLong(); + + // The flag registers for the data fetchers + limit = (uInt32) in.getLong(); + for(uInt32 i = 0; i < limit; ++i) + myFlags[i] = (uInt8) in.getLong(); + + // The random number generator register + myRandomNumber = (uInt8) in.getLong(); + + // The top registers for the data fetchers + limit = (uInt32) in.getLong(); + for(uInt32 i = 0; i < limit; ++i) + myTops[i] = (uInt8) in.getLong(); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in load state for " << cart << endl; + return false; + } + + // Now, go to the current bank + bank(myCurrentBank); + + return true; +} diff --git a/stella/src/emucore/CartDPC.hxx b/stella/src/emucore/CartDPC.hxx index 24ad86258..e35aa7c9e 100644 --- a/stella/src/emucore/CartDPC.hxx +++ b/stella/src/emucore/CartDPC.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartDPC.hxx,v 1.1 2001-12-30 18:43:30 bwmott Exp $ +// $Id: CartDPC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEDCP_HXX #define CARTRIDGEDCP_HXX class CartridgeDPC; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -30,7 +32,7 @@ class CartridgeDPC; see David P. Crane's United States Patent Number 4,644,495. @author Bradford W. Mott - @version $Id: CartDPC.hxx,v 1.1 2001-12-30 18:43:30 bwmott Exp $ + @version $Id: CartDPC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeDPC : public Cartridge { @@ -68,6 +70,22 @@ class CartridgeDPC : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. @@ -123,4 +141,3 @@ class CartridgeDPC : public Cartridge uInt8 myTops[8]; }; #endif - diff --git a/stella/src/emucore/CartE0.cxx b/stella/src/emucore/CartE0.cxx index e2250810f..513e4d22c 100644 --- a/stella/src/emucore/CartE0.cxx +++ b/stella/src/emucore/CartE0.cxx @@ -13,12 +13,15 @@ // 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.1.1.1 2001-12-27 19:54:19 bwmott Exp $ +// $Id: CartE0.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartE0.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeE0::CartridgeE0(const uInt8* image) @@ -189,3 +192,59 @@ void CartridgeE0::segmentTwo(uInt16 slice) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeE0::save(Serializer& out) +{ + cerr << "save from CartE0 !!\n"; + string cart = name(); + + try + { + out.putString(cart); + + out.putLong(4); + for(uInt32 i = 0; i < 4; ++i) + out.putLong(myCurrentSlice[i]); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in save state for " << cart << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeE0::load(Deserializer& in) +{ + cerr << "load from CartE0 !!\n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + uInt32 limit = (uInt32) in.getLong(); + for(uInt32 i = 0; i < limit; ++i) + myCurrentSlice[i] = (uInt16) in.getLong(); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in load state for " << cart << endl; + return false; + } + + return true; +} diff --git a/stella/src/emucore/CartE0.hxx b/stella/src/emucore/CartE0.hxx index 6a94441ad..65eb3a0ff 100644 --- a/stella/src/emucore/CartE0.hxx +++ b/stella/src/emucore/CartE0.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartE0.hxx,v 1.1.1.1 2001-12-27 19:54:19 bwmott Exp $ +// $Id: CartE0.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEE0_HXX #define CARTRIDGEE0_HXX class CartridgeF8; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -34,7 +36,7 @@ class CartridgeF8; always points to the last 1K of the ROM image. @author Bradford W. Mott - @version $Id: CartE0.hxx,v 1.1.1.1 2001-12-27 19:54:19 bwmott Exp $ + @version $Id: CartE0.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeE0 : public Cartridge { @@ -72,6 +74,22 @@ class CartridgeE0 : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. diff --git a/stella/src/emucore/CartE7.cxx b/stella/src/emucore/CartE7.cxx index 03ba3eadf..1078866e4 100644 --- a/stella/src/emucore/CartE7.cxx +++ b/stella/src/emucore/CartE7.cxx @@ -13,13 +13,16 @@ // 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.1.1.1 2001-12-27 19:54:19 bwmott Exp $ +// $Id: CartE7.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartE7.hxx" #include "Random.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeE7::CartridgeE7(const uInt8* image) @@ -212,3 +215,79 @@ void CartridgeE7::bankRAM(uInt16 bank) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeE7::save(Serializer& out) +{ + cerr << "save from CartE7 !!\n"; + string cart = name(); + + try + { + out.putString(cart); + + out.putLong(2); + for(uInt32 i = 0; i < 2; ++i) + out.putLong(myCurrentSlice[i]); + + out.putLong(myCurrentRAM); + + // The 2048 bytes of RAM + out.putLong(2048); + for(uInt32 i = 0; i < 2048; ++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 CartridgeE7::load(Deserializer& in) +{ + cerr << "load from CartE7 !!\n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + uInt32 limit; + + limit = (uInt32) in.getLong(); + for(uInt32 i = 0; i < limit; ++i) + myCurrentSlice[i] = (uInt16) in.getLong(); + + myCurrentRAM = (uInt16) in.getLong(); + + // The 2048 bytes 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; + } + + // Set up the previously used banks for the RAM and segment + bankRAM(myCurrentRAM); + bank(myCurrentSlice[0]); + + return true; +} diff --git a/stella/src/emucore/CartE7.hxx b/stella/src/emucore/CartE7.hxx index 6ead04794..087b8c159 100644 --- a/stella/src/emucore/CartE7.hxx +++ b/stella/src/emucore/CartE7.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartE7.hxx,v 1.1.1.1 2001-12-27 19:54:19 bwmott Exp $ +// $Id: CartE7.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEE7_HXX #define CARTRIDGEE7_HXX class CartridgeE7; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -51,7 +53,7 @@ class CartridgeE7; here by accessing 1FF8 to 1FFB. @author Bradford W. Mott - @version $Id: CartE7.hxx,v 1.1.1.1 2001-12-27 19:54:19 bwmott Exp $ + @version $Id: CartE7.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeE7 : public Cartridge { @@ -89,6 +91,22 @@ class CartridgeE7 : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. diff --git a/stella/src/emucore/CartF4SC.cxx b/stella/src/emucore/CartF4SC.cxx index f6dad3ed9..7bea8dfee 100644 --- a/stella/src/emucore/CartF4SC.cxx +++ b/stella/src/emucore/CartF4SC.cxx @@ -13,13 +13,16 @@ // 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.1.1.1 2001-12-27 19:54:19 bwmott Exp $ +// $Id: CartF4SC.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartF4SC.hxx" #include "Random.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeF4SC::CartridgeF4SC(const uInt8* image) @@ -152,3 +155,67 @@ void CartridgeF4SC::bank(uInt16 bank) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeF4SC::save(Serializer& out) +{ + cerr << "save from CartF4SC !!\n"; + string cart = name(); + + try + { + out.putString(cart); + + out.putLong(myCurrentBank); + + // The 128 bytes of RAM + out.putLong(128); + for(uInt32 i = 0; i < 128; ++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 CartridgeF4SC::load(Deserializer& in) +{ + cerr << "load from CartF4SC !!\n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + myCurrentBank = (uInt16) in.getLong(); + + uInt32 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; + } + + // Remember what bank we were in + bank(myCurrentBank); + + return true; +} diff --git a/stella/src/emucore/CartF4SC.hxx b/stella/src/emucore/CartF4SC.hxx index 3366d9971..d3daeef3c 100644 --- a/stella/src/emucore/CartF4SC.hxx +++ b/stella/src/emucore/CartF4SC.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartF4SC.hxx,v 1.1.1.1 2001-12-27 19:54:19 bwmott Exp $ +// $Id: CartF4SC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEF4SC_HXX #define CARTRIDGEF4SC_HXX class CartridgeF4SC; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -29,7 +31,7 @@ class CartridgeF4SC; 128 bytes of RAM. There are eight 4K banks. @author Bradford W. Mott - @version $Id: CartF4SC.hxx,v 1.1.1.1 2001-12-27 19:54:19 bwmott Exp $ + @version $Id: CartF4SC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeF4SC : public Cartridge { @@ -67,6 +69,22 @@ class CartridgeF4SC : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. diff --git a/stella/src/emucore/CartF6.cxx b/stella/src/emucore/CartF6.cxx index 231d85a81..6100e0447 100644 --- a/stella/src/emucore/CartF6.cxx +++ b/stella/src/emucore/CartF6.cxx @@ -13,12 +13,15 @@ // 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.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartF6.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartF6.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeF6::CartridgeF6(const uInt8* image) @@ -163,3 +166,58 @@ void CartridgeF6::bank(uInt16 bank) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeF6::save(Serializer& out) +{ + cerr << "save from CartF6 !!\n"; + string cart = name(); + + try + { + out.putString(cart); + + out.putLong(myCurrentBank); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in save state for " << cart << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeF6::load(Deserializer& in) +{ + cerr << "load from CartF6 !!\n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + myCurrentBank = (uInt16) in.getLong(); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in load state for " << cart << endl; + return false; + } + + // Remember what bank we were in + bank(myCurrentBank); + + return true; +} diff --git a/stella/src/emucore/CartF6.hxx b/stella/src/emucore/CartF6.hxx index fcf595653..34dabb9d8 100644 --- a/stella/src/emucore/CartF6.hxx +++ b/stella/src/emucore/CartF6.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartF6.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartF6.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEF6_HXX #define CARTRIDGEF6_HXX class CartridgeF6; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -29,7 +31,7 @@ class CartridgeF6; are four 4K banks. @author Bradford W. Mott - @version $Id: CartF6.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ + @version $Id: CartF6.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeF6 : public Cartridge { @@ -67,6 +69,22 @@ class CartridgeF6 : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. diff --git a/stella/src/emucore/CartF6SC.cxx b/stella/src/emucore/CartF6SC.cxx index 4e8982481..d724d7f35 100644 --- a/stella/src/emucore/CartF6SC.cxx +++ b/stella/src/emucore/CartF6SC.cxx @@ -13,13 +13,16 @@ // 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.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartF6SC.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartF6SC.hxx" #include "Random.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeF6SC::CartridgeF6SC(const uInt8* image) @@ -196,3 +199,69 @@ void CartridgeF6SC::bank(uInt16 bank) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeF6SC::save(Serializer& out) +{ + cerr << "save from CartF6SC !!\n"; + string cart = name(); + + try + { + out.putString(cart); + + out.putLong(myCurrentBank); + + // The 128 bytes of RAM + out.putLong(128); + for(uInt32 i = 0; i < 128; ++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 CartridgeF6SC::load(Deserializer& in) +{ + cerr << "load from CartF6SC !!\n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + myCurrentBank = (uInt16) in.getLong(); + + // The 128 bytes of RAM + uInt32 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; + } + + // Remember what bank we were in + bank(myCurrentBank); + + return true; +} diff --git a/stella/src/emucore/CartF6SC.hxx b/stella/src/emucore/CartF6SC.hxx index 4453b65a1..a938ac555 100644 --- a/stella/src/emucore/CartF6SC.hxx +++ b/stella/src/emucore/CartF6SC.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartF6SC.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartF6SC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEF6SC_HXX #define CARTRIDGEF6SC_HXX class CartridgeF6SC; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -29,7 +31,7 @@ class CartridgeF6SC; 128 bytes of RAM. There are four 4K banks. @author Bradford W. Mott - @version $Id: CartF6SC.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ + @version $Id: CartF6SC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeF6SC : public Cartridge { @@ -67,6 +69,22 @@ class CartridgeF6SC : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. diff --git a/stella/src/emucore/CartF8.cxx b/stella/src/emucore/CartF8.cxx index 36d8231f4..f7e61e0cd 100644 --- a/stella/src/emucore/CartF8.cxx +++ b/stella/src/emucore/CartF8.cxx @@ -13,12 +13,15 @@ // 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.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartF8.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartF8.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeF8::CartridgeF8(const uInt8* image) @@ -143,3 +146,58 @@ void CartridgeF8::bank(uInt16 bank) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeF8::save(Serializer& out) +{ + cerr << "save from CartF8 !!\n"; + string cart = name(); + + try + { + out.putString(cart); + + out.putLong(myCurrentBank); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in save state for " << cart << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeF8::load(Deserializer& in) +{ + cerr << "load from CartF8 !!\n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + myCurrentBank = (uInt16) in.getLong(); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in load state for " << cart << endl; + return false; + } + + // Remember what bank we were in + bank(myCurrentBank); + + return true; +} diff --git a/stella/src/emucore/CartF8.hxx b/stella/src/emucore/CartF8.hxx index 7b2733ebc..14acd9570 100644 --- a/stella/src/emucore/CartF8.hxx +++ b/stella/src/emucore/CartF8.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartF8.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartF8.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEF8_HXX #define CARTRIDGEF8_HXX class CartridgeF8; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -29,7 +31,7 @@ class CartridgeF8; are two 4K banks. @author Bradford W. Mott - @version $Id: CartF8.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ + @version $Id: CartF8.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeF8 : public Cartridge { @@ -67,6 +69,22 @@ class CartridgeF8 : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. diff --git a/stella/src/emucore/CartF8SC.cxx b/stella/src/emucore/CartF8SC.cxx index 13b6e164c..9bf4ebef7 100644 --- a/stella/src/emucore/CartF8SC.cxx +++ b/stella/src/emucore/CartF8SC.cxx @@ -13,13 +13,16 @@ // 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.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartF8SC.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartF8SC.hxx" #include "Random.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeF8SC::CartridgeF8SC(const uInt8* image) @@ -176,3 +179,67 @@ void CartridgeF8SC::bank(uInt16 bank) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeF8SC::save(Serializer& out) +{ + cerr << "save from CartF8SC !!\n"; + string cart = name(); + + try + { + out.putString(cart); + + out.putLong(myCurrentBank); + + // The 128 bytes of RAM + out.putLong(128); + for(uInt32 i = 0; i < 128; ++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 CartridgeF8SC::load(Deserializer& in) +{ + cerr << "load from CartF8SC !!\n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + myCurrentBank = (uInt16) in.getLong(); + + uInt32 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; + } + + // Remember what bank we were in + bank(myCurrentBank); + + return true; +} diff --git a/stella/src/emucore/CartF8SC.hxx b/stella/src/emucore/CartF8SC.hxx index 0ccc435f8..ca9a28d83 100644 --- a/stella/src/emucore/CartF8SC.hxx +++ b/stella/src/emucore/CartF8SC.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartF8SC.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartF8SC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEF8SC_HXX #define CARTRIDGEF8SC_HXX class CartridgeF8SC; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -29,7 +31,7 @@ class CartridgeF8SC; 128 bytes of RAM. There are two 4K banks. @author Bradford W. Mott - @version $Id: CartF8SC.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ + @version $Id: CartF8SC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeF8SC : public Cartridge { @@ -67,6 +69,22 @@ class CartridgeF8SC : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. diff --git a/stella/src/emucore/CartFASC.cxx b/stella/src/emucore/CartFASC.cxx index 8c9e2e1e2..8d7a453d0 100644 --- a/stella/src/emucore/CartFASC.cxx +++ b/stella/src/emucore/CartFASC.cxx @@ -13,13 +13,16 @@ // 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.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartFASC.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartFASC.hxx" #include "Random.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeFASC::CartridgeFASC(const uInt8* image) @@ -186,3 +189,67 @@ void CartridgeFASC::bank(uInt16 bank) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeFASC::save(Serializer& out) +{ + cerr << "save from CartFASC !!\n"; + string cart = name(); + + try + { + out.putString(cart); + + out.putLong(myCurrentBank); + + // The 256 bytes of RAM + out.putLong(256); + for(uInt32 i = 0; i < 256; ++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 CartridgeFASC::load(Deserializer& in) +{ + cerr << "load from CartFASC \n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + myCurrentBank = (uInt16) in.getLong(); + + uInt32 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; + } + + // Remember what bank we were in + bank(myCurrentBank); + + return true; +} diff --git a/stella/src/emucore/CartFASC.hxx b/stella/src/emucore/CartFASC.hxx index 022c66286..98658ab38 100644 --- a/stella/src/emucore/CartFASC.hxx +++ b/stella/src/emucore/CartFASC.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartFASC.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartFASC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEFASC_HXX #define CARTRIDGEFASC_HXX class CartridgeFASC; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -29,7 +31,7 @@ class CartridgeFASC; three 4K banks and 256 bytes of RAM. @author Bradford W. Mott - @version $Id: CartFASC.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ + @version $Id: CartFASC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeFASC : public Cartridge { @@ -67,6 +69,22 @@ class CartridgeFASC : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. diff --git a/stella/src/emucore/CartFE.cxx b/stella/src/emucore/CartFE.cxx index ee0108024..63642a928 100644 --- a/stella/src/emucore/CartFE.cxx +++ b/stella/src/emucore/CartFE.cxx @@ -13,12 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartFE.cxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartFE.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartFE.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeFE::CartridgeFE(const uInt8* image) @@ -79,3 +82,49 @@ void CartridgeFE::poke(uInt16, uInt8) { } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeFE::save(Serializer& out) +{ + string cart = name(); + + try + { + out.putString(cart); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in save state for " << cart << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeFE::load(Deserializer& in) +{ + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in load state for " << cart << endl; + return false; + } + + return true; +} diff --git a/stella/src/emucore/CartFE.hxx b/stella/src/emucore/CartFE.hxx index 2fc8abbe7..24c21bc79 100644 --- a/stella/src/emucore/CartFE.hxx +++ b/stella/src/emucore/CartFE.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartFE.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ +// $Id: CartFE.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEFE_HXX #define CARTRIDGEFE_HXX class CartridgeFE; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -41,7 +43,7 @@ class CartridgeFE; monitoring the bus. @author Bradford W. Mott - @version $Id: CartFE.hxx,v 1.1.1.1 2001-12-27 19:54:20 bwmott Exp $ + @version $Id: CartFE.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeFE : public Cartridge { @@ -79,6 +81,22 @@ class CartridgeFE : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. diff --git a/stella/src/emucore/CartMB.cxx b/stella/src/emucore/CartMB.cxx index eeff6d260..85c921240 100644 --- a/stella/src/emucore/CartMB.cxx +++ b/stella/src/emucore/CartMB.cxx @@ -13,12 +13,15 @@ // 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.1 2002-01-18 16:01:43 estolberg Exp $ +// $Id: CartMB.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartMB.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeMB::CartridgeMB(const uInt8* image) @@ -118,3 +121,59 @@ void CartridgeMB::incbank() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeMB::save(Serializer& out) +{ + cerr << "save from CartMB !!\n"; + string cart = name(); + + try + { + out.putString(cart); + + out.putLong(myCurrentBank); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in save state for " << cart << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeMB::load(Deserializer& in) +{ + cerr << "load from CartMB !!\n"; + string cart = name(); + + try + { + if(in.getString() != cart) + return false; + + myCurrentBank = (uInt16) in.getLong(); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in load state for " << cart << endl; + return false; + } + + // Remember what bank we were in + --myCurrentBank; + incbank(); + + return true; +} diff --git a/stella/src/emucore/CartMB.hxx b/stella/src/emucore/CartMB.hxx index 89f4c6383..e507fecd0 100644 --- a/stella/src/emucore/CartMB.hxx +++ b/stella/src/emucore/CartMB.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartMB.hxx,v 1.1 2002-01-18 16:02:30 estolberg Exp $ +// $Id: CartMB.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEMB_HXX #define CARTRIDGEMB_HXX class CartridgeMB; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -30,7 +32,7 @@ class CartridgeMB; Accessing $1FF0 switches to next bank. @author Eckhard Stolberg - @version $Id: CartMB.hxx,v 1.1 2002-01-18 16:02:30 estolberg Exp $ + @version $Id: CartMB.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeMB : public Cartridge { @@ -68,6 +70,22 @@ class CartridgeMB : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address. diff --git a/stella/src/emucore/CartMC.cxx b/stella/src/emucore/CartMC.cxx index d47e2d29b..0d7d5c6ca 100644 --- a/stella/src/emucore/CartMC.cxx +++ b/stella/src/emucore/CartMC.cxx @@ -13,13 +13,16 @@ // 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.1.1.1 2001-12-27 19:54:21 bwmott Exp $ +// $Id: CartMC.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include #include "CartMC.hxx" #include "Random.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeMC::CartridgeMC(const uInt8* image, uInt32 size) @@ -216,3 +219,16 @@ void CartridgeMC::poke(uInt16 address, uInt8 value) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeMC::save(Serializer& out) +{ + cerr << "save from CartMC \n"; + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeMC::load(Deserializer& in) +{ + cerr << "load from CartMC \n"; + return true; +} diff --git a/stella/src/emucore/CartMC.hxx b/stella/src/emucore/CartMC.hxx index 529b0f71f..2c87cfd45 100644 --- a/stella/src/emucore/CartMC.hxx +++ b/stella/src/emucore/CartMC.hxx @@ -13,13 +13,15 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CartMC.hxx,v 1.1.1.1 2001-12-27 19:54:21 bwmott Exp $ +// $Id: CartMC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef CARTRIDGEMC_HXX #define CARTRIDGEMC_HXX class CartridgeMC; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Cart.hxx" @@ -133,7 +135,7 @@ class CartridgeMC; @author Bradford W. Mott - @version $Id: CartMC.hxx,v 1.1.1.1 2001-12-27 19:54:21 bwmott Exp $ + @version $Id: CartMC.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class CartridgeMC : public Cartridge { @@ -174,6 +176,22 @@ class CartridgeMC : public Cartridge */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address @@ -204,4 +222,3 @@ class CartridgeMC : public Cartridge uInt8* myImage; }; #endif - diff --git a/stella/src/emucore/M6532.cxx b/stella/src/emucore/M6532.cxx index 6df99c907..daf0bb24c 100644 --- a/stella/src/emucore/M6532.cxx +++ b/stella/src/emucore/M6532.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: M6532.cxx,v 1.1.1.1 2001-12-27 19:54:22 bwmott Exp $ +// $Id: M6532.cxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include @@ -22,6 +22,9 @@ #include "Random.hxx" #include "Switches.hxx" #include "System.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - M6532::M6532(const Console& console) @@ -289,6 +292,81 @@ void M6532::poke(uInt16 addr, uInt8 value) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool M6532::save(Serializer& out) +{ + string device = name(); + + try + { + out.putString(device); + + // Output the RAM + out.putLong(128); + for(uInt32 t = 0; t < 128; ++t) + out.putLong(myRAM[t]); + + out.putLong(myTimer); + out.putLong(myIntervalShift); + out.putLong(myCyclesWhenTimerSet); + out.putLong(myCyclesWhenInterruptReset); + out.putBool(myTimerReadAfterInterrupt); + out.putLong(myDDRA); + out.putLong(myDDRB); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in save state for " << device << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool M6532::load(Deserializer& in) +{ + string device = name(); + + try + { + if(in.getString() != device) + return false; + + // Input the RAM + uInt32 limit = (uInt32) in.getLong(); + for(uInt32 t = 0; t < limit; ++t) + myRAM[t] = (uInt8) in.getLong(); + + myTimer = (uInt32) in.getLong(); + myIntervalShift = (uInt32) in.getLong(); + myCyclesWhenTimerSet = (uInt32) in.getLong(); + myCyclesWhenInterruptReset = (uInt32) in.getLong(); + myTimerReadAfterInterrupt = in.getBool(); + + myDDRA = (uInt8) in.getLong(); + myDDRB = (uInt8) in.getLong(); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in load state for " << device << endl; + return false; + } + + return true; +} + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - M6532::M6532(const M6532& c) : myConsole(c.myConsole) diff --git a/stella/src/emucore/M6532.hxx b/stella/src/emucore/M6532.hxx index 02c854a46..4e85b2ad3 100644 --- a/stella/src/emucore/M6532.hxx +++ b/stella/src/emucore/M6532.hxx @@ -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: M6532.hxx,v 1.1.1.1 2001-12-27 19:54:22 bwmott Exp $ +// $Id: M6532.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef M6532_HXX @@ -21,6 +21,8 @@ class Console; class System; +class Serializer; +class Deserializer; #include "bspf.hxx" #include "Device.hxx" @@ -29,7 +31,7 @@ class System; RIOT @author Bradford W. Mott - @version $Id: M6532.hxx,v 1.1.1.1 2001-12-27 19:54:22 bwmott Exp $ + @version $Id: M6532.hxx,v 1.2 2002-05-13 19:17:32 stephena Exp $ */ class M6532 : public Device { @@ -74,6 +76,22 @@ class M6532 : public Device */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address diff --git a/stella/src/emucore/TIA.cxx b/stella/src/emucore/TIA.cxx index cce10d309..57ea62b24 100644 --- a/stella/src/emucore/TIA.cxx +++ b/stella/src/emucore/TIA.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: TIA.cxx,v 1.12 2002-04-18 17:18:48 stephena Exp $ +// $Id: TIA.cxx,v 1.13 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #include @@ -26,6 +26,9 @@ #include "Sound.hxx" #include "System.hxx" #include "TIA.hxx" +#include "Serializer.hxx" +#include "Deserializer.hxx" +#include #define HBLANK 68 @@ -279,6 +282,195 @@ void TIA::install(System& system) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool TIA::save(Serializer& out) +{ + cerr << "save from TIA !!\n"; + string device = name(); + + try + { + out.putString(device); + + out.putLong(myLastSoundUpdateCycle); + out.putLong(myClockWhenFrameStarted); + out.putLong(myClockStartDisplay); + out.putLong(myClockStopDisplay); + out.putLong(myClockAtLastUpdate); + out.putLong(myClocksToEndOfScanLine); + out.putLong(myScanlineCountForLastFrame); + out.putLong(myVSYNCFinishClock); + + out.putLong(myEnabledObjects); + + out.putLong(myVSYNC); + out.putLong(myVBLANK); + out.putLong(myNUSIZ0); + out.putLong(myNUSIZ1); + + out.putLong(myCOLUP0); + out.putLong(myCOLUP1); + out.putLong(myCOLUPF); + out.putLong(myCOLUBK); + + out.putLong(myCTRLPF); + out.putLong(myPlayfieldPriorityAndScore); + out.putBool(myREFP0); + out.putBool(myREFP1); + out.putLong(myPF); + out.putLong(myGRP0); + out.putLong(myGRP1); + out.putLong(myDGRP0); + out.putLong(myDGRP1); + out.putBool(myENAM0); + out.putBool(myENAM1); + out.putBool(myENABL); + out.putBool(myDENABL); + out.putLong(myHMP0); + out.putLong(myHMP1); + out.putLong(myHMM0); + out.putLong(myHMM1); + out.putLong(myHMBL); + out.putBool(myVDELP0); + out.putBool(myVDELP1); + out.putBool(myVDELBL); + out.putBool(myRESMP0); + out.putBool(myRESMP1); + out.putLong(myCollision); + out.putLong(myPOSP0); + out.putLong(myPOSP1); + out.putLong(myPOSM0); + out.putLong(myPOSM1); + out.putLong(myPOSBL); + + out.putLong(myCurrentGRP0); + out.putLong(myCurrentGRP1); + +// pointers +// myCurrentBLMask = ourBallMaskTable[0][0]; +// myCurrentM0Mask = ourMissleMaskTable[0][0][0]; +// myCurrentM1Mask = ourMissleMaskTable[0][0][0]; +// myCurrentP0Mask = ourPlayerMaskTable[0][0][0]; +// myCurrentP1Mask = ourPlayerMaskTable[0][0][0]; +// myCurrentPFMask = ourPlayfieldTable[0]; + + out.putLong(myLastHMOVEClock); + out.putBool(myHMOVEBlankEnabled); + out.putBool(myM0CosmicArkMotionEnabled); + out.putLong(myM0CosmicArkCounter); + + out.putBool(myDumpEnabled); + out.putLong(myDumpDisabledCycle); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in TIA save state\n"; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool TIA::load(Deserializer& in) +{ + cerr << "load from TIA !!\n"; + string device = name(); + + try + { + if(in.getString() != device) + return false; + + myLastSoundUpdateCycle = (Int32) in.getLong(); + myClockWhenFrameStarted = (Int32) in.getLong(); + myClockStartDisplay = (Int32) in.getLong(); + myClockStopDisplay = (Int32) in.getLong(); + myClockAtLastUpdate = (Int32) in.getLong(); + myClocksToEndOfScanLine = (Int32) in.getLong(); + myScanlineCountForLastFrame = (Int32) in.getLong(); + myVSYNCFinishClock = (Int32) in.getLong(); + + myEnabledObjects = (uInt8) in.getLong(); + + myVSYNC = (uInt8) in.getLong(); + myVBLANK = (uInt8) in.getLong(); + myNUSIZ0 = (uInt8) in.getLong(); + myNUSIZ1 = (uInt8) in.getLong(); + + myCOLUP0 = (uInt32) in.getLong(); + myCOLUP1 = (uInt32) in.getLong(); + myCOLUPF = (uInt32) in.getLong(); + myCOLUBK = (uInt32) in.getLong(); + + myCTRLPF = (uInt8) in.getLong(); + myPlayfieldPriorityAndScore = (uInt8) in.getLong(); + myREFP0 = in.getBool(); + myREFP1 = in.getBool(); + myPF = (uInt32) in.getLong(); + myGRP0 = (uInt8) in.getLong(); + myGRP1 = (uInt8) in.getLong(); + myDGRP0 = (uInt8) in.getLong(); + myDGRP1 = (uInt8) in.getLong(); + myENAM0 = in.getBool(); + myENAM1 = in.getBool(); + myENABL = in.getBool(); + myDENABL = in.getBool(); + myHMP0 = (Int8) in.getLong(); + myHMP1 = (Int8) in.getLong(); + myHMM0 = (Int8) in.getLong(); + myHMM1 = (Int8) in.getLong(); + myHMBL = (Int8) in.getLong(); + myVDELP0 = in.getBool(); + myVDELP1 = in.getBool(); + myVDELBL = in.getBool(); + myRESMP0 = in.getBool(); + myRESMP1 = in.getBool(); + myCollision = (uInt16) in.getLong(); + myPOSP0 = (Int16) in.getLong(); + myPOSP1 = (Int16) in.getLong(); + myPOSM0 = (Int16) in.getLong(); + myPOSM1 = (Int16) in.getLong(); + myPOSBL = (Int16) in.getLong(); + + myCurrentGRP0 = (uInt8) in.getLong(); + myCurrentGRP1 = (uInt8) in.getLong(); + +// pointers +// myCurrentBLMask = ourBallMaskTable[0][0]; +// myCurrentM0Mask = ourMissleMaskTable[0][0][0]; +// myCurrentM1Mask = ourMissleMaskTable[0][0][0]; +// myCurrentP0Mask = ourPlayerMaskTable[0][0][0]; +// myCurrentP1Mask = ourPlayerMaskTable[0][0][0]; +// myCurrentPFMask = ourPlayfieldTable[0]; + + myLastHMOVEClock = (Int32) in.getLong(); + myHMOVEBlankEnabled = in.getBool(); + myM0CosmicArkMotionEnabled = in.getBool(); + myM0CosmicArkCounter = (uInt32) in.getLong(); + + myDumpEnabled = in.getBool(); + myDumpDisabledCycle = (Int32) in.getLong(); + } + catch(char *msg) + { + cerr << msg << endl; + return false; + } + catch(...) + { + cerr << "Unknown error in TIA load state\n"; + return false; + } + + return true; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIA::update() { diff --git a/stella/src/emucore/TIA.hxx b/stella/src/emucore/TIA.hxx index 54cd00a99..72f2048b9 100644 --- a/stella/src/emucore/TIA.hxx +++ b/stella/src/emucore/TIA.hxx @@ -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.hxx,v 1.5 2002-04-18 17:18:48 stephena Exp $ +// $Id: TIA.hxx,v 1.6 2002-05-13 19:17:32 stephena Exp $ //============================================================================ #ifndef TIA_HXX @@ -21,6 +21,8 @@ class Console; class System; +class Serializer; +class Deserializer; #include @@ -40,7 +42,7 @@ class System; be displayed on screen. @author Bradford W. Mott - @version $Id: TIA.hxx,v 1.5 2002-04-18 17:18:48 stephena Exp $ + @version $Id: TIA.hxx,v 1.6 2002-05-13 19:17:32 stephena Exp $ */ class TIA : public Device , public MediaSource { @@ -85,6 +87,22 @@ class TIA : public Device , public MediaSource */ virtual void install(System& system); + /** + Saves the current state of this device to the given Serializer. + + @param out The serializer device to save to. + @return The result of the save. True on success, false on failure. + */ + virtual bool save(Serializer& out); + + /** + Loads the current state of this device from the given Deserializer. + + @param in The deserializer device to load from. + @return The result of the load. True on success, false on failure. + */ + virtual bool load(Deserializer& in); + public: /** Get the byte at the specified address