OK, another huge commit. I need to commit this now, because things are

starting to go out of sync on my development machines.  OK, where to
begin ...

Changed state file format, so older state files will no longer work.  The
changes aren't finalized yet, so expect more breakage.

Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).

Totally reworked controller handling code.  Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.

Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized.  This fixes a long-standing design issue
which I personally caused many years ago.

Console switches state (SWCHB register) is now saved to state files.

Added beginnings of movie support.  Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state.  Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.

Removed specific events for driving controllers, and have them use
joystick events instead.  This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.

Fixed issues with paddle emulation seen in 'Night Driver' ROM.  Related
to this, removed a hack wrt paddles when grabmouse is enabled.  There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.

Added beginnings of TrackBall CX-22 controller emulation.  It doesn't
actually do anything yet, but the class is there :)

Probably some other stuff that I'm forgetting ...


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2007-10-03 21:41:19 +00:00
parent e444ba6901
commit 714b940ac9
89 changed files with 3183 additions and 2970 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: SoundNull.cxx,v 1.6 2007-01-01 18:04:40 stephena Exp $
// $Id: SoundNull.cxx,v 1.7 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include "Serializer.hxx"
@ -47,12 +47,12 @@ bool SoundNull::load(Deserializer& in)
return false;
uInt8 reg;
reg = (uInt8) in.getInt();
reg = (uInt8) in.getInt();
reg = (uInt8) in.getInt();
reg = (uInt8) in.getInt();
reg = (uInt8) in.getInt();
reg = (uInt8) in.getInt();
reg = (uInt8) in.getByte();
reg = (uInt8) in.getByte();
reg = (uInt8) in.getByte();
reg = (uInt8) in.getByte();
reg = (uInt8) in.getByte();
reg = (uInt8) in.getByte();
// myLastRegisterSetCycle
in.getInt();
@ -66,12 +66,12 @@ bool SoundNull::save(Serializer& out)
out.putString("TIASound");
uInt8 reg = 0;
out.putInt(reg);
out.putInt(reg);
out.putInt(reg);
out.putInt(reg);
out.putInt(reg);
out.putInt(reg);
out.putByte((char)reg);
out.putByte((char)reg);
out.putByte((char)reg);
out.putByte((char)reg);
out.putByte((char)reg);
out.putByte((char)reg);
// myLastRegisterSetCycle
out.putInt(0);

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: SoundSDL.cxx,v 1.38 2007-07-27 13:49:16 stephena Exp $
// $Id: SoundSDL.cxx,v 1.39 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifdef SOUND_SUPPORT
@ -438,12 +438,12 @@ bool SoundSDL::load(Deserializer& in)
return false;
uInt8 reg1 = 0, reg2 = 0, reg3 = 0, reg4 = 0, reg5 = 0, reg6 = 0;
reg1 = (uInt8) in.getInt();
reg2 = (uInt8) in.getInt();
reg3 = (uInt8) in.getInt();
reg4 = (uInt8) in.getInt();
reg5 = (uInt8) in.getInt();
reg6 = (uInt8) in.getInt();
reg1 = (uInt8) in.getByte();
reg2 = (uInt8) in.getByte();
reg3 = (uInt8) in.getByte();
reg4 = (uInt8) in.getByte();
reg5 = (uInt8) in.getByte();
reg6 = (uInt8) in.getByte();
myLastRegisterSetCycle = (Int32) in.getInt();
@ -498,12 +498,12 @@ bool SoundSDL::save(Serializer& out)
reg6 = myTIASound.get(0x1a);
}
out.putInt(reg1);
out.putInt(reg2);
out.putInt(reg3);
out.putInt(reg4);
out.putInt(reg5);
out.putInt(reg6);
out.putByte((char)reg1);
out.putByte((char)reg2);
out.putByte((char)reg3);
out.putByte((char)reg4);
out.putByte((char)reg5);
out.putByte((char)reg6);
out.putInt(myLastRegisterSetCycle);
}

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: Debugger.cxx,v 1.116 2007-09-23 17:04:17 stephena Exp $
// $Id: Debugger.cxx,v 1.117 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include "bspf.hxx"
@ -935,7 +935,8 @@ int Debugger::bankCount() {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char *Debugger::getCartType() {
return myConsole->cartridge().name();
return myConsole->cartridge().name().c_str();
// FIXME - maybe whatever is calling this should use a string instead
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: Booster.cxx,v 1.8 2007-01-05 17:54:08 stephena Exp $
// $Id: Booster.cxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include "Event.hxx"
@ -23,6 +23,26 @@
BoosterGrip::BoosterGrip(Jack jack, const Event& event)
: Controller(jack, event, Controller::BoosterGrip)
{
if(myJack == Left)
{
myUpEvent = Event::JoystickZeroUp;
myDownEvent = Event::JoystickZeroDown;
myLeftEvent = Event::JoystickZeroLeft;
myRightEvent = Event::JoystickZeroRight;
myFireEvent = Event::JoystickZeroFire;
myBoosterEvent = Event::BoosterGripZeroBooster;
myTriggerEvent = Event::BoosterGripZeroTrigger;
}
else
{
myUpEvent = Event::JoystickOneUp;
myDownEvent = Event::JoystickOneDown;
myLeftEvent = Event::JoystickOneLeft;
myRightEvent = Event::JoystickOneRight;
myFireEvent = Event::JoystickOneFire;
myBoosterEvent = Event::BoosterGripOneBooster;
myTriggerEvent = Event::BoosterGripOneTrigger;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -31,74 +51,18 @@ BoosterGrip::~BoosterGrip()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool BoosterGrip::read(DigitalPin pin)
void BoosterGrip::update()
{
switch(pin)
{
case One:
return (myJack == Left) ? (myEvent.get(Event::JoystickZeroUp) == 0) :
(myEvent.get(Event::JoystickOneUp) == 0);
myDigitalPinState[One] = (myEvent.get(myUpEvent) == 0);
myDigitalPinState[Two] = (myEvent.get(myDownEvent) == 0);
myDigitalPinState[Three] = (myEvent.get(myLeftEvent) == 0);
myDigitalPinState[Four] = (myEvent.get(myRightEvent) == 0);
myDigitalPinState[Six] = (myEvent.get(myFireEvent) == 0);
case Two:
return (myJack == Left) ? (myEvent.get(Event::JoystickZeroDown) == 0) :
(myEvent.get(Event::JoystickOneDown) == 0);
case Three:
return (myJack == Left) ? (myEvent.get(Event::JoystickZeroLeft) == 0) :
(myEvent.get(Event::JoystickOneLeft) == 0);
case Four:
return (myJack == Left) ? (myEvent.get(Event::JoystickZeroRight) == 0) :
(myEvent.get(Event::JoystickOneRight) == 0);
case Six:
return (myJack == Left) ? (myEvent.get(Event::JoystickZeroFire) == 0) :
(myEvent.get(Event::JoystickOneFire) == 0);
default:
return true;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 BoosterGrip::read(AnalogPin pin)
{
// The CBS Booster-grip has two more buttons on it. These buttons are
// connected to the inputs usually used by paddles.
switch(pin)
{
case Five:
if(myJack == Left)
{
return (myEvent.get(Event::BoosterGripZeroBooster) != 0) ?
minimumResistance : maximumResistance;
}
else
{
return (myEvent.get(Event::BoosterGripOneBooster) != 0) ?
minimumResistance : maximumResistance;
}
case Nine:
if(myJack == Left)
{
return (myEvent.get(Event::BoosterGripZeroTrigger) != 0) ?
minimumResistance : maximumResistance;
}
else
{
return (myEvent.get(Event::BoosterGripOneTrigger) != 0) ?
minimumResistance : maximumResistance;
}
default:
return maximumResistance;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void BoosterGrip::write(DigitalPin, bool)
{
// Writing doesn't do anything to the booster grip...
myAnalogPinValue[Five] = (myEvent.get(myBoosterEvent) != 0) ?
minimumResistance : maximumResistance;
myAnalogPinValue[Nine] = (myEvent.get(myTriggerEvent) != 0) ?
minimumResistance : maximumResistance;
}

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: Booster.hxx,v 1.7 2007-01-01 18:04:45 stephena Exp $
// $Id: Booster.hxx,v 1.8 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef BOOSTERGRIP_HXX
@ -21,6 +21,7 @@
#include "bspf.hxx"
#include "Control.hxx"
#include "Event.hxx"
/**
The standard Atari 2600 joystick controller fitted with the
@ -28,7 +29,7 @@
on it (a booster and a trigger).
@author Bradford W. Mott
@version $Id: Booster.hxx,v 1.7 2007-01-01 18:04:45 stephena Exp $
@version $Id: Booster.hxx,v 1.8 2007-10-03 21:41:17 stephena Exp $
*/
class BoosterGrip : public Controller
{
@ -48,31 +49,16 @@ class BoosterGrip : public Controller
public:
/**
Read the value of the specified digital pin for this controller.
@param pin The pin of the controller jack to read
@return The state of the pin
Update the entire digital and analog pin state according to the
events currently set.
*/
virtual bool read(DigitalPin pin);
virtual void update();
/**
Read the resistance at the specified analog pin for this controller.
The returned value is the resistance measured in ohms.
@param pin The pin of the controller jack to read
@return The resistance at the specified pin
*/
virtual Int32 read(AnalogPin pin);
/**
Write the given value to the specified digital pin for this
controller. Writing is only allowed to the pins associated
with the PIA. Therefore you cannot write to pin six.
@param pin The pin of the controller jack to write to
@param value The value to write to the pin
*/
virtual void write(DigitalPin pin, bool value);
private:
// Pre-compute the events we care about based on given port
// This will eliminate test for left or right port in update()
Event::Type myUpEvent, myDownEvent, myLeftEvent, myRightEvent, myFireEvent;
Event::Type myBoosterEvent, myTriggerEvent;
};
#endif
#endif

View File

@ -13,18 +13,19 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Cart.hxx,v 1.19 2007-06-14 13:47:50 stephena Exp $
// $Id: Cart.hxx,v 1.20 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGE_HXX
#define CARTRIDGE_HXX
#include <fstream>
class Cartridge;
class System;
class Properties;
class Settings;
#include <fstream>
#include "bspf.hxx"
#include "Device.hxx"
@ -33,7 +34,7 @@ class Settings;
game and handles any bankswitching performed by the cartridge.
@author Bradford W. Mott
@version $Id: Cart.hxx,v 1.19 2007-06-14 13:47:50 stephena Exp $
@version $Id: Cart.hxx,v 1.20 2007-10-03 21:41:17 stephena Exp $
*/
class Cartridge : public Device
{
@ -118,6 +119,29 @@ class Cartridge : public Device
*/
virtual uInt8* getImage(int& size) = 0;
/**
Save the current state of this device to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const = 0;
/**
Load the current state of this device from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in) = 0;
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const = 0;
protected:
// If bankLocked is true, ignore attempts at bankswitching. This is used
// by the debugger, when disassembling/dumping ROM.

View File

@ -19,8 +19,6 @@
#include <cassert>
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "Cart0840.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -33,12 +31,6 @@ Cartridge0840::~Cartridge0840()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* Cartridge0840::name() const
{
return "Cartridge0840";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge0840::reset()
{
@ -60,18 +52,6 @@ void Cartridge0840::poke(uInt16 address, uInt8 value)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge0840::save(Serializer& out)
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge0840::load(Deserializer& in)
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge0840::bank(uInt16 bank)
{
@ -101,3 +81,15 @@ uInt8* Cartridge0840::getImage(int& size)
size = 0;
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge0840::save(Serializer& out) const
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge0840::load(Deserializer& in)
{
return false;
}

View File

@ -48,13 +48,6 @@ class Cartridge0840 : public Cartridge
virtual ~Cartridge0840();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -68,22 +61,6 @@ class Cartridge0840 : 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);
/**
Install pages for the specified bank in the system.
@ -120,6 +97,29 @@ class Cartridge0840 : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "Cartridge0840"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,14 +13,12 @@
// 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.10 2007-07-19 16:21:39 stephena Exp $
// $Id: Cart2K.cxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "Cart2K.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -38,12 +36,6 @@ Cartridge2K::~Cartridge2K()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* Cartridge2K::name() const
{
return "Cartridge2K";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge2K::reset()
{
@ -84,7 +76,40 @@ void Cartridge2K::poke(uInt16, uInt8)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge2K::save(Serializer& out)
void Cartridge2K::bank(uInt16 bank)
{
// Doesn't support bankswitching
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge2K::bank()
{
// Doesn't support bankswitching
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge2K::bankCount()
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge2K::patch(uInt16 address, uInt8 value)
{
myImage[address & 0x07FF] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge2K::getImage(int& size)
{
size = 2048;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge2K::save(Serializer& out) const
{
string cart = name();
@ -129,36 +154,3 @@ bool Cartridge2K::load(Deserializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge2K::bank(uInt16 bank)
{
// Doesn't support bankswitching
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge2K::bank()
{
// Doesn't support bankswitching
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge2K::bankCount()
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge2K::patch(uInt16 address, uInt8 value)
{
myImage[address & 0x07FF] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge2K::getImage(int& size)
{
size = 2048;
return &myImage[0];
}

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: Cart2K.hxx,v 1.9 2007-01-14 16:17:52 stephena Exp $
// $Id: Cart2K.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGE2K_HXX
@ -32,7 +32,7 @@ class Deserializer;
2600's 4K cartridge addressing space.
@author Bradford W. Mott
@version $Id: Cart2K.hxx,v 1.9 2007-01-14 16:17:52 stephena Exp $
@version $Id: Cart2K.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
*/
class Cartridge2K : public Cartridge
{
@ -50,13 +50,6 @@ class Cartridge2K : public Cartridge
virtual ~Cartridge2K();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset cartridge to its power-on state
*/
@ -70,22 +63,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -122,6 +99,29 @@ class Cartridge2K : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "Cartridge2K"; }
public:
/**
Get the byte at the specified address

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: Cart3E.cxx,v 1.12 2007-01-14 16:17:52 stephena Exp $
// $Id: Cart3E.cxx,v 1.13 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
@ -21,8 +21,6 @@
#include "Random.hxx"
#include "System.hxx"
#include "TIA.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "Cart3E.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -52,12 +50,6 @@ Cartridge3E::~Cartridge3E()
delete[] myImage;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* Cartridge3E::name() const
{
return "Cartridge3E";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3E::reset()
{
@ -141,69 +133,6 @@ void Cartridge3E::poke(uInt16 address, uInt8 value)
mySystem->tia().poke(address, value);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3E::save(Serializer& out)
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
// Output RAM
out.putInt(32768);
for(uInt32 addr = 0; addr < 32768; ++addr)
out.putInt(myRam[addr]);
}
catch(const char* msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3E::load(Deserializer& in)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
// Input RAM
uInt32 limit = (uInt32) in.getInt();
for(uInt32 addr = 0; addr < limit; ++addr)
myRam[addr] = (uInt8) in.getInt();
}
catch(const 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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3E::bank(uInt16 bank)
{
@ -307,3 +236,66 @@ uInt8* Cartridge3E::getImage(int& size)
size = mySize;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3E::save(Serializer& out) const
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
// Output RAM
out.putInt(32768);
for(uInt32 addr = 0; addr < 32768; ++addr)
out.putByte((char)myRam[addr]);
}
catch(const char* msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3E::load(Deserializer& in)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
// Input RAM
uInt32 limit = (uInt32) in.getInt();
for(uInt32 addr = 0; addr < limit; ++addr)
myRam[addr] = (uInt8) in.getByte();
}
catch(const 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;
}

View File

@ -13,15 +13,13 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Cart3E.hxx,v 1.5 2007-01-14 16:17:52 stephena Exp $
// $Id: Cart3E.hxx,v 1.6 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGE3E_HXX
#define CARTRIDGE3E_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -59,7 +57,7 @@ class Deserializer;
any problems. (Famous last words...)
@author B. Watson
@version $Id: Cart3E.hxx,v 1.5 2007-01-14 16:17:52 stephena Exp $
@version $Id: Cart3E.hxx,v 1.6 2007-10-03 21:41:17 stephena Exp $
*/
class Cartridge3E : public Cartridge
@ -79,13 +77,6 @@ class Cartridge3E : public Cartridge
virtual ~Cartridge3E();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -99,22 +90,6 @@ class Cartridge3E : 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);
/**
Install pages for the specified bank in the system.
@ -151,6 +126,29 @@ class Cartridge3E : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "Cartridge3E"; }
public:
/**
Get the byte at the specified address

View File

@ -13,15 +13,13 @@
// 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.15 2007-01-14 16:17:52 stephena Exp $
// $Id: Cart3F.cxx,v 1.16 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "System.hxx"
#include "TIA.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "Cart3F.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -44,12 +42,6 @@ Cartridge3F::~Cartridge3F()
delete[] myImage;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* Cartridge3F::name() const
{
return "Cartridge3F";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3F::reset()
{
@ -122,59 +114,6 @@ void Cartridge3F::poke(uInt16 address, uInt8 value)
mySystem->tia().poke(address, value);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3F::save(Serializer& out)
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
}
catch(const 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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3F::bank(uInt16 bank)
{
@ -241,3 +180,56 @@ uInt8* Cartridge3F::getImage(int& size)
size = mySize;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3F::save(Serializer& out) const
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
}
catch(const 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;
}

View File

@ -13,15 +13,13 @@
// 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.10 2007-01-14 16:17:52 stephena Exp $
// $Id: Cart3F.hxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGE3F_HXX
#define CARTRIDGE3F_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -37,7 +35,7 @@ class Deserializer;
only used 8K this bankswitching scheme supports up to 512K.
@author Bradford W. Mott
@version $Id: Cart3F.hxx,v 1.10 2007-01-14 16:17:52 stephena Exp $
@version $Id: Cart3F.hxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
*/
class Cartridge3F : public Cartridge
{
@ -56,13 +54,6 @@ class Cartridge3F : public Cartridge
virtual ~Cartridge3F();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -76,22 +67,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -128,6 +103,29 @@ class Cartridge3F : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "Cartridge3F"; }
public:
/**
Get the byte at the specified address

View File

@ -13,14 +13,12 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Cart4A50.cxx,v 1.4 2007-01-14 16:17:52 stephena Exp $
// $Id: Cart4A50.cxx,v 1.5 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "Cart4A50.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -33,12 +31,6 @@ Cartridge4A50::~Cartridge4A50()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* Cartridge4A50::name() const
{
return "Cartridge4A50";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4A50::reset()
{
@ -60,18 +52,6 @@ void Cartridge4A50::poke(uInt16, uInt8)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::save(Serializer& out)
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::load(Deserializer& in)
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4A50::bank(uInt16 b)
{
@ -101,3 +81,16 @@ uInt8* Cartridge4A50::getImage(int& size)
size = 0;
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::save(Serializer& out) const
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::load(Deserializer& in)
{
return false;
}

View File

@ -13,15 +13,13 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Cart4A50.hxx,v 1.5 2007-01-14 16:17:52 stephena Exp $
// $Id: Cart4A50.hxx,v 1.6 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGE4A50_HXX
#define CARTRIDGE4A50_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -31,7 +29,7 @@ class Deserializer;
not bankswitched.
@author Bradford W. Mott
@version $Id: Cart4A50.hxx,v 1.5 2007-01-14 16:17:52 stephena Exp $
@version $Id: Cart4A50.hxx,v 1.6 2007-10-03 21:41:17 stephena Exp $
*/
class Cartridge4A50 : public Cartridge
{
@ -49,13 +47,6 @@ class Cartridge4A50 : public Cartridge
virtual ~Cartridge4A50();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset cartridge to its power-on state
*/
@ -69,22 +60,6 @@ class Cartridge4A50 : 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);
/**
Install pages for the specified bank in the system.
@ -121,6 +96,29 @@ class Cartridge4A50 : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "Cartridge4A50"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,14 +13,12 @@
// 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.10 2007-01-14 16:17:52 stephena Exp $
// $Id: Cart4K.cxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "Cart4K.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -38,12 +36,6 @@ Cartridge4K::~Cartridge4K()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* Cartridge4K::name() const
{
return "Cartridge4K";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4K::reset()
{
@ -84,7 +76,40 @@ void Cartridge4K::poke(uInt16, uInt8)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::save(Serializer& out)
void Cartridge4K::bank(uInt16 bank)
{
// Doesn't support bankswitching
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge4K::bank()
{
// Doesn't support bankswitching
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge4K::bankCount()
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::patch(uInt16 address, uInt8 value)
{
myImage[address & 0x0FFF] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge4K::getImage(int& size)
{
size = 4096;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::save(Serializer& out) const
{
string cart = name();
@ -129,36 +154,3 @@ bool Cartridge4K::load(Deserializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4K::bank(uInt16 bank)
{
// Doesn't support bankswitching
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge4K::bank()
{
// Doesn't support bankswitching
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge4K::bankCount()
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::patch(uInt16 address, uInt8 value)
{
myImage[address & 0x0FFF] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge4K::getImage(int& size)
{
size = 4096;
return &myImage[0];
}

View File

@ -13,15 +13,13 @@
// 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.9 2007-01-14 16:17:53 stephena Exp $
// $Id: Cart4K.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGE4K_HXX
#define CARTRIDGE4K_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -31,7 +29,7 @@ class Deserializer;
not bankswitched.
@author Bradford W. Mott
@version $Id: Cart4K.hxx,v 1.9 2007-01-14 16:17:53 stephena Exp $
@version $Id: Cart4K.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
*/
class Cartridge4K : public Cartridge
{
@ -49,13 +47,6 @@ class Cartridge4K : public Cartridge
virtual ~Cartridge4K();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset cartridge to its power-on state
*/
@ -69,22 +60,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -121,6 +96,29 @@ class Cartridge4K : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "Cartridge4K"; }
public:
/**
Get the byte at the specified address.

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.18 2007-01-14 16:17:53 stephena Exp $
// $Id: CartAR.cxx,v 1.19 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
@ -21,8 +21,6 @@
#include "M6502Hi.hxx"
#include "Random.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartAR.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -53,12 +51,6 @@ CartridgeAR::~CartridgeAR()
delete[] myLoadImages;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeAR::name() const
{
return "CartridgeAR";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeAR::reset()
{
@ -429,7 +421,41 @@ void CartridgeAR::loadIntoRAM(uInt8 load)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeAR::save(Serializer& out)
void CartridgeAR::bank(uInt16 bank)
{
if(bankLocked) return;
bankConfiguration(bank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeAR::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeAR::bankCount()
{
return 32;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeAR::patch(uInt16 address, uInt8 value)
{
// myImage[address & 0x0FFF] = value;
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeAR::getImage(int& size)
{
size = myNumberOfLoadImages * 8448;
return &myLoadImages[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeAR::save(Serializer& out) const
{
string cart = name();
@ -447,12 +473,12 @@ bool CartridgeAR::save(Serializer& out)
// The 6K of RAM and 2K of ROM contained in the Supercharger
out.putInt(8192);
for(i = 0; i < 8192; ++i)
out.putInt(myImage[i]);
out.putByte((char)myImage[i]);
// The 256 byte header for the current 8448 byte load
out.putInt(256);
for(i = 0; i < 256; ++i)
out.putInt(myHeader[i]);
out.putByte((char)myHeader[i]);
// All of the 8448 byte loads associated with the game
// Note that the size of this array is myNumberOfLoadImages * 8448
@ -461,7 +487,7 @@ bool CartridgeAR::save(Serializer& out)
out.putInt(myLoadImages[i]);
// Indicates how many 8448 loads there are
out.putInt(myNumberOfLoadImages);
out.putByte((char)myNumberOfLoadImages);
// Indicates if the RAM is write enabled
out.putBool(myWriteEnabled);
@ -473,7 +499,7 @@ bool CartridgeAR::save(Serializer& out)
out.putInt(myPowerRomCycle);
// Data hold register used for writing
out.putInt(myDataHoldRegister);
out.putByte((char)myDataHoldRegister);
// Indicates number of distinct accesses when data hold register was set
out.putInt(myNumberOfDistinctAccesses);
@ -515,12 +541,12 @@ bool CartridgeAR::load(Deserializer& in)
// The 6K of RAM and 2K of ROM contained in the Supercharger
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myImage[i] = (uInt8) in.getInt();
myImage[i] = (uInt8) in.getByte();
// The 256 byte header for the current 8448 byte load
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myHeader[i] = (uInt8) in.getInt();
myHeader[i] = (uInt8) in.getByte();
// All of the 8448 byte loads associated with the game
// Note that the size of this array is myNumberOfLoadImages * 8448
@ -529,7 +555,7 @@ bool CartridgeAR::load(Deserializer& in)
myLoadImages[i] = (uInt8) in.getInt();
// Indicates how many 8448 loads there are
myNumberOfLoadImages = (uInt8) in.getInt();
myNumberOfLoadImages = (uInt8) in.getByte();
// Indicates if the RAM is write enabled
myWriteEnabled = in.getBool();
@ -541,7 +567,7 @@ bool CartridgeAR::load(Deserializer& in)
myPowerRomCycle = (Int32) in.getInt();
// Data hold register used for writing
myDataHoldRegister = (uInt8) in.getInt();
myDataHoldRegister = (uInt8) in.getByte();
// Indicates number of distinct accesses when data hold register was set
myNumberOfDistinctAccesses = (uInt32) in.getInt();
@ -562,37 +588,3 @@ bool CartridgeAR::load(Deserializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeAR::bank(uInt16 bank)
{
if(bankLocked) return;
bankConfiguration(bank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeAR::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeAR::bankCount()
{
return 32;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeAR::patch(uInt16 address, uInt8 value)
{
// myImage[address & 0x0FFF] = value;
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeAR::getImage(int& size)
{
size = myNumberOfLoadImages * 8448;
return &myLoadImages[0];
}

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.hxx,v 1.12 2007-01-14 16:17:53 stephena Exp $
// $Id: CartAR.hxx,v 1.13 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEAR_HXX
@ -21,8 +21,6 @@
class M6502High;
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -37,7 +35,7 @@ class Deserializer;
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.12 2007-01-14 16:17:53 stephena Exp $
@version $Id: CartAR.hxx,v 1.13 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeAR : public Cartridge
{
@ -57,13 +55,6 @@ class CartridgeAR : public Cartridge
virtual ~CartridgeAR();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -84,22 +75,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -136,6 +111,29 @@ class CartridgeAR : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeAR"; }
public:
/**
Get the byte at the specified address

View File

@ -13,15 +13,13 @@
// 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.14 2007-01-14 16:17:53 stephena Exp $
// $Id: CartCV.cxx,v 1.15 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "Random.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartCV.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -68,12 +66,6 @@ CartridgeCV::~CartridgeCV()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeCV::name() const
{
return "CartridgeCV";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCV::reset()
{
@ -131,63 +123,6 @@ void CartridgeCV::poke(uInt16, uInt8)
// This is ROM so poking has no effect :-)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeCV::save(Serializer& out)
{
string cart = name();
try
{
out.putString(cart);
// Output RAM
out.putInt(1024);
for(uInt32 addr = 0; addr < 1024; ++addr)
out.putInt(myRAM[addr]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
// Input RAM
uInt32 limit = (uInt32) in.getInt();
for(uInt32 addr = 0; addr < limit; ++addr)
myRAM[addr] = (uInt8) in.getInt();
}
catch(const char* msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCV::bank(uInt16 bank)
{
@ -220,3 +155,60 @@ uInt8* CartridgeCV::getImage(int& size)
size = 2048;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeCV::save(Serializer& out) const
{
string cart = name();
try
{
out.putString(cart);
// Output RAM
out.putInt(1024);
for(uInt32 addr = 0; addr < 1024; ++addr)
out.putByte((char)myRAM[addr]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
// Input RAM
uInt32 limit = (uInt32) in.getInt();
for(uInt32 addr = 0; addr < limit; ++addr)
myRAM[addr] = (uInt8) in.getByte();
}
catch(const char* msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
return true;
}

View File

@ -13,15 +13,13 @@
// 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.9 2007-01-14 16:17:53 stephena Exp $
// $Id: CartCV.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGECV_HXX
#define CARTRIDGECV_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -34,7 +32,7 @@ class Deserializer;
$F800-$FFFF ROM
@author Eckhard Stolberg
@version $Id: CartCV.hxx,v 1.9 2007-01-14 16:17:53 stephena Exp $
@version $Id: CartCV.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeCV : public Cartridge
{
@ -52,13 +50,6 @@ class CartridgeCV : public Cartridge
virtual ~CartridgeCV();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset cartridge to its power-on state
*/
@ -72,22 +63,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -124,6 +99,29 @@ class CartridgeCV : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeCV"; }
public:
/**
Get the byte at the specified address

View File

@ -13,15 +13,14 @@
// 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.18 2007-01-14 16:17:53 stephena Exp $
// $Id: CartDPC.cxx,v 1.19 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <assert.h>
#include <cassert>
#include <iostream>
#include "CartDPC.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartDPC.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeDPC::CartridgeDPC(const uInt8* image, uInt32 size)
@ -67,12 +66,6 @@ CartridgeDPC::~CartridgeDPC()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeDPC::name() const
{
return "CartridgeDPC";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDPC::reset()
{
@ -427,129 +420,6 @@ void CartridgeDPC::poke(uInt16 address, uInt8 value)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeDPC::save(Serializer& out)
{
string cart = name();
try
{
uInt32 i;
out.putString(cart);
// Indicates which bank is currently active
out.putInt(myCurrentBank);
// The top registers for the data fetchers
out.putInt(8);
for(i = 0; i < 8; ++i)
out.putInt(myTops[i]);
// The bottom registers for the data fetchers
out.putInt(8);
for(i = 0; i < 8; ++i)
out.putInt(myBottoms[i]);
// The counter registers for the data fetchers
out.putInt(8);
for(i = 0; i < 8; ++i)
out.putInt(myCounters[i]);
// The flag registers for the data fetchers
out.putInt(8);
for(i = 0; i < 8; ++i)
out.putInt(myFlags[i]);
// The music mode flags for the data fetchers
out.putInt(3);
for(i = 0; i < 3; ++i)
out.putBool(myMusicMode[i]);
// The random number generator register
out.putInt(myRandomNumber);
out.putInt(mySystemCycles);
out.putInt((uInt32)(myFractionalClocks * 100000000.0));
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
uInt32 i, limit;
// Indicates which bank is currently active
myCurrentBank = (uInt16) in.getInt();
// The top registers for the data fetchers
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myTops[i] = (uInt8) in.getInt();
// The bottom registers for the data fetchers
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myBottoms[i] = (uInt8) in.getInt();
// The counter registers for the data fetchers
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myCounters[i] = (uInt16) in.getInt();
// The flag registers for the data fetchers
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myFlags[i] = (uInt8) in.getInt();
// The music mode flags for the data fetchers
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myMusicMode[i] = in.getBool();
// The random number generator register
myRandomNumber = (uInt8) in.getInt();
// Get system cycles and fractional clocks
mySystemCycles = in.getInt();
myFractionalClocks = (double)in.getInt() / 100000000.0;
}
catch(const 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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDPC::bank(uInt16 bank)
{
@ -609,3 +479,126 @@ uInt8* CartridgeDPC::getImage(int& size)
return &myImageCopy[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeDPC::save(Serializer& out) const
{
string cart = name();
try
{
uInt32 i;
out.putString(cart);
// Indicates which bank is currently active
out.putInt(myCurrentBank);
// The top registers for the data fetchers
out.putInt(8);
for(i = 0; i < 8; ++i)
out.putByte((char)myTops[i]);
// The bottom registers for the data fetchers
out.putInt(8);
for(i = 0; i < 8; ++i)
out.putByte((char)myBottoms[i]);
// The counter registers for the data fetchers
out.putInt(8);
for(i = 0; i < 8; ++i)
out.putInt(myCounters[i]);
// The flag registers for the data fetchers
out.putInt(8);
for(i = 0; i < 8; ++i)
out.putByte((char)myFlags[i]);
// The music mode flags for the data fetchers
out.putInt(3);
for(i = 0; i < 3; ++i)
out.putBool(myMusicMode[i]);
// The random number generator register
out.putByte((char)myRandomNumber);
out.putInt(mySystemCycles);
out.putInt((uInt32)(myFractionalClocks * 100000000.0));
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
uInt32 i, limit;
// Indicates which bank is currently active
myCurrentBank = (uInt16) in.getInt();
// The top registers for the data fetchers
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myTops[i] = (uInt8) in.getByte();
// The bottom registers for the data fetchers
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myBottoms[i] = (uInt8) in.getByte();
// The counter registers for the data fetchers
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myCounters[i] = (uInt16) in.getInt();
// The flag registers for the data fetchers
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myFlags[i] = (uInt8) in.getByte();
// The music mode flags for the data fetchers
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myMusicMode[i] = in.getBool();
// The random number generator register
myRandomNumber = (uInt8) in.getByte();
// Get system cycles and fractional clocks
mySystemCycles = in.getInt();
myFractionalClocks = (double)in.getInt() / 100000000.0;
}
catch(const 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;
}

View File

@ -13,15 +13,13 @@
// 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.10 2007-01-14 16:17:53 stephena Exp $
// $Id: CartDPC.hxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEDCP_HXX
#define CARTRIDGEDCP_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -32,7 +30,7 @@ class Deserializer;
see David P. Crane's United States Patent Number 4,644,495.
@author Bradford W. Mott
@version $Id: CartDPC.hxx,v 1.10 2007-01-14 16:17:53 stephena Exp $
@version $Id: CartDPC.hxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeDPC : public Cartridge
{
@ -50,13 +48,6 @@ class CartridgeDPC : public Cartridge
virtual ~CartridgeDPC();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -77,22 +68,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -129,6 +104,29 @@ class CartridgeDPC : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeDPC"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,14 +13,12 @@
// 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.13 2007-01-14 16:17:53 stephena Exp $
// $Id: CartE0.cxx,v 1.14 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartE0.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -38,12 +36,6 @@ CartridgeE0::~CartridgeE0()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeE0::name() const
{
return "CartridgeE0";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeE0::reset()
{
@ -197,7 +189,42 @@ void CartridgeE0::segmentTwo(uInt16 slice)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE0::save(Serializer& out)
void CartridgeE0::bank(uInt16 bank)
{
// FIXME - get this working, so we can debug E0 carts
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeE0::bank()
{
// FIXME - get this working, so we can debug E0 carts
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeE0::bankCount()
{
// FIXME - get this working, so we can debug E0 carts
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE0::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[(myCurrentSlice[address >> 10] << 10) + (address & 0x03FF)] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeE0::getImage(int& size)
{
size = 8192;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE0::save(Serializer& out) const
{
string cart = name();
@ -250,38 +277,3 @@ bool CartridgeE0::load(Deserializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeE0::bank(uInt16 bank)
{
// FIXME - get this working, so we can debug E0 carts
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeE0::bank()
{
// FIXME - get this working, so we can debug E0 carts
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeE0::bankCount()
{
// FIXME - get this working, so we can debug E0 carts
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE0::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[(myCurrentSlice[address >> 10] << 10) + (address & 0x03FF)] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeE0::getImage(int& size)
{
size = 8192;
return &myImage[0];
}

View File

@ -13,15 +13,13 @@
// 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.9 2007-01-14 16:17:53 stephena Exp $
// $Id: CartE0.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEE0_HXX
#define CARTRIDGEE0_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -36,7 +34,7 @@ class Deserializer;
always points to the last 1K of the ROM image.
@author Bradford W. Mott
@version $Id: CartE0.hxx,v 1.9 2007-01-14 16:17:53 stephena Exp $
@version $Id: CartE0.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeE0 : public Cartridge
{
@ -54,13 +52,6 @@ class CartridgeE0 : public Cartridge
virtual ~CartridgeE0();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -74,22 +65,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -126,6 +101,29 @@ class CartridgeE0 : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeE0"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,15 +13,13 @@
// 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.16 2007-01-14 16:17:53 stephena Exp $
// $Id: CartE7.cxx,v 1.17 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "Random.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartE7.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -46,12 +44,6 @@ CartridgeE7::~CartridgeE7()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeE7::name() const
{
return "CartridgeE7";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeE7::reset()
{
@ -168,83 +160,6 @@ void CartridgeE7::bankRAM(uInt16 bank)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE7::save(Serializer& out)
{
string cart = name();
try
{
uInt32 i;
out.putString(cart);
out.putInt(2);
for(i = 0; i < 2; ++i)
out.putInt(myCurrentSlice[i]);
out.putInt(myCurrentRAM);
// The 2048 bytes of RAM
out.putInt(2048);
for(i = 0; i < 2048; ++i)
out.putInt(myRAM[i]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
uInt32 i, limit;
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myCurrentSlice[i] = (uInt16) in.getInt();
myCurrentRAM = (uInt16) in.getInt();
// The 2048 bytes of RAM
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt();
}
catch(const 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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeE7::bank(uInt16 slice)
{
@ -321,3 +236,80 @@ uInt8* CartridgeE7::getImage(int& size)
size = 16384;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE7::save(Serializer& out) const
{
string cart = name();
try
{
uInt32 i;
out.putString(cart);
out.putInt(2);
for(i = 0; i < 2; ++i)
out.putInt(myCurrentSlice[i]);
out.putInt(myCurrentRAM);
// The 2048 bytes of RAM
out.putInt(2048);
for(i = 0; i < 2048; ++i)
out.putByte((char)myRAM[i]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
uInt32 i, limit;
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myCurrentSlice[i] = (uInt16) in.getInt();
myCurrentRAM = (uInt16) in.getInt();
// The 2048 bytes of RAM
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getByte();
}
catch(const 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;
}

View File

@ -13,15 +13,13 @@
// 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.10 2007-01-14 16:17:53 stephena Exp $
// $Id: CartE7.hxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEE7_HXX
#define CARTRIDGEE7_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -53,7 +51,7 @@ class Deserializer;
here by accessing 1FF8 to 1FFB.
@author Bradford W. Mott
@version $Id: CartE7.hxx,v 1.10 2007-01-14 16:17:53 stephena Exp $
@version $Id: CartE7.hxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeE7 : public Cartridge
{
@ -71,13 +69,6 @@ class CartridgeE7 : public Cartridge
virtual ~CartridgeE7();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -91,22 +82,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -143,6 +118,29 @@ class CartridgeE7 : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeE7"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,15 +13,13 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartF4.cxx,v 1.11 2007-01-14 16:17:53 stephena Exp $
// $Id: CartF4.cxx,v 1.12 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "Random.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartF4.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -39,12 +37,6 @@ CartridgeF4::~CartridgeF4()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeF4::name() const
{
return "CartridgeF4";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF4::reset()
{
@ -103,7 +95,59 @@ void CartridgeF4::poke(uInt16 address, uInt8)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4::save(Serializer& out)
void CartridgeF4::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;
uInt16 shift = mySystem->pageShift();
uInt16 mask = mySystem->pageMask();
// Setup the page access methods for the current bank
System::PageAccess access;
access.device = this;
access.directPokeBase = 0;
// Map ROM image into the system
for(uInt32 address = 0x1000; address < (0x1FF4U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF4::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF4::bankCount()
{
return 8;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF4::getImage(int& size)
{
size = 32768;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4::save(Serializer& out) const
{
string cart = name();
@ -156,55 +200,3 @@ bool CartridgeF4::load(Deserializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF4::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;
uInt16 shift = mySystem->pageShift();
uInt16 mask = mySystem->pageMask();
// Setup the page access methods for the current bank
System::PageAccess access;
access.device = this;
access.directPokeBase = 0;
// Map ROM image into the system
for(uInt32 address = 0x1000; address < (0x1FF4U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF4::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF4::bankCount()
{
return 8;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF4::getImage(int& size)
{
size = 32768;
return &myImage[0];
}

View File

@ -13,15 +13,13 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartF4.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
// $Id: CartF4.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEF4_HXX
#define CARTRIDGEF4_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -31,7 +29,7 @@ class Deserializer;
are eight 4K banks.
@author Bradford W. Mott
@version $Id: CartF4.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
@version $Id: CartF4.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeF4 : public Cartridge
{
@ -49,13 +47,6 @@ class CartridgeF4 : public Cartridge
virtual ~CartridgeF4();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -69,22 +60,6 @@ class CartridgeF4 : 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);
/**
Install pages for the specified bank in the system.
@ -121,6 +96,29 @@ class CartridgeF4 : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeF4"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,15 +13,13 @@
// 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.14 2007-01-14 16:17:54 stephena Exp $
// $Id: CartF4SC.cxx,v 1.15 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "Random.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartF4SC.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -46,12 +44,6 @@ CartridgeF4SC::~CartridgeF4SC()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeF4SC::name() const
{
return "CartridgeF4SC";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF4SC::reset()
{
@ -132,69 +124,6 @@ void CartridgeF4SC::poke(uInt16 address, uInt8)
// has been setup
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4SC::save(Serializer& out)
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
// The 128 bytes of RAM
out.putInt(128);
for(uInt32 i = 0; i < 128; ++i)
out.putInt(myRAM[i]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
uInt32 limit = (uInt32) in.getInt();
for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt();
}
catch(const 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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF4SC::bank(uInt16 bank)
{
@ -246,3 +175,66 @@ uInt8* CartridgeF4SC::getImage(int& size)
size = 32768;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4SC::save(Serializer& out) const
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
// The 128 bytes of RAM
out.putInt(128);
for(uInt32 i = 0; i < 128; ++i)
out.putByte((char)myRAM[i]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
uInt32 limit = (uInt32) in.getInt();
for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getByte();
}
catch(const 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;
}

View File

@ -13,15 +13,13 @@
// 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.9 2007-01-14 16:17:54 stephena Exp $
// $Id: CartF4SC.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEF4SC_HXX
#define CARTRIDGEF4SC_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -31,7 +29,7 @@ class Deserializer;
128 bytes of RAM. There are eight 4K banks.
@author Bradford W. Mott
@version $Id: CartF4SC.hxx,v 1.9 2007-01-14 16:17:54 stephena Exp $
@version $Id: CartF4SC.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeF4SC : public Cartridge
{
@ -49,13 +47,6 @@ class CartridgeF4SC : public Cartridge
virtual ~CartridgeF4SC();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -69,22 +60,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -121,6 +96,29 @@ class CartridgeF4SC : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeF4SC"; }
public:
/**
Get the byte at the specified address.

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.13 2007-01-14 16:17:54 stephena Exp $
// $Id: CartF6.cxx,v 1.14 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
@ -38,12 +38,6 @@ CartridgeF6::~CartridgeF6()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeF6::name() const
{
return "CartridgeF6";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF6::reset()
{
@ -144,7 +138,59 @@ void CartridgeF6::poke(uInt16 address, uInt8)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6::save(Serializer& out)
void CartridgeF6::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;
uInt16 shift = mySystem->pageShift();
uInt16 mask = mySystem->pageMask();
// Setup the page access methods for the current bank
System::PageAccess access;
access.device = this;
access.directPokeBase = 0;
// Map ROM image into the system
for(uInt32 address = 0x1000; address < (0x1FF6U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF6::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF6::bankCount()
{
return 4;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF6::getImage(int& size)
{
size = 16384;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6::save(Serializer& out) const
{
string cart = name();
@ -196,55 +242,3 @@ bool CartridgeF6::load(Deserializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF6::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;
uInt16 shift = mySystem->pageShift();
uInt16 mask = mySystem->pageMask();
// Setup the page access methods for the current bank
System::PageAccess access;
access.device = this;
access.directPokeBase = 0;
// Map ROM image into the system
for(uInt32 address = 0x1000; address < (0x1FF6U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF6::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF6::bankCount()
{
return 4;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF6::getImage(int& size)
{
size = 16384;
return &myImage[0];
}

View File

@ -13,15 +13,13 @@
// 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.10 2007-01-14 16:17:54 stephena Exp $
// $Id: CartF6.hxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEF6_HXX
#define CARTRIDGEF6_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -31,7 +29,7 @@ class Deserializer;
are four 4K banks.
@author Bradford W. Mott
@version $Id: CartF6.hxx,v 1.10 2007-01-14 16:17:54 stephena Exp $
@version $Id: CartF6.hxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeF6 : public Cartridge
{
@ -49,13 +47,6 @@ class CartridgeF6 : public Cartridge
virtual ~CartridgeF6();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -69,22 +60,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -121,6 +96,29 @@ class CartridgeF6 : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeF6"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,15 +13,13 @@
// 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.13 2007-01-14 16:17:54 stephena Exp $
// $Id: CartF6SC.cxx,v 1.14 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "Random.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartF6SC.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -46,12 +44,6 @@ CartridgeF6SC::~CartridgeF6SC()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeF6SC::name() const
{
return "CartridgeF6SC";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF6SC::reset()
{
@ -176,71 +168,6 @@ void CartridgeF6SC::poke(uInt16 address, uInt8)
// has been setup
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6SC::save(Serializer& out)
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
// The 128 bytes of RAM
out.putInt(128);
for(uInt32 i = 0; i < 128; ++i)
out.putInt(myRAM[i]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
// The 128 bytes of RAM
uInt32 limit = (uInt32) in.getInt();
for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt();
}
catch(const 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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF6SC::bank(uInt16 bank)
{
@ -292,3 +219,68 @@ uInt8* CartridgeF6SC::getImage(int& size)
size = 16384;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6SC::save(Serializer& out) const
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
// The 128 bytes of RAM
out.putInt(128);
for(uInt32 i = 0; i < 128; ++i)
out.putByte((char)myRAM[i]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
// The 128 bytes of RAM
uInt32 limit = (uInt32) in.getInt();
for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getByte();
}
catch(const 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;
}

View File

@ -13,15 +13,13 @@
// 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.9 2007-01-14 16:17:54 stephena Exp $
// $Id: CartF6SC.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEF6SC_HXX
#define CARTRIDGEF6SC_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -31,7 +29,7 @@ class Deserializer;
128 bytes of RAM. There are four 4K banks.
@author Bradford W. Mott
@version $Id: CartF6SC.hxx,v 1.9 2007-01-14 16:17:54 stephena Exp $
@version $Id: CartF6SC.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeF6SC : public Cartridge
{
@ -49,13 +47,6 @@ class CartridgeF6SC : public Cartridge
virtual ~CartridgeF6SC();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -69,22 +60,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -121,6 +96,29 @@ class CartridgeF6SC : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeF6SC"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,14 +13,12 @@
// 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.15 2007-01-14 16:17:54 stephena Exp $
// $Id: CartF8.cxx,v 1.16 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartF8.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -42,12 +40,6 @@ CartridgeF8::~CartridgeF8()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeF8::name() const
{
return "CartridgeF8";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF8::reset()
{
@ -127,60 +119,6 @@ void CartridgeF8::poke(uInt16 address, uInt8)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8::save(Serializer& out)
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
}
catch(const 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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF8::bank(uInt16 bank)
{
@ -233,3 +171,57 @@ uInt8* CartridgeF8::getImage(int& size)
size = 8192;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8::save(Serializer& out) const
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
}
catch(const 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;
}

View File

@ -13,15 +13,13 @@
// 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.10 2007-01-14 16:17:54 stephena Exp $
// $Id: CartF8.hxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEF8_HXX
#define CARTRIDGEF8_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -31,7 +29,7 @@ class Deserializer;
are two 4K banks.
@author Bradford W. Mott
@version $Id: CartF8.hxx,v 1.10 2007-01-14 16:17:54 stephena Exp $
@version $Id: CartF8.hxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeF8 : public Cartridge
{
@ -50,13 +48,6 @@ class CartridgeF8 : public Cartridge
virtual ~CartridgeF8();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -70,22 +61,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -122,6 +97,29 @@ class CartridgeF8 : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeF8"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,15 +13,13 @@
// 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.13 2007-01-14 16:17:54 stephena Exp $
// $Id: CartF8SC.cxx,v 1.14 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "Random.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartF8SC.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -46,12 +44,6 @@ CartridgeF8SC::~CartridgeF8SC()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeF8SC::name() const
{
return "CartridgeF8SC";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF8SC::reset()
{
@ -160,69 +152,6 @@ void CartridgeF8SC::poke(uInt16 address, uInt8)
// has been setup
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8SC::save(Serializer& out)
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
// The 128 bytes of RAM
out.putInt(128);
for(uInt32 i = 0; i < 128; ++i)
out.putInt(myRAM[i]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
uInt32 limit = (uInt32) in.getInt();
for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt();
}
catch(const 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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF8SC::bank(uInt16 bank)
{
@ -274,3 +203,66 @@ uInt8* CartridgeF8SC::getImage(int& size)
size = 8192;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8SC::save(Serializer& out) const
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
// The 128 bytes of RAM
out.putInt(128);
for(uInt32 i = 0; i < 128; ++i)
out.putByte((char)myRAM[i]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
uInt32 limit = (uInt32) in.getInt();
for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getByte();
}
catch(const 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;
}

View File

@ -13,15 +13,13 @@
// 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.8 2007-01-14 16:17:54 stephena Exp $
// $Id: CartF8SC.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEF8SC_HXX
#define CARTRIDGEF8SC_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -31,7 +29,7 @@ class Deserializer;
128 bytes of RAM. There are two 4K banks.
@author Bradford W. Mott
@version $Id: CartF8SC.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
@version $Id: CartF8SC.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeF8SC : public Cartridge
{
@ -49,13 +47,6 @@ class CartridgeF8SC : public Cartridge
virtual ~CartridgeF8SC();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -69,22 +60,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -121,6 +96,29 @@ class CartridgeF8SC : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeF8SC"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,15 +13,13 @@
// 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.12 2007-01-14 16:17:54 stephena Exp $
// $Id: CartFASC.cxx,v 1.13 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "Random.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartFASC.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -46,12 +44,6 @@ CartridgeFASC::~CartridgeFASC()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeFASC::name() const
{
return "CartridgeFASC";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeFASC::reset()
{
@ -166,69 +158,6 @@ void CartridgeFASC::poke(uInt16 address, uInt8)
// has been setup
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFASC::save(Serializer& out)
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
// The 256 bytes of RAM
out.putInt(256);
for(uInt32 i = 0; i < 256; ++i)
out.putInt(myRAM[i]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
uInt32 limit = (uInt32) in.getInt();
for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt();
}
catch(const 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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeFASC::bank(uInt16 bank)
{
@ -280,3 +209,66 @@ uInt8* CartridgeFASC::getImage(int& size)
size = 12288;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFASC::save(Serializer& out) const
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
// The 256 bytes of RAM
out.putInt(256);
for(uInt32 i = 0; i < 256; ++i)
out.putByte((char)myRAM[i]);
}
catch(const 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)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
uInt32 limit = (uInt32) in.getInt();
for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getByte();
}
catch(const 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;
}

View File

@ -13,15 +13,13 @@
// 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.8 2007-01-14 16:17:54 stephena Exp $
// $Id: CartFASC.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEFASC_HXX
#define CARTRIDGEFASC_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -31,7 +29,7 @@ class Deserializer;
three 4K banks and 256 bytes of RAM.
@author Bradford W. Mott
@version $Id: CartFASC.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
@version $Id: CartFASC.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeFASC : public Cartridge
{
@ -49,13 +47,6 @@ class CartridgeFASC : public Cartridge
virtual ~CartridgeFASC();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -69,22 +60,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -121,6 +96,29 @@ class CartridgeFASC : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeFASC"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,14 +13,12 @@
// 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.8 2007-01-14 16:17:54 stephena Exp $
// $Id: CartFE.cxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartFE.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -38,12 +36,6 @@ CartridgeFE::~CartridgeFE()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeFE::name() const
{
return "CartridgeFE";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeFE::reset()
{
@ -83,7 +75,40 @@ void CartridgeFE::poke(uInt16, uInt8)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFE::save(Serializer& out)
void CartridgeFE::bank(uInt16 b)
{
// Doesn't support bankswitching in the normal sense
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeFE::bank()
{
// Doesn't support bankswitching in the normal sense
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeFE::bankCount()
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFE::patch(uInt16 address, uInt8 value)
{
myImage[(address & 0x0FFF) + (((address & 0x2000) == 0) ? 4096 : 0)] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeFE::getImage(int& size)
{
size = 8192;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFE::save(Serializer& out) const
{
string cart = name();
@ -128,36 +153,3 @@ bool CartridgeFE::load(Deserializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeFE::bank(uInt16 b)
{
// Doesn't support bankswitching in the normal sense
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeFE::bank()
{
// Doesn't support bankswitching in the normal sense
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeFE::bankCount()
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFE::patch(uInt16 address, uInt8 value)
{
myImage[(address & 0x0FFF) + (((address & 0x2000) == 0) ? 4096 : 0)] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeFE::getImage(int& size)
{
size = 8192;
return &myImage[0];
}

View File

@ -13,15 +13,13 @@
// 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.8 2007-01-14 16:17:54 stephena Exp $
// $Id: CartFE.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEFE_HXX
#define CARTRIDGEFE_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -43,7 +41,7 @@ class Deserializer;
monitoring the bus.
@author Bradford W. Mott
@version $Id: CartFE.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
@version $Id: CartFE.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeFE : public Cartridge
{
@ -61,13 +59,6 @@ class CartridgeFE : public Cartridge
virtual ~CartridgeFE();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -81,22 +72,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -133,6 +108,29 @@ class CartridgeFE : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeFE"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,14 +13,12 @@
// 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.11 2007-01-14 16:17:55 stephena Exp $
// $Id: CartMB.cxx,v 1.12 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartMB.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -38,12 +36,6 @@ CartridgeMB::~CartridgeMB()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeMB::name() const
{
return "CartridgeMB";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeMB::reset()
{
@ -124,7 +116,43 @@ void CartridgeMB::incbank()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMB::save(Serializer& out)
void CartridgeMB::bank(uInt16 bank)
{
if(bankLocked) return;
myCurrentBank = (bank - 1);
incbank();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeMB::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeMB::bankCount()
{
return 16;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMB::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeMB::getImage(int& size)
{
size = 65536;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMB::save(Serializer& out) const
{
string cart = name();
@ -177,39 +205,3 @@ bool CartridgeMB::load(Deserializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeMB::bank(uInt16 bank)
{
if(bankLocked) return;
myCurrentBank = (bank - 1);
incbank();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeMB::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeMB::bankCount()
{
return 16;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMB::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeMB::getImage(int& size)
{
size = 65536;
return &myImage[0];
}

View File

@ -13,15 +13,13 @@
// 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.8 2007-01-14 16:17:55 stephena Exp $
// $Id: CartMB.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEMB_HXX
#define CARTRIDGEMB_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -32,7 +30,7 @@ class Deserializer;
Accessing $1FF0 switches to next bank.
@author Eckhard Stolberg
@version $Id: CartMB.hxx,v 1.8 2007-01-14 16:17:55 stephena Exp $
@version $Id: CartMB.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeMB : public Cartridge
{
@ -50,13 +48,6 @@ class CartridgeMB : public Cartridge
virtual ~CartridgeMB();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -70,22 +61,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -122,6 +97,29 @@ class CartridgeMB : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeMB"; }
public:
/**
Get the byte at the specified address.

View File

@ -13,15 +13,13 @@
// 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.12 2007-01-14 16:17:55 stephena Exp $
// $Id: CartMC.cxx,v 1.13 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "Random.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartMC.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -66,12 +64,6 @@ CartridgeMC::~CartridgeMC()
delete[] myImage;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeMC::name() const
{
return "CartridgeMC";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeMC::reset()
{
@ -219,77 +211,6 @@ void CartridgeMC::poke(uInt16 address, uInt8 value)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMC::save(Serializer& out)
{
uInt32 i;
string cart = name();
try
{
out.putString(cart);
// The currentBlock array
out.putInt(4);
for(i = 0; i < 4; ++i)
out.putInt(myCurrentBlock[i]);
// The 32K of RAM
out.putInt(32 * 1024);
for(i = 0; i < 32 * 1024; ++i)
out.putInt(myRAM[i]);
}
catch(const 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)
{
uInt32 i;
string cart = name();
try
{
uInt32 limit;
if(in.getString() != cart)
return false;
// The currentBlock array
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myCurrentBlock[i] = (uInt8) in.getInt();
// The 32K of RAM
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt();
}
catch(const char* msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeMC::bank(uInt16 b)
{
@ -323,3 +244,74 @@ uInt8* CartridgeMC::getImage(int& size)
size = 128 * 1024; // FIXME: keep track of original size
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMC::save(Serializer& out) const
{
uInt32 i;
string cart = name();
try
{
out.putString(cart);
// The currentBlock array
out.putInt(4);
for(i = 0; i < 4; ++i)
out.putByte((char)myCurrentBlock[i]);
// The 32K of RAM
out.putInt(32 * 1024);
for(i = 0; i < 32 * 1024; ++i)
out.putByte((char)myRAM[i]);
}
catch(const 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)
{
uInt32 i;
string cart = name();
try
{
uInt32 limit;
if(in.getString() != cart)
return false;
// The currentBlock array
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myCurrentBlock[i] = (uInt8) in.getByte();
// The 32K of RAM
limit = (uInt32) in.getInt();
for(i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getByte();
}
catch(const char* msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
return true;
}

View File

@ -13,15 +13,13 @@
// 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.8 2007-01-14 16:17:55 stephena Exp $
// $Id: CartMC.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEMC_HXX
#define CARTRIDGEMC_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
@ -135,7 +133,7 @@ class Deserializer;
@author Bradford W. Mott
@version $Id: CartMC.hxx,v 1.8 2007-01-14 16:17:55 stephena Exp $
@version $Id: CartMC.hxx,v 1.9 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeMC : public Cartridge
{
@ -156,13 +154,6 @@ class CartridgeMC : public Cartridge
virtual ~CartridgeMC();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -176,22 +167,6 @@ 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);
/**
Install pages for the specified bank in the system.
@ -228,6 +203,29 @@ class CartridgeMC : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeMC"; }
public:
/**
Get the byte at the specified address

View File

@ -13,14 +13,12 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartUA.cxx,v 1.10 2007-01-14 16:17:55 stephena Exp $
// $Id: CartUA.cxx,v 1.11 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "CartUA.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -38,12 +36,6 @@ CartridgeUA::~CartridgeUA()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeUA::name() const
{
return "CartridgeUA";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeUA::reset()
{
@ -138,7 +130,59 @@ void CartridgeUA::poke(uInt16 address, uInt8 value)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeUA::save(Serializer& out)
void CartridgeUA::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;
uInt16 shift = mySystem->pageShift();
// uInt16 mask = mySystem->pageMask();
// Setup the page access methods for the current bank
System::PageAccess access;
access.device = this;
access.directPokeBase = 0;
// Map ROM image into the system
for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeUA::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeUA::bankCount()
{
return 2;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeUA::patch(uInt16 address, uInt8 value)
{
address &= 0x0fff;
myImage[myCurrentBank * 4096] = value;
bank(myCurrentBank); // TODO: see if this is really necessary
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeUA::getImage(int& size)
{
size = 8192;
return &myImage[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeUA::save(Serializer& out) const
{
string cart = name();
@ -190,55 +234,3 @@ bool CartridgeUA::load(Deserializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeUA::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;
uInt16 shift = mySystem->pageShift();
// uInt16 mask = mySystem->pageMask();
// Setup the page access methods for the current bank
System::PageAccess access;
access.device = this;
access.directPokeBase = 0;
// Map ROM image into the system
for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeUA::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeUA::bankCount()
{
return 2;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeUA::patch(uInt16 address, uInt8 value)
{
address &= 0x0fff;
myImage[myCurrentBank * 4096] = value;
bank(myCurrentBank); // TODO: see if this is really necessary
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeUA::getImage(int& size)
{
size = 8192;
return &myImage[0];
}

View File

@ -13,26 +13,24 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartUA.hxx,v 1.7 2007-01-14 16:17:55 stephena Exp $
// $Id: CartUA.hxx,v 1.8 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CARTRIDGEUA_HXX
#define CARTRIDGEUA_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
#include "System.hxx"
#include "Cart.hxx"
/**
Cartridge class used for UA Limited's 8K bankswitched games. There
are two 4K banks.
@author Bradford W. Mott
@version $Id: CartUA.hxx,v 1.7 2007-01-14 16:17:55 stephena Exp $
@version $Id: CartUA.hxx,v 1.8 2007-10-03 21:41:17 stephena Exp $
*/
class CartridgeUA : public Cartridge
{
@ -50,13 +48,6 @@ class CartridgeUA : public Cartridge
virtual ~CartridgeUA();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -70,22 +61,6 @@ class CartridgeUA : 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);
/**
Install pages for the specified bank in the system.
@ -122,6 +97,29 @@ class CartridgeUA : public Cartridge
*/
virtual uInt8* getImage(int& size);
/**
Save the current state of this cart to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "CartridgeUA"; }
public:
/**
Get the byte at the specified address.

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: Console.cxx,v 1.129 2007-09-10 15:46:58 stephena Exp $
// $Id: Console.cxx,v 1.130 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
@ -43,10 +43,12 @@
#include "Switches.hxx"
#include "System.hxx"
#include "TIA.hxx"
#include "TrackBall22.hxx"
#include "FrameBuffer.hxx"
#include "OSystem.hxx"
#include "Menu.hxx"
#include "CommandMenu.hxx"
#include "Serializable.hxx"
#include "Version.hxx"
#ifdef DEBUGGER_SUPPORT
@ -113,6 +115,10 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
{
myControllers[leftPort] = new Paddles(Controller::Left, *myEvent, swapPaddles);
}
else if(left == "TRACKBALL22")
{
myControllers[leftPort] = new TrackBall22(Controller::Left, *myEvent);
}
else
{
myControllers[leftPort] = new Joystick(Controller::Left, *myEvent);
@ -250,6 +256,60 @@ Console::~Console()
delete myControllers[1];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Console::save(Serializer& out) const
{
try
{
// First save state for the system
if(!mySystem->save(out))
return false;
// Now save the console switches
if(!mySwitches->save(out))
return false;
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for \'Console\'" << endl;
return false;
}
return true; // success
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Console::load(Deserializer& in)
{
try
{
// First load state for the system
if(!mySystem->load(in))
return false;
// Then load the console switches
if(!mySwitches->load(in))
return false;
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for \'Console\'" << endl;
return false;
}
return true; // success
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleFormat()
{

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: Console.hxx,v 1.62 2007-09-10 15:46:58 stephena Exp $
// $Id: Console.hxx,v 1.63 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CONSOLE_HXX
@ -33,14 +33,15 @@ class System;
#include "Cart.hxx"
#include "M6532.hxx"
#include "AtariVox.hxx"
#include "Serializable.hxx"
/**
This class represents the entire game console.
@author Bradford W. Mott
@version $Id: Console.hxx,v 1.62 2007-09-10 15:46:58 stephena Exp $
@version $Id: Console.hxx,v 1.63 2007-10-03 21:41:17 stephena Exp $
*/
class Console
class Console : public Serializable
{
public:
/**
@ -118,6 +119,29 @@ class Console
*/
M6532& riot() const { return *myRiot; }
/**
Saves the current state of this console class to the given Serializer.
@param out The serializer device to save to.
@return The result of the save. True on success, false on failure.
*/
bool save(Serializer& out) const;
/**
Loads the current state of this console class from the given Deserializer.
@param in The deserializer device to load from.
@return The result of the load. True on success, false on failure.
*/
bool load(Deserializer& in);
/**
Get a descriptor for this console class (used in error checking).
@return The name of the object
*/
string name() const { return "Console"; }
/**
Set the properties to those given
@ -141,7 +165,7 @@ class Console
public:
/**
Toggle between NTSC/PAL/PAL60 display format.
Toggle between NTSC/PAL/SECAM (and variants) display format.
*/
void toggleFormat();

View File

@ -13,10 +13,11 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Control.cxx,v 1.6 2007-01-05 17:54:09 stephena Exp $
// $Id: Control.cxx,v 1.7 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <assert.h>
#include <cassert>
#include "Control.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -25,6 +26,39 @@ Controller::Controller(Jack jack, const Event& event, Type type)
myEvent(event),
myType(type)
{
myDigitalPinState[One] =
myDigitalPinState[Two] =
myDigitalPinState[Three] =
myDigitalPinState[Four] =
myDigitalPinState[Six] = true;
myAnalogPinValue[Five] =
myAnalogPinValue[Nine] = maximumResistance;
switch(myType)
{
case Joystick:
myName = "Joystick";
break;
case Paddles:
myName = "Paddles";
break;
case BoosterGrip:
myName = "BoosterGrip";
break;
case Driving:
myName = "Driving";
break;
case Keyboard:
myName = "Keyboard";
break;
case TrackBall22:
myName = "TrackBall22";
break;
case AtariVox:
myName = "AtariVox";
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -33,11 +67,96 @@ Controller::~Controller()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Controller::Type Controller::type()
const Controller::Type Controller::type() const
{
return myType;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Controller::read(DigitalPin pin) const
{
switch(pin)
{
case One:
case Two:
case Three:
case Four:
case Six:
return myDigitalPinState[pin];
default:
return true;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 Controller::read(AnalogPin pin) const
{
switch(pin)
{
case Five:
case Nine:
return myAnalogPinValue[pin];
default:
return maximumResistance;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Controller::save(Serializer& out) const
{
try
{
// Output the digital pins
out.putBool(myDigitalPinState[One]);
out.putBool(myDigitalPinState[Two]);
out.putBool(myDigitalPinState[Three]);
out.putBool(myDigitalPinState[Four]);
out.putBool(myDigitalPinState[Six]);
// Output the analog pins
out.putInt(myAnalogPinValue[Five]);
out.putInt(myAnalogPinValue[Nine]);
}
catch(...)
{
cerr << "Error: Controller::save() exception\n";
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Controller::load(Deserializer& in)
{
try
{
// Input the digital pins
myDigitalPinState[One] = in.getBool();
myDigitalPinState[Two] = in.getBool();
myDigitalPinState[Three] = in.getBool();
myDigitalPinState[Four] = in.getBool();
myDigitalPinState[Six] = in.getBool();
// Input the analog pins
myAnalogPinValue[Five] = (Int32) in.getInt();
myAnalogPinValue[Nine] = (Int32) in.getInt();
}
catch(...)
{
cerr << "Error: Controller::load() exception\n";
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Controller::name() const
{
return myName;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Int32 Controller::maximumResistance = 0x7FFFFFFF;

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: Control.hxx,v 1.9 2007-02-22 02:15:46 stephena Exp $
// $Id: Control.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef CONTROLLER_HXX
@ -23,6 +23,7 @@ class Controller;
class Event;
class System;
#include "Serializable.hxx"
#include "bspf.hxx"
/**
@ -56,9 +57,9 @@ class System;
of the controller from the perspective of the controller's jack.
@author Bradford W. Mott
@version $Id: Control.hxx,v 1.9 2007-02-22 02:15:46 stephena Exp $
@version $Id: Control.hxx,v 1.10 2007-10-03 21:41:17 stephena Exp $
*/
class Controller
class Controller : public Serializable
{
public:
/**
@ -75,7 +76,7 @@ class Controller
enum Type
{
BoosterGrip, Driving, Keyboard, Paddles, Joystick,
TrakBall, AtariVox
TrackBall22, AtariVox
};
public:
@ -96,7 +97,7 @@ class Controller
/**
Returns the type of this controller.
*/
const Type type();
const Type type() const;
/**
Inform this controller about the current System.
@ -127,7 +128,7 @@ class Controller
@param pin The pin of the controller jack to read
@return The state of the pin
*/
virtual bool read(DigitalPin pin) = 0;
bool read(DigitalPin pin) const;
/**
Read the resistance at the specified analog pin for this controller.
@ -136,7 +137,7 @@ class Controller
@param pin The pin of the controller jack to read
@return The resistance at the specified pin
*/
virtual Int32 read(AnalogPin pin) = 0;
Int32 read(AnalogPin pin) const;
/**
Write the given value to the specified digital pin for this
@ -146,7 +147,34 @@ class Controller
@param pin The pin of the controller jack to write to
@param value The value to write to the pin
*/
virtual void write(DigitalPin pin, bool value) = 0;
virtual void write(DigitalPin pin, bool value) { };
/**
Update the entire digital and analog pin state according to the
events currently set.
*/
virtual void update() = 0;
/**
Saves the current state of this controller 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) const;
/**
Loads the current state of this controller 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);
/**
Returns the name of this controller.
*/
virtual string name() const;
public:
/// Constant which represents maximum resistance for analog pins
@ -165,9 +193,18 @@ class Controller
/// Specifies which type of controller this is (defined by child classes)
const Type myType;
/// Specifies the name of this controller based on type
string myName;
/// Pointer to the System object (used for timing purposes)
System* mySystem;
/// The boolean value on each digital pin
bool myDigitalPinState[5];
/// The analog value on each analog pin
Int32 myAnalogPinValue[2];
protected:
// Copy constructor isn't supported by controllers so make it private
Controller(const Controller&);

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: Deserializer.cxx,v 1.12 2007-01-01 18:04:47 stephena Exp $
// $Id: Deserializer.cxx,v 1.13 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include "Deserializer.hxx"
@ -51,6 +51,18 @@ bool Deserializer::isOpen(void)
return myStream.is_open();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
char Deserializer::getByte(void)
{
if(myStream.eof())
throw "Deserializer: end of file";
char buf[1];
myStream.read(buf, 1);
return buf[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Deserializer::getInt(void)
{
@ -85,10 +97,10 @@ bool Deserializer::getBool(void)
{
bool result = false;
int b = getInt();
if(b == (int)TruePattern)
char b = getByte();
if(b == (char)TruePattern)
result = true;
else if(b == (int)FalsePattern)
else if(b == (char)FalsePattern)
result = false;
else
throw "Deserializer: data corruption";

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: Deserializer.hxx,v 1.11 2007-01-01 18:04:47 stephena Exp $
// $Id: Deserializer.hxx,v 1.12 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef DESERIALIZER_HXX
@ -27,11 +27,11 @@
deserialized from an input binary file in a system-independent
way.
All ints should be cast to their appropriate data type upon method
return.
All bytes and ints should be cast to their appropriate data type upon
method return.
@author Stephen Anthony
@version $Id: Deserializer.hxx,v 1.11 2007-01-01 18:04:47 stephena Exp $
@version $Id: Deserializer.hxx,v 1.12 2007-10-03 21:41:17 stephena Exp $
*/
class Deserializer
{
@ -70,7 +70,14 @@ class Deserializer
bool isOpen(void);
/**
Reads an int value from the current input stream.
Reads a byte value (8-bit) from the current input stream.
@result The char value which has been read from the stream.
*/
char getByte(void);
/**
Reads an int value (32-bit) from the current input stream.
@result The int value which has been read from the stream.
*/
@ -95,8 +102,8 @@ class Deserializer
fstream myStream;
enum {
TruePattern = 0xfab1fab2,
FalsePattern = 0xbad1bad2
TruePattern = 0xfe,
FalsePattern = 0x01
};
};

View File

@ -13,20 +13,39 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Driving.cxx,v 1.11 2007-02-22 02:15:46 stephena Exp $
// $Id: Driving.cxx,v 1.12 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <cassert>
#include "Event.hxx"
#include "Driving.hxx"
#include "System.hxx"
#include "Driving.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Driving::Driving(Jack jack, const Event& event)
: Controller(jack, event, Controller::Driving),
myCounter(0)
{
if(myJack == Left)
{
myCCWEvent = Event::JoystickZeroLeft;
myCWEvent = Event::JoystickZeroRight;
myFireEvent = Event::JoystickZeroFire;
myValueEvent = Event::DrivingZeroValue;
}
else
{
myCCWEvent = Event::JoystickOneLeft;
myCWEvent = Event::JoystickOneRight;
myFireEvent = Event::JoystickOneFire;
myValueEvent = Event::DrivingOneValue;
}
// Digital pins 3 and 4 are not connected
myDigitalPinState[Three] = myDigitalPinState[Four] = true;
// Analog pins are not connected
myAnalogPinValue[Five] = myAnalogPinValue[Nine] = maximumResistance;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -35,6 +54,32 @@ Driving::~Driving()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Driving::update()
{
// TODO - this isn't working with Stelladaptor and real driving controllers
// Gray codes for rotation
static const uInt8 graytable[] = { 0x03, 0x01, 0x00, 0x02 };
// Determine which gray code we're at
if(myEvent.get(myCCWEvent) != 0)
myCounter--;
else if(myEvent.get(myCWEvent) != 0)
myCounter++;
// Only consider the lower-most bits (corresponding to pins 1 & 2)
myCounter &= 0x0f;
uInt8 gray = graytable[myCounter >> 2];
// Determine which bits are set
myDigitalPinState[One] = (gray & 0x1) != 0;
myDigitalPinState[Two] = (gray & 0x2) != 0;
myDigitalPinState[Six] = (myEvent.get(myFireEvent) == 0);
}
/*
bool Driving::read(DigitalPin pin)
{
// Gray codes for clockwise rotation
@ -105,32 +150,6 @@ bool Driving::read(DigitalPin pin)
else
return(myEvent.get(Event::DrivingOneValue) & 0x02);
}
case Three:
return true;
case Four:
return true;
case Six:
return (myJack == Left) ? (myEvent.get(Event::DrivingZeroFire) == 0) :
(myEvent.get(Event::DrivingOneFire) == 0);
default:
return true;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 Driving::read(AnalogPin)
{
// Analog pins are not connect in driving controller so we have
// infinite resistance
return maximumResistance;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Driving::write(DigitalPin, bool)
{
// Writing doesn't do anything to the driving controller...
}
*/

View File

@ -13,23 +13,21 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Driving.hxx,v 1.6 2007-01-01 18:04:47 stephena Exp $
// $Id: Driving.hxx,v 1.7 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef DRIVING_HXX
#define DRIVING_HXX
class Driving;
class System;
#include "bspf.hxx"
#include "Control.hxx"
#include "Event.hxx"
/**
The standard Atari 2600 Indy 500 driving controller.
@author Bradford W. Mott
@version $Id: Driving.hxx,v 1.6 2007-01-01 18:04:47 stephena Exp $
@version $Id: Driving.hxx,v 1.7 2007-10-03 21:41:17 stephena Exp $
*/
class Driving : public Controller
{
@ -50,35 +48,18 @@ class Driving : public Controller
public:
/**
Read the value of the specified digital pin for this controller.
@param pin The pin of the controller jack to read
@return The state of the pin
Update the entire digital and analog pin state according to the
events currently set.
*/
virtual bool read(DigitalPin pin);
/**
Read the resistance at the specified analog pin for this controller.
The returned value is the resistance measured in ohms.
@param pin The pin of the controller jack to read
@return The resistance at the specified pin
*/
virtual Int32 read(AnalogPin pin);
/**
Write the given value to the specified digital pin for this
controller. Writing is only allowed to the pins associated
with the PIA. Therefore you cannot write to pin six.
@param pin The pin of the controller jack to write to
@param value The value to write to the pin
*/
virtual void write(DigitalPin pin, bool value);
virtual void update();
private:
// Counter to iterate through the gray codes
uInt32 myCounter;
};
#endif
// Pre-compute the events we care about based on given port
// This will eliminate test for left or right port in update()
Event::Type myCWEvent, myCCWEvent, myValueEvent, myFireEvent;
};
#endif

View File

@ -13,9 +13,13 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Event.cxx,v 1.12 2007-09-23 17:04:17 stephena Exp $
// $Id: Event.cxx,v 1.13 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include "OSystem.hxx"
#include "Console.hxx"
#include "Control.hxx"
#include "Event.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: Event.hxx,v 1.29 2007-09-23 17:04:17 stephena Exp $
// $Id: Event.hxx,v 1.30 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#ifndef EVENT_HXX
@ -25,7 +25,7 @@ class Event;
/**
@author Bradford W. Mott
@version $Id: Event.hxx,v 1.29 2007-09-23 17:04:17 stephena Exp $
@version $Id: Event.hxx,v 1.30 2007-10-03 21:41:17 stephena Exp $
*/
class Event
{
@ -51,6 +51,9 @@ class Event
BoosterGripZeroTrigger, BoosterGripZeroBooster,
BoosterGripOneTrigger, BoosterGripOneBooster,
DrivingZeroValue,
DrivingOneValue,
PaddleZeroResistance, PaddleZeroFire,
PaddleZeroDecrease, PaddleZeroIncrease, PaddleZeroAnalog,
PaddleOneResistance, PaddleOneFire,
@ -70,11 +73,6 @@ class Event
KeyboardOne7, KeyboardOne8, KeyboardOne9,
KeyboardOneStar, KeyboardOne0, KeyboardOnePound,
DrivingZeroClockwise, DrivingZeroCounterClockwise, DrivingZeroValue,
DrivingZeroFire,
DrivingOneClockwise, DrivingOneCounterClockwise, DrivingOneValue,
DrivingOneFire,
ChangeState, LoadState, SaveState, TakeSnapshot, Quit,
PauseMode, MenuMode, CmdMenuMode, DebuggerMode, LauncherMode,
Fry, VolumeDecrease, VolumeIncrease,

View File

@ -14,7 +14,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EventHandler.cxx,v 1.211 2007-09-25 13:04:24 stephena Exp $
// $Id: EventHandler.cxx,v 1.212 2007-10-03 21:41:17 stephena Exp $
//============================================================================
#include <sstream>
@ -37,6 +37,7 @@
#include "Snapshot.hxx"
#include "Sound.hxx"
#include "StateManager.hxx"
#include "Switches.hxx"
#include "EventHandler.hxx"
@ -347,13 +348,6 @@ void EventHandler::mapStelladaptors(const string& sa1, const string& sa2)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::poll(uInt32 time)
{
// FIXME - change this to use StateManager stuff
// Check if we have an event from the eventstreamer
// TODO - should we lock out input from the user while getting synthetic events?
// int type, value;
// while(myEventStreamer->pollEvent(type, value))
// myEvent->set((Event::Type)type, value);
// Synthesize events for platform-specific hardware
myOSystem->pollEvent();
@ -455,26 +449,22 @@ void EventHandler::poll(uInt32 time)
myOSystem->console().togglePhosphor();
break;
#if 0
#if 1
// FIXME - these will be removed when a UI is added for event recording
case SDLK_e: // Alt-e starts/stops event recording
if(myEventStreamer->isRecording())
{
if(myEventStreamer->stopRecording())
myOSystem->frameBuffer().showMessage("Recording stopped");
else
myOSystem->frameBuffer().showMessage("Stop recording error");
}
if(myOSystem->state().toggleRecordMode())
myOSystem->frameBuffer().showMessage("Recording started");
else
{
if(myEventStreamer->startRecording())
myOSystem->frameBuffer().showMessage("Recording started");
else
myOSystem->frameBuffer().showMessage("Start recording error");
}
return;
myOSystem->frameBuffer().showMessage("Recording stopped");
break;
case SDLK_r: // Alt-r starts/stops rewind mode
if(myOSystem->state().toggleRewindMode())
myOSystem->frameBuffer().showMessage("Rewind mode started");
else
myOSystem->frameBuffer().showMessage("Rewind mode stopped");
break;
/*
case SDLK_l: // Alt-l loads a recording
if(myEventStreamer->loadRecording())
myOSystem->frameBuffer().showMessage("Playing recording");
@ -482,6 +472,7 @@ void EventHandler::poll(uInt32 time)
myOSystem->frameBuffer().showMessage("Playing recording error");
return;
break;
*/
////////////////////////////////////////////////////////////////////////
#endif
}
@ -675,10 +666,14 @@ void EventHandler::poll(uInt32 time)
// Since we can't detect what controller is attached to a
// Stelladaptor, we only send events based on controller
// type in ROM properties
// The 'type-2' here refers to the fact that 'JT_STELLADAPTOR_LEFT'
// and 'JT_STELLADAPTOR_RIGHT' are at index 2 and 3 in the JoyType
// enum; subtracting two gives us Controller 0 and 1
switch((int)myController[type-2])
{
// Send button events for the joysticks
// Send button events for the joysticks and driving controllers
case Controller::Joystick:
case Controller::Driving:
myEvent->set(SA_Button[type-2][button][0], state);
break;
@ -686,11 +681,6 @@ void EventHandler::poll(uInt32 time)
case Controller::Paddles:
myEvent->set(SA_Button[type-2][button][1], state);
break;
// Send events for the driving controllers
case Controller::Driving:
myEvent->set(SA_Button[type-2][button][2], state);
break;
}
break; // Stelladaptor button
}
@ -729,10 +719,15 @@ void EventHandler::poll(uInt32 time)
// Since we can't detect what controller is attached to a
// Stelladaptor, we only send events based on controller
// type in ROM properties
// The 'type-2' here refers to the fact that 'JT_STELLADAPTOR_LEFT'
// and 'JT_STELLADAPTOR_RIGHT' are at index 2 and 3 in the JoyType
// enum; subtracting two gives us Controller 0 and 1
switch((int)myController[type-2])
{
// Send axis events for the joysticks
case Controller::Joystick:
// Disallow 4-direction movement by turning off the
// other extreme of the axis
myEvent->set(SA_Axis[type-2][axis][0], (value < -16384) ? 1 : 0);
myEvent->set(SA_Axis[type-2][axis][1], (value > 16384) ? 1 : 0);
break;
@ -817,27 +812,42 @@ void EventHandler::poll(uInt32 time)
}
else
{
int resistance = (int)(1000000.0 * (1000000.0 - myPaddle[i].x) / 1000000.0);
int resistance = (int)(1000000.0 * (1000000 - myPaddle[i].x) / 1000000);
myEvent->set(Paddle_Resistance[i], resistance);
}
}
}
// Update the current dialog container at regular intervals
// Used to implement continuous events
if(myState != S_EMULATE && myOverlay)
// Update controllers and console switches, and in general all other things
// related to emulation
if(myState == S_EMULATE)
{
myOSystem->console().controller(Controller::Left).update();
myOSystem->console().controller(Controller::Right).update();
myOSystem->console().switches().update();
// Now check if the StateManager should be saving or loading state
// Per-frame cheats are disabled if the StateManager is active, since
// it would interfere with proper playback
if(myOSystem->state().isActive())
{
myOSystem->state().update();
}
else
{
#ifdef CHEATCODE_SUPPORT
const CheatList& cheats = myOSystem->cheat().perFrame();
for(unsigned int i = 0; i < cheats.size(); i++)
cheats[i]->evaluate();
#endif
}
}
else if(myOverlay)
{
// Update the current dialog container at regular intervals
// Used to implement continuous events
myOverlay->updateTime(time);
#ifdef CHEATCODE_SUPPORT
const CheatList& cheats = myOSystem->cheat().perFrame();
for(unsigned int i = 0; i < cheats.size(); i++)
cheats[i]->evaluate();
#endif
// Tell the eventstreamer that another frame has finished
// This is used for event recording
// myEventStreamer->nextFrame();
// FIXME - change this to use StateManager stuff
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -845,18 +855,12 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event)
{
// Take window zooming into account
int x = event.motion.x, y = event.motion.y;
myOSystem->frameBuffer().translateCoords(x, y);
// Determine which mode we're in, then send the event to the appropriate place
if(myState == S_EMULATE)
{
int w = myOSystem->frameBuffer().baseWidth();
if(x < 0 || x > w) return;
// Grabmouse introduces some lag into the mouse movement,
// so we need to fudge the numbers a bit
if(myGrabMouseFlag) x = BSPF_min(w, (int) (x * 1.5));
int resistance = (int)(1000000.0 * (w - x) / w);
myEvent->set(Paddle_Resistance[myPaddleMode], resistance);
@ -864,7 +868,10 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event)
myPaddle[myPaddleMode].x = 1000000 - resistance;
}
else if(myOverlay)
{
myOSystem->frameBuffer().translateCoords(x, y);
myOverlay->handleMouseMotionEvent(x, y, 0);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -877,9 +884,7 @@ void EventHandler::handleMouseButtonEvent(SDL_Event& event, int state)
{
// Take window zooming into account
Int32 x = event.button.x, y = event.button.y;
//if (state) cerr << "B: x = " << x << ", y = " << y << endl;
myOSystem->frameBuffer().translateCoords(x, y);
//if (state) cerr << "A: x = " << x << ", y = " << y << endl << endl;
MouseButton button;
switch(event.button.button)
@ -1027,9 +1032,11 @@ void EventHandler::handleEvent(Event::Type event, int state)
case Controller::Paddles:
handleEvent(Event::PaddleZeroDecrease, state);
return;
/*
case Controller::Driving:
myEvent->set(Event::DrivingZeroCounterClockwise, state);
return;
*/
}
break;
case Event::JoystickZeroRight:
@ -1044,9 +1051,11 @@ void EventHandler::handleEvent(Event::Type event, int state)
case Controller::Paddles:
handleEvent(Event::PaddleZeroIncrease, state);
return;
/*
case Controller::Driving:
myEvent->set(Event::DrivingZeroClockwise, state);
return;
*/
}
break;
case Event::JoystickZeroFire:
@ -1058,9 +1067,11 @@ void EventHandler::handleEvent(Event::Type event, int state)
case Controller::Paddles:
myEvent->set(Event::PaddleZeroFire, state);
return;
/*
case Controller::Driving:
myEvent->set(Event::DrivingZeroFire, state);
return;
*/
}
break;
case Event::JoystickOneUp:
@ -1083,9 +1094,11 @@ void EventHandler::handleEvent(Event::Type event, int state)
case Controller::Paddles:
handleEvent(Event::PaddleOneDecrease, state);
return;
/*
case Controller::Driving:
myEvent->set(Event::DrivingOneCounterClockwise, state);
return;
*/
}
break;
case Event::JoystickOneRight:
@ -1100,9 +1113,11 @@ void EventHandler::handleEvent(Event::Type event, int state)
case Controller::Paddles:
handleEvent(Event::PaddleZeroIncrease, state);
return;
/*
case Controller::Driving:
myEvent->set(Event::DrivingOneClockwise, state);
return;
*/
}
break;
case Event::JoystickOneFire:
@ -1114,9 +1129,11 @@ void EventHandler::handleEvent(Event::Type event, int state)
case Controller::Paddles:
myEvent->set(Event::PaddleOneFire, state);
return;
/*
case Controller::Driving:
myEvent->set(Event::DrivingOneFire, state);
return;
*/
}
break;
////////////////////////////////////////////////////////////////////////
@ -1162,9 +1179,11 @@ void EventHandler::handleEvent(Event::Type event, int state)
return;
case Event::VolumeDecrease:
if(state) myOSystem->sound().adjustVolume(-1);
return;
case Event::VolumeIncrease:
if(state)
myOSystem->sound().adjustVolume(event == Event::VolumeIncrease ? 1 : -1);
if(state) myOSystem->sound().adjustVolume(+1);
return;
case Event::SaveState:
@ -1718,14 +1737,6 @@ void EventHandler::setDefaultKeymap(EventMode mode)
myKeyTable[ SDLK_6 ][mode] = Event::BoosterGripOneTrigger;
myKeyTable[ SDLK_7 ][mode] = Event::BoosterGripOneBooster;
myKeyTable[ SDLK_INSERT ][mode] = Event::DrivingZeroCounterClockwise;
myKeyTable[ SDLK_PAGEUP ][mode] = Event::DrivingZeroClockwise;
myKeyTable[ SDLK_HOME ][mode] = Event::DrivingZeroFire;
myKeyTable[ SDLK_DELETE ][mode] = Event::DrivingOneCounterClockwise;
myKeyTable[ SDLK_PAGEDOWN ][mode] = Event::DrivingOneClockwise;
myKeyTable[ SDLK_END ][mode] = Event::DrivingOneFire;
myKeyTable[ SDLK_F1 ][mode] = Event::ConsoleSelect;
myKeyTable[ SDLK_F2 ][mode] = Event::ConsoleReset;
myKeyTable[ SDLK_F3 ][mode] = Event::ConsoleColor;
@ -2505,13 +2516,13 @@ EventHandler::ActionList EventHandler::ourEmulActionList[kEmulActionListSize] =
{ Event::BoosterGripOneTrigger, "P1 Booster-Grip Trigger", 0 },
{ Event::BoosterGripOneBooster, "P1 Booster-Grip Booster", 0 },
{ Event::DrivingZeroCounterClockwise, "P0 Driving Controller Left", 0 },
{ Event::DrivingZeroClockwise, "P0 Driving Controller Right", 0 },
{ Event::DrivingZeroFire, "P0 Driving Controller Fire", 0 },
// { Event::DrivingZeroCounterClockwise, "P0 Driving Controller Left", 0 },
// { Event::DrivingZeroClockwise, "P0 Driving Controller Right", 0 },
// { Event::DrivingZeroFire, "P0 Driving Controller Fire", 0 },
{ Event::DrivingOneCounterClockwise, "P1 Driving Controller Left", 0 },
{ Event::DrivingOneClockwise, "P1 Driving Controller Right", 0 },
{ Event::DrivingOneFire, "P1 Driving Controller Fire", 0 },
// { Event::DrivingOneCounterClockwise, "P1 Driving Controller Left", 0 },
// { Event::DrivingOneClockwise, "P1 Driving Controller Right", 0 },
// { Event::DrivingOneFire, "P1 Driving Controller Fire", 0 },
{ Event::KeyboardZero1, "P0 Keyboard 1", 0 },
{ Event::KeyboardZero2, "P0 Keyboard 2", 0 },
@ -2573,22 +2584,27 @@ const Event::Type EventHandler::Paddle_Button[4] = {
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Used by the Stelladaptor to disallow impossible directions (both up & down
// or left & right), or for resistance for paddles
const Event::Type EventHandler::SA_Axis[2][2][3] = {
{ {Event::JoystickZeroLeft, Event::JoystickZeroRight, Event::PaddleZeroResistance},
{Event::JoystickZeroUp, Event::JoystickZeroDown, Event::PaddleOneResistance} },
{ {Event::JoystickOneLeft, Event::JoystickOneRight, Event::PaddleTwoResistance},
{ {Event::JoystickZeroLeft, Event::JoystickZeroRight, Event::PaddleZeroResistance },
{Event::JoystickZeroUp, Event::JoystickZeroDown, Event::PaddleOneResistance } },
{ {Event::JoystickOneLeft, Event::JoystickOneRight, Event::PaddleTwoResistance },
{Event::JoystickOneUp, Event::JoystickOneDown, Event::PaddleThreeResistance} }
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Event::Type EventHandler::SA_Button[2][2][3] = {
{ {Event::JoystickZeroFire, Event::PaddleZeroFire, Event::DrivingZeroFire },
{Event::NoType, Event::PaddleOneFire, Event::NoType} },
{ {Event::JoystickOneFire, Event::PaddleTwoFire, Event::DrivingOneFire },
{Event::NoType, Event::PaddleThreeFire, Event::NoType} }
// Used by the Stelladaptor to map button presses to joystick or paddles
// (driving controllers are considered the same as joysticks)
const Event::Type EventHandler::SA_Button[2][2][2] = {
{ {Event::JoystickZeroFire, Event::PaddleZeroFire },
{Event::NoType, Event::PaddleOneFire } },
{ {Event::JoystickOneFire, Event::PaddleTwoFire },
{Event::NoType, Event::PaddleThreeFire } }
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Used by the Stelladaptor to send simulated 'gray codes'
const Event::Type EventHandler::SA_DrivingValue[2] = {
Event::DrivingZeroValue, Event::DrivingOneValue
};

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: EventHandler.hxx,v 1.104 2007-09-23 17:04:17 stephena Exp $
// $Id: EventHandler.hxx,v 1.105 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -25,7 +25,6 @@ class Console;
class OSystem;
class DialogContainer;
class EventMappingWidget;
class EventStreamer;
#include "Array.hxx"
#include "Event.hxx"
@ -62,7 +61,7 @@ enum EventMode {
mapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.104 2007-09-23 17:04:17 stephena Exp $
@version $Id: EventHandler.hxx,v 1.105 2007-10-03 21:41:18 stephena Exp $
*/
class EventHandler
{
@ -448,7 +447,7 @@ class EventHandler
private:
enum {
kEmulActionListSize = 81,
kEmulActionListSize = 75,
kMenuActionListSize = 13
};
@ -495,9 +494,6 @@ class EventHandler
// Global Event object
Event* myEvent;
// The EventStreamer to use for loading/saving eventstreams
EventStreamer* myEventStreamer;
// Indicates current overlay object
DialogContainer* myOverlay;
@ -561,7 +557,7 @@ class EventHandler
// Static lookup tables for Stelladaptor axis/button support
static const Event::Type SA_Axis[2][2][3];
static const Event::Type SA_Button[2][2][3];
static const Event::Type SA_Button[2][2][2];
static const Event::Type SA_DrivingValue[2];
};

View File

@ -13,10 +13,9 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Joystick.cxx,v 1.7 2007-01-05 17:54:23 stephena Exp $
// $Id: Joystick.cxx,v 1.8 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#include <assert.h>
#include "Event.hxx"
#include "Joystick.hxx"
@ -24,6 +23,25 @@
Joystick::Joystick(Jack jack, const Event& event)
: Controller(jack, event, Controller::Joystick)
{
if(myJack == Left)
{
myUpEvent = Event::JoystickZeroUp;
myDownEvent = Event::JoystickZeroDown;
myLeftEvent = Event::JoystickZeroLeft;
myRightEvent = Event::JoystickZeroRight;
myFireEvent = Event::JoystickZeroFire;
}
else
{
myUpEvent = Event::JoystickOneUp;
myDownEvent = Event::JoystickOneDown;
myLeftEvent = Event::JoystickOneLeft;
myRightEvent = Event::JoystickOneRight;
myFireEvent = Event::JoystickOneFire;
}
// Analog pins are never used by the joystick
myAnalogPinValue[Five] = myAnalogPinValue[Nine] = maximumResistance;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -32,44 +50,11 @@ Joystick::~Joystick()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Joystick::read(DigitalPin pin)
void Joystick::update()
{
switch(pin)
{
case One:
return (myJack == Left) ? (myEvent.get(Event::JoystickZeroUp) == 0) :
(myEvent.get(Event::JoystickOneUp) == 0);
case Two:
return (myJack == Left) ? (myEvent.get(Event::JoystickZeroDown) == 0) :
(myEvent.get(Event::JoystickOneDown) == 0);
case Three:
return (myJack == Left) ? (myEvent.get(Event::JoystickZeroLeft) == 0) :
(myEvent.get(Event::JoystickOneLeft) == 0);
case Four:
return (myJack == Left) ? (myEvent.get(Event::JoystickZeroRight) == 0) :
(myEvent.get(Event::JoystickOneRight) == 0);
case Six:
return (myJack == Left) ? (myEvent.get(Event::JoystickZeroFire) == 0) :
(myEvent.get(Event::JoystickOneFire) == 0);
default:
return true;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 Joystick::read(AnalogPin)
{
// Analog pins are not connect in joystick so we have infinite resistance
return maximumResistance;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Joystick::write(DigitalPin, bool)
{
// Writing doesn't do anything to the joystick...
myDigitalPinState[One] = (myEvent.get(myUpEvent) == 0);
myDigitalPinState[Two] = (myEvent.get(myDownEvent) == 0);
myDigitalPinState[Three] = (myEvent.get(myLeftEvent) == 0);
myDigitalPinState[Four] = (myEvent.get(myRightEvent) == 0);
myDigitalPinState[Six] = (myEvent.get(myFireEvent) == 0);
}

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: Joystick.hxx,v 1.6 2007-01-01 18:04:48 stephena Exp $
// $Id: Joystick.hxx,v 1.7 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef JOYSTICK_HXX
@ -21,12 +21,13 @@
#include "bspf.hxx"
#include "Control.hxx"
#include "Event.hxx"
/**
The standard Atari 2600 joystick controller.
@author Bradford W. Mott
@version $Id: Joystick.hxx,v 1.6 2007-01-01 18:04:48 stephena Exp $
@version $Id: Joystick.hxx,v 1.7 2007-10-03 21:41:18 stephena Exp $
*/
class Joystick : public Controller
{
@ -46,31 +47,15 @@ class Joystick : public Controller
public:
/**
Read the value of the specified digital pin for this controller.
@param pin The pin of the controller jack to read
@return The state of the pin
Update the entire digital and analog pin state according to the
events currently set.
*/
virtual bool read(DigitalPin pin);
virtual void update();
/**
Read the resistance at the specified analog pin for this controller.
The returned value is the resistance measured in ohms.
@param pin The pin of the controller jack to read
@return The resistance at the specified pin
*/
virtual Int32 read(AnalogPin pin);
/**
Write the given value to the specified digital pin for this
controller. Writing is only allowed to the pins associated
with the PIA. Therefore you cannot write to pin six.
@param pin The pin of the controller jack to write to
@param value The value to write to the pin
*/
virtual void write(DigitalPin pin, bool value);
private:
// Pre-compute the events we care about based on given port
// This will eliminate test for left or right port in update()
Event::Type myUpEvent, myDownEvent, myLeftEvent, myRightEvent, myFireEvent;
};
#endif

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: Keyboard.cxx,v 1.8 2007-01-13 20:39:48 bwmott Exp $
// $Id: Keyboard.cxx,v 1.9 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#include "Event.hxx"
@ -24,6 +24,36 @@ Keyboard::Keyboard(Jack jack, const Event& event)
: Controller(jack, event, Controller::Keyboard),
myPinState(0)
{
if(myJack == Left)
{
myOneEvent = Event::KeyboardZero1;
myTwoEvent = Event::KeyboardZero2;
myThreeEvent = Event::KeyboardZero3;
myFourEvent = Event::KeyboardZero4;
myFiveEvent = Event::KeyboardZero5;
mySixEvent = Event::KeyboardZero6;
mySevenEvent = Event::KeyboardZero7;
myEightEvent = Event::KeyboardZero8;
myNineEvent = Event::KeyboardZero9;
myStarEvent = Event::KeyboardZeroStar;
myZeroEvent = Event::KeyboardZero0;
myPoundEvent = Event::KeyboardZeroPound;
}
else
{
myOneEvent = Event::KeyboardOne1;
myTwoEvent = Event::KeyboardOne2;
myThreeEvent = Event::KeyboardOne3;
myFourEvent = Event::KeyboardOne4;
myFiveEvent = Event::KeyboardOne5;
mySixEvent = Event::KeyboardOne6;
mySevenEvent = Event::KeyboardOne7;
myEightEvent = Event::KeyboardOne8;
myNineEvent = Event::KeyboardOne9;
myStarEvent = Event::KeyboardOneStar;
myZeroEvent = Event::KeyboardOne0;
myPoundEvent = Event::KeyboardOnePound;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -31,157 +61,6 @@ Keyboard::~Keyboard()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Keyboard::read(DigitalPin pin)
{
switch(pin)
{
case One:
return (myPinState & 0x01);
case Two:
return (myPinState & 0x02);
case Three:
return (myPinState & 0x04);
case Four:
return (myPinState & 0x08);
case Six:
if((myPinState & 0x01) == 0)
{
return (myJack == Left) ? (myEvent.get(Event::KeyboardZero3) == 0) :
(myEvent.get(Event::KeyboardOne3) == 0);
}
else if((myPinState & 0x02) == 0)
{
return (myJack == Left) ? (myEvent.get(Event::KeyboardZero6) == 0) :
(myEvent.get(Event::KeyboardOne6) == 0);
}
else if((myPinState & 0x04) == 0)
{
return (myJack == Left) ? (myEvent.get(Event::KeyboardZero9) == 0) :
(myEvent.get(Event::KeyboardOne9) == 0);
}
else if((myPinState & 0x08) == 0)
{
return (myJack == Left) ? (myEvent.get(Event::KeyboardZeroPound) == 0) :
(myEvent.get(Event::KeyboardOnePound) == 0);
}
break;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 Keyboard::read(AnalogPin pin)
{
// NOTE: maximumResistance = GND, while minimumResistance = +5V
if(pin == Nine)
{
if(myJack == Left)
{
if(!(myPinState & 0x01) && (myEvent.get(Event::KeyboardZero1) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x02) && (myEvent.get(Event::KeyboardZero4) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x04) && (myEvent.get(Event::KeyboardZero7) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x08) && (myEvent.get(Event::KeyboardZeroStar) != 0))
{
return maximumResistance;
}
else
{
return minimumResistance;
}
}
else
{
if(!(myPinState & 0x01) && (myEvent.get(Event::KeyboardOne1) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x02) && (myEvent.get(Event::KeyboardOne4) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x04) && (myEvent.get(Event::KeyboardOne7) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x08) && (myEvent.get(Event::KeyboardOneStar) != 0))
{
return maximumResistance;
}
else
{
return minimumResistance;
}
}
}
else
{
if(myJack == Left)
{
if(!(myPinState & 0x01) && (myEvent.get(Event::KeyboardZero2) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x02) && (myEvent.get(Event::KeyboardZero5) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x04) && (myEvent.get(Event::KeyboardZero8) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x08) && (myEvent.get(Event::KeyboardZero0) != 0))
{
return maximumResistance;
}
else
{
return minimumResistance;
}
}
else
{
if(!(myPinState & 0x01) && (myEvent.get(Event::KeyboardOne2) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x02) && (myEvent.get(Event::KeyboardOne5) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x04) && (myEvent.get(Event::KeyboardOne8) != 0))
{
return maximumResistance;
}
else if(!(myPinState & 0x08) && (myEvent.get(Event::KeyboardOne0) != 0))
{
return maximumResistance;
}
else
{
return minimumResistance;
}
}
}
return minimumResistance;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Keyboard::write(DigitalPin pin, bool value)
{
@ -207,4 +86,47 @@ void Keyboard::write(DigitalPin pin, bool value)
default:
break;
}
// State has probably changed, so recalculate it
update();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Keyboard::update()
{
myDigitalPinState[One] = (myPinState & 0x01);
myDigitalPinState[Two] = (myPinState & 0x02);
myDigitalPinState[Three] = (myPinState & 0x04);
myDigitalPinState[Four] = (myPinState & 0x08);
// Set defaults
myDigitalPinState[Six] = true;
myAnalogPinValue[Five] = minimumResistance;
myAnalogPinValue[Nine] = minimumResistance;
// Now scan the rows and columns
if(!(myPinState & 0x08))
{
myDigitalPinState[Six] = (myEvent.get(myPoundEvent) == 0);
if(myEvent.get(myZeroEvent) != 0) myAnalogPinValue[Five] = maximumResistance;
if(myEvent.get(myStarEvent) != 0) myAnalogPinValue[Nine] = maximumResistance;
}
if(!(myPinState & 0x04))
{
myDigitalPinState[Six] = (myEvent.get(myNineEvent) == 0);
if(myEvent.get(myEightEvent) != 0) myAnalogPinValue[Five] = maximumResistance;
if(myEvent.get(mySevenEvent) != 0) myAnalogPinValue[Nine] = maximumResistance;
}
if(!(myPinState & 0x02))
{
myDigitalPinState[Six] = (myEvent.get(mySixEvent) == 0);
if(myEvent.get(myFiveEvent) != 0) myAnalogPinValue[Five] = maximumResistance;
if(myEvent.get(myFourEvent) != 0) myAnalogPinValue[Nine] = maximumResistance;
}
if(!(myPinState & 0x01))
{
myDigitalPinState[Six] = (myEvent.get(myThreeEvent) == 0);
if(myEvent.get(myTwoEvent) != 0) myAnalogPinValue[Five] = maximumResistance;
if(myEvent.get(myOneEvent) != 0) myAnalogPinValue[Nine] = maximumResistance;
}
}

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: Keyboard.hxx,v 1.6 2007-01-01 18:04:48 stephena Exp $
// $Id: Keyboard.hxx,v 1.7 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef KEYBOARD_HXX
@ -21,12 +21,13 @@
#include "bspf.hxx"
#include "Control.hxx"
#include "Event.hxx"
/**
The standard Atari 2600 keyboard controller
@author Bradford W. Mott
@version $Id: Keyboard.hxx,v 1.6 2007-01-01 18:04:48 stephena Exp $
@version $Id: Keyboard.hxx,v 1.7 2007-10-03 21:41:18 stephena Exp $
*/
class Keyboard : public Controller
{
@ -45,23 +46,6 @@ class Keyboard : public Controller
virtual ~Keyboard();
public:
/**
Read the value of the specified digital pin for this controller.
@param pin The pin of the controller jack to read
@return The state of the pin
*/
virtual bool read(DigitalPin pin);
/**
Read the resistance at the specified analog pin for this controller.
The returned value is the resistance measured in ohms.
@param pin The pin of the controller jack to read
@return The resistance at the specified pin
*/
virtual Int32 read(AnalogPin pin);
/**
Write the given value to the specified digital pin for this
controller. Writing is only allowed to the pins associated
@ -72,9 +56,22 @@ class Keyboard : public Controller
*/
virtual void write(DigitalPin pin, bool value);
/**
Update the entire digital and analog pin state according to the
events currently set.
*/
virtual void update();
private:
// State of the output pins
uInt8 myPinState;
// Pre-compute the events we care about based on given port
// This will eliminate test for left or right port in update()
Event::Type myOneEvent, myTwoEvent, myThreeEvent,
myFourEvent, myFiveEvent, mySixEvent,
mySevenEvent, myEightEvent, myNineEvent,
myStarEvent, myZeroEvent, myPoundEvent;
};
#endif

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: M6532.cxx,v 1.10 2007-06-21 12:27:00 stephena Exp $
// $Id: M6532.cxx,v 1.11 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#include <assert.h>
@ -47,12 +47,6 @@ M6532::~M6532()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* M6532::name() const
{
return "M6532";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6532::reset()
{
@ -321,7 +315,7 @@ void M6532::poke(uInt16 addr, uInt8 value)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool M6532::save(Serializer& out)
bool M6532::save(Serializer& out) const
{
string device = name();
@ -332,15 +326,15 @@ bool M6532::save(Serializer& out)
// Output the RAM
out.putInt(128);
for(uInt32 t = 0; t < 128; ++t)
out.putInt(myRAM[t]);
out.putByte((char)myRAM[t]);
out.putInt(myTimer);
out.putInt(myIntervalShift);
out.putInt(myCyclesWhenTimerSet);
out.putInt(myCyclesWhenInterruptReset);
out.putBool(myTimerReadAfterInterrupt);
out.putInt(myDDRA);
out.putInt(myDDRB);
out.putByte((char)myDDRA);
out.putByte((char)myDDRB);
}
catch(char *msg)
{
@ -369,7 +363,7 @@ bool M6532::load(Deserializer& in)
// Input the RAM
uInt32 limit = (uInt32) in.getInt();
for(uInt32 t = 0; t < limit; ++t)
myRAM[t] = (uInt8) in.getInt();
myRAM[t] = (uInt8) in.getByte();
myTimer = (uInt32) in.getInt();
myIntervalShift = (uInt32) in.getInt();
@ -377,8 +371,8 @@ bool M6532::load(Deserializer& in)
myCyclesWhenInterruptReset = (uInt32) in.getInt();
myTimerReadAfterInterrupt = in.getBool();
myDDRA = (uInt8) in.getInt();
myDDRB = (uInt8) in.getInt();
myDDRA = (uInt8) in.getByte();
myDDRB = (uInt8) in.getByte();
}
catch(char *msg)
{
@ -394,7 +388,6 @@ bool M6532::load(Deserializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
M6532::M6532(const M6532& c)
: myConsole(c.myConsole)

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: M6532.hxx,v 1.5 2007-01-01 18:04:48 stephena Exp $
// $Id: M6532.hxx,v 1.6 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef M6532_HXX
@ -31,7 +31,7 @@ class Deserializer;
RIOT
@author Bradford W. Mott
@version $Id: M6532.hxx,v 1.5 2007-01-01 18:04:48 stephena Exp $
@version $Id: M6532.hxx,v 1.6 2007-10-03 21:41:18 stephena Exp $
*/
class M6532 : public Device
{
@ -49,13 +49,6 @@ class M6532 : public Device
virtual ~M6532();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset cartridge to its power-on state
*/
@ -77,21 +70,28 @@ class M6532 : public Device
virtual void install(System& system);
/**
Saves the current state of this device to the given Serializer.
Save 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.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out);
virtual bool save(Serializer& out) const;
/**
Loads the current state of this device from the given Deserializer.
Load 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.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "M6532"; }
public:
/**
Get the byte at the specified address

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: Paddles.cxx,v 1.8 2007-01-05 17:54:23 stephena Exp $
// $Id: Paddles.cxx,v 1.9 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#include "Event.hxx"
@ -24,42 +24,30 @@ Paddles::Paddles(Jack jack, const Event& event, bool swap)
: Controller(jack, event, Controller::Paddles)
{
// Swap the paddle events, from paddle 0 <=> 1 and paddle 2 <=> 3
if(!swap)
// Also consider whether this is the left or right port
if(myJack == Left)
{
// Pin Three
myPinEvents[0][0] = Event::PaddleOneFire;
myPinEvents[0][1] = Event::PaddleThreeFire;
// Pin Four
myPinEvents[1][0] = Event::PaddleZeroFire;
myPinEvents[1][1] = Event::PaddleTwoFire;
// Pin Five
myPinEvents[2][0] = Event::PaddleOneResistance;
myPinEvents[2][1] = Event::PaddleThreeResistance;
// Pin Nine
myPinEvents[3][0] = Event::PaddleZeroResistance;
myPinEvents[3][1] = Event::PaddleTwoResistance;
myP1ResEvent =
swap ? Event::PaddleZeroResistance : Event::PaddleOneResistance;
myP2ResEvent =
swap ? Event::PaddleOneResistance : Event::PaddleZeroResistance;
myP1FireEvent = swap ? Event::PaddleZeroFire : Event::PaddleOneFire;
myP2FireEvent = swap ? Event::PaddleOneFire : Event::PaddleZeroFire;
}
else
{
// Pin Three (swapped)
myPinEvents[0][0] = Event::PaddleZeroFire;
myPinEvents[0][1] = Event::PaddleTwoFire;
// Pin Four (swapped)
myPinEvents[1][0] = Event::PaddleOneFire;
myPinEvents[1][1] = Event::PaddleThreeFire;
// Pin Five (swapped)
myPinEvents[2][0] = Event::PaddleZeroResistance;
myPinEvents[2][1] = Event::PaddleTwoResistance;
// Pin Nine (swapped)
myPinEvents[3][0] = Event::PaddleOneResistance;
myPinEvents[3][1] = Event::PaddleThreeResistance;
myP1ResEvent =
swap ? Event::PaddleTwoResistance : Event::PaddleThreeResistance;
myP2ResEvent =
swap ? Event::PaddleThreeResistance : Event::PaddleTwoResistance;
myP1FireEvent = swap ? Event::PaddleTwoFire : Event::PaddleThreeFire;
myP2FireEvent = swap ? Event::PaddleThreeFire : Event::PaddleTwoFire;
}
// Digital pins 1, 2 and 6 are not connected
myDigitalPinState[One] =
myDigitalPinState[Two] =
myDigitalPinState[Six] = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -68,44 +56,11 @@ Paddles::~Paddles()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Paddles::read(DigitalPin pin)
void Paddles::update()
{
switch(pin)
{
case Three:
return (myJack == Left) ? (myEvent.get(myPinEvents[0][0]) == 0) :
(myEvent.get(myPinEvents[0][1]) == 0);
myDigitalPinState[Three] = (myEvent.get(myP1FireEvent) == 0);
myDigitalPinState[Four] = (myEvent.get(myP2FireEvent) == 0);
case Four:
return (myJack == Left) ? (myEvent.get(myPinEvents[1][0]) == 0) :
(myEvent.get(myPinEvents[1][1]) == 0);
default:
// Other pins are not connected (floating high)
return true;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 Paddles::read(AnalogPin pin)
{
switch(pin)
{
case Five:
return (myJack == Left) ? myEvent.get(myPinEvents[2][0]) :
myEvent.get(myPinEvents[2][1]);
case Nine:
return (myJack == Left) ? myEvent.get(myPinEvents[3][0]) :
myEvent.get(myPinEvents[3][1]);
default:
return maximumResistance;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Paddles::write(DigitalPin, bool)
{
// Writing doesn't do anything to the paddles...
myAnalogPinValue[Five] = myEvent.get(myP1ResEvent);
myAnalogPinValue[Nine] = myEvent.get(myP2ResEvent);
}

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: Paddles.hxx,v 1.7 2007-01-01 18:04:49 stephena Exp $
// $Id: Paddles.hxx,v 1.8 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef PADDLES_HXX
@ -21,12 +21,13 @@
#include "bspf.hxx"
#include "Control.hxx"
#include "Event.hxx"
/**
The standard Atari 2600 pair of paddle controllers.
@author Bradford W. Mott
@version $Id: Paddles.hxx,v 1.7 2007-01-01 18:04:49 stephena Exp $
@version $Id: Paddles.hxx,v 1.8 2007-10-03 21:41:18 stephena Exp $
*/
class Paddles : public Controller
{
@ -47,36 +48,15 @@ class Paddles : public Controller
public:
/**
Read the value of the specified digital pin for this controller.
@param pin The pin of the controller jack to read
@return The state of the pin
Update the entire digital and analog pin state according to the
events currently set.
*/
virtual bool read(DigitalPin pin);
/**
Read the resistance at the specified analog pin for this controller.
The returned value is the resistance measured in ohms.
@param pin The pin of the controller jack to read
@return The resistance at the specified pin
*/
virtual Int32 read(AnalogPin pin);
/**
Write the given value to the specified digital pin for this
controller. Writing is only allowed to the pins associated
with the PIA. Therefore you cannot write to pin six.
@param pin The pin of the controller jack to write to
@param value The value to write to the pin
*/
virtual void write(DigitalPin pin, bool value);
virtual void update();
private:
// Used to implement paddle swapping efficiently, and eliminate
// testing at runtime
Event::Type myPinEvents[4][2];
// Pre-compute the events we care about based on given port
// This will eliminate test for left or right port in update()
Event::Type myP1ResEvent, myP2ResEvent, myP1FireEvent, myP2FireEvent;
};
#endif

View File

@ -0,0 +1,63 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Serializable.hxx,v 1.1 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef SERIALIZABLE_HXX
#define SERIALIZABLE_HXX
#include "Serializer.hxx"
#include "Deserializer.hxx"
/**
This class provides an interface for (de)serializing objects.
It exists strictly to guarantee that all required classes use
method signatures as defined below.
@author Stephen Anthony
@version $Id: Serializable.hxx,v 1.1 2007-10-03 21:41:18 stephena Exp $
*/
class Serializable
{
public:
Serializable() { }
virtual ~Serializable() { }
/**
Save the current state of the object to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) const = 0;
/**
Load the current state of the object from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in) = 0;
/**
Get a descriptor for the object name (used in error checking).
@return The name of the object
*/
virtual string name() const = 0;
};
#endif

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: Serializer.cxx,v 1.11 2007-01-01 18:04:49 stephena Exp $
// $Id: Serializer.cxx,v 1.12 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#include "Serializer.hxx"
@ -51,6 +51,16 @@ bool Serializer::isOpen(void)
return myStream.is_open();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::putByte(char value)
{
char buf[1];
buf[0] = value;
myStream.write(buf, 1);
if(myStream.bad())
throw "Serializer: file write failed";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::putInt(int value)
{
@ -77,5 +87,5 @@ void Serializer::putString(const string& str)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::putBool(bool b)
{
putInt(b ? TruePattern: FalsePattern);
putByte(b ? TruePattern: FalsePattern);
}

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: Serializer.hxx,v 1.12 2007-01-01 18:04:49 stephena Exp $
// $Id: Serializer.hxx,v 1.13 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef SERIALIZER_HXX
@ -27,12 +27,12 @@
serialized and sent to an output binary file in a system-
independent way.
All bytes and integers are written as int's. Strings are
written as characters prepended by the length of the string.
Boolean values are written using a special pattern.
Bytes are written as characters, integers are written as 4 characters
(32-bit), strings are written as characters prepended by the length of the
string, boolean values are written using a special character pattern.
@author Stephen Anthony
@version $Id: Serializer.hxx,v 1.12 2007-01-01 18:04:49 stephena Exp $
@version $Id: Serializer.hxx,v 1.13 2007-10-03 21:41:18 stephena Exp $
*/
class Serializer
{
@ -71,7 +71,14 @@ class Serializer
bool isOpen(void);
/**
Writes an int value to the current output stream.
Writes an byte value (8-bit) to the current output stream.
@param value The byte value to write to the output stream.
*/
void putByte(char value);
/**
Writes an int value (32-bit) to the current output stream.
@param value The int value to write to the output stream.
*/
@ -96,8 +103,8 @@ class Serializer
fstream myStream;
enum {
TruePattern = 0xfab1fab2,
FalsePattern = 0xbad1bad2
TruePattern = 0xfe,
FalsePattern = 0x01
};
};

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: StateManager.cxx,v 1.1 2007-09-23 17:04:17 stephena Exp $
// $Id: StateManager.cxx,v 1.2 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#include <sstream>
@ -23,6 +23,8 @@
#include "Deserializer.hxx"
#include "Settings.hxx"
#include "Console.hxx"
#include "Control.hxx"
#include "Switches.hxx"
#include "System.hxx"
#include "StateManager.hxx"
@ -30,7 +32,9 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StateManager::StateManager(OSystem* osystem)
: myOSystem(osystem),
myCurrentSlot(0)
myCurrentSlot(0),
myActiveMode(kOffMode),
myFrameCounter(0)
{
reset();
}
@ -40,6 +44,122 @@ StateManager::~StateManager()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool StateManager::isActive()
{
return myActiveMode != kOffMode;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool StateManager::toggleRecordMode()
{
if(myActiveMode != kMovieRecordMode) // Turn on movie record mode
{
myActiveMode = kOffMode;
string moviefile = /*myOSystem->baseDir() + BSPF_PATH_SEPARATOR +*/ "test.inp";
if(myMovieWriter.isOpen())
myMovieWriter.close();
if(!myMovieWriter.open(moviefile))
return false;
// Prepend the ROM md5 so this state file only works with that ROM
myMovieWriter.putString(myOSystem->console().properties().get(Cartridge_MD5));
if(!myOSystem->console().save(myMovieWriter))
return false;
// Save controller types for this ROM
// We need to check this, since some controllers save more state than
// normal, and those states files wouldn't be compatible with normal
// controllers.
myMovieWriter.putString(
myOSystem->console().controller(Controller::Left).name());
myMovieWriter.putString(
myOSystem->console().controller(Controller::Right).name());
// If we get this far, we're really in movie record mode
myActiveMode = kMovieRecordMode;
}
else // Turn off movie record mode
{
myActiveMode = kOffMode;
myMovieWriter.close();
return false;
}
return myActiveMode == kMovieRecordMode;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool StateManager::toggleRewindMode()
{
// FIXME - For now, I'm going to use this to activate movie playback
// Close the writer, since we're about to re-open in read mode
myMovieWriter.close();
if(myActiveMode != kMoviePlaybackMode) // Turn on movie playback mode
{
myActiveMode = kOffMode;
string moviefile = /*myOSystem->baseDir() + BSPF_PATH_SEPARATOR +*/ "test.inp";
if(myMovieReader.isOpen())
myMovieReader.close();
if(!myMovieReader.open(moviefile))
return false;
// Check the ROM md5
if(myMovieReader.getString() !=
myOSystem->console().properties().get(Cartridge_MD5))
return false;
if(!myOSystem->console().load(myMovieReader))
return false;
// Check controller types
const string& left = myMovieReader.getString();
const string& right = myMovieReader.getString();
if(left != myOSystem->console().controller(Controller::Left).name() ||
right != myOSystem->console().controller(Controller::Right).name())
return false;
// If we get this far, we're really in movie record mode
myActiveMode = kMoviePlaybackMode;
}
else // Turn off movie playback mode
{
myActiveMode = kOffMode;
myMovieReader.close();
return false;
}
return myActiveMode == kMoviePlaybackMode;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StateManager::update()
{
switch(myActiveMode)
{
case kMovieRecordMode:
myOSystem->console().controller(Controller::Left).save(myMovieWriter);
myOSystem->console().controller(Controller::Right).save(myMovieWriter);
myOSystem->console().switches().save(myMovieWriter);
break;
case kMoviePlaybackMode:
myOSystem->console().controller(Controller::Left).load(myMovieReader);
myOSystem->console().controller(Controller::Right).load(myMovieReader);
myOSystem->console().switches().load(myMovieReader);
break;
default:
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StateManager::loadState(int slot)
{
@ -64,9 +184,9 @@ void StateManager::loadState(int slot)
return;
}
// Do a state load using the System
// Do a complete state load using the Console
buf.str("");
if(myOSystem->console().system().loadState(md5, in))
if(in.getString() == md5 && myOSystem->console().load(in))
buf << "State " << slot << " loaded";
else
buf << "Invalid state " << slot << " file";
@ -98,14 +218,13 @@ void StateManager::saveState(int slot)
return;
}
// Do a state save using the System
buf.str("");
//int start = myOSystem->getTicks();
if(myOSystem->console().system().saveState(md5, out))
{
//int end = myOSystem->getTicks();
//cerr << "ticks to save a state slot: " << (end - start) << endl;
// Prepend the ROM md5 so this state file only works with that ROM
out.putString(md5);
// Do a complete state save using the Console
buf.str("");
if(myOSystem->console().save(out))
{
buf << "State " << slot << " saved";
if(myOSystem->settings().getBool("autoslot"))
{
@ -136,6 +255,21 @@ void StateManager::changeState()
void StateManager::reset()
{
myCurrentSlot = 0;
switch(myActiveMode)
{
case kMovieRecordMode:
myMovieWriter.close();
break;
case kMoviePlaybackMode:
myMovieReader.close();
break;
default:
break;
}
myActiveMode = kOffMode;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: StateManager.hxx,v 1.1 2007-09-23 17:04:17 stephena Exp $
// $Id: StateManager.hxx,v 1.2 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef STATE_MANAGER_HXX
@ -21,13 +21,16 @@
class OSystem;
#include "Deserializer.hxx"
#include "Serializer.hxx"
/**
This class provides an interface to all things related to emulation state.
States can be loaded or saved here, as well as recorded, rewound, and later
played back.
@author Stephen Anthony
@version $Id: StateManager.hxx,v 1.1 2007-09-23 17:04:17 stephena Exp $
@version $Id: StateManager.hxx,v 1.2 2007-10-03 21:41:18 stephena Exp $
*/
class StateManager
{
@ -43,6 +46,19 @@ class StateManager
virtual ~StateManager();
public:
/**
Answers whether the manager is in record or playback mode
*/
bool isActive();
bool toggleRecordMode();
bool toggleRewindMode();
/**
Updates the state of the system based on the currently active mode
*/
void update();
/**
Load a state into the current system
@ -75,11 +91,32 @@ class StateManager
StateManager& operator = (const StateManager&);
private:
enum Mode {
kOffMode,
kMoviePlaybackMode,
kMovieRecordMode,
kRewindPlaybackMode,
kRewindRecordMode
};
// The parent OSystem object
OSystem* myOSystem;
// The current slot for load/save states
int myCurrentSlot;
// Whether the manager is in record or playback mode
Mode myActiveMode;
// Current frame count (write full state every 60 frames)
int myFrameCounter;
// MD5 of the currently active ROM (either in movie or rewind mode)
string myMD5;
// Serializer classes used to save/load the eventstream
Serializer myMovieWriter;
Deserializer myMovieReader;
};
#endif

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: Switches.cxx,v 1.7 2007-01-01 18:04:50 stephena Exp $
// $Id: Switches.cxx,v 1.8 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#include "Event.hxx"
@ -22,8 +22,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Switches::Switches(const Event& event, const Properties& properties)
: myEvent(event),
mySwitches(0xFF)
: myEvent(event),
mySwitches(0xFF)
{
if(properties.get(Console_RightDifficulty) == "B")
{
@ -59,7 +59,7 @@ Switches::~Switches()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 Switches::read()
void Switches::update()
{
if(myEvent.get(Event::ConsoleColor) != 0)
{
@ -105,7 +105,34 @@ uInt8 Switches::read()
{
mySwitches |= 0x01;
}
return mySwitches;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Switches::save(Serializer& out) const
{
try
{
out.putByte((char)mySwitches);
}
catch(...)
{
cerr << "Error: Switches::save() exception\n";
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Switches::load(Deserializer& in)
{
try
{
mySwitches = (uInt8) in.getByte();
}
catch(...)
{
cerr << "Error: Switches::load() exception\n";
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: Switches.hxx,v 1.4 2007-01-01 18:04:50 stephena Exp $
// $Id: Switches.hxx,v 1.5 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef SWITCHES_HXX
@ -21,17 +21,17 @@
class Event;
class Properties;
class Switches;
#include "Serializable.hxx"
#include "bspf.hxx"
/**
This class represents the console switches of the game console.
@author Bradford W. Mott
@version $Id: Switches.hxx,v 1.4 2007-01-01 18:04:50 stephena Exp $
@version $Id: Switches.hxx,v 1.5 2007-10-03 21:41:18 stephena Exp $
*/
class Switches
class Switches : public Serializable
{
public:
/**
@ -53,7 +53,35 @@ class Switches
@return The 8 bits which represent the state of the console switches
*/
uInt8 read();
uInt8 read() const { return mySwitches; }
/**
Update the switches variable
*/
void update();
/**
Save the current state of the switches to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
bool save(Serializer& out) const;
/**
Load the current state of the switches from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
string name() const { return "Switches"; }
private:
// Reference to the event object to use
@ -62,5 +90,5 @@ class Switches
// State of the console switches
uInt8 mySwitches;
};
#endif
#endif

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.81 2007-09-10 15:46:59 stephena Exp $
// $Id: TIA.cxx,v 1.82 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#include <cassert>
@ -120,12 +120,6 @@ TIA::~TIA()
delete[] myPreviousFrameBuffer;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* TIA::name() const
{
return "TIA";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::reset()
{
@ -303,7 +297,7 @@ void TIA::install(System& system)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TIA::save(Serializer& out)
bool TIA::save(Serializer& out) const
{
string device = name();
@ -320,36 +314,36 @@ bool TIA::save(Serializer& out)
out.putInt(myCurrentScanline);
out.putInt(myVSYNCFinishClock);
out.putInt(myEnabledObjects);
out.putByte((char)myEnabledObjects);
out.putInt(myVSYNC);
out.putInt(myVBLANK);
out.putInt(myNUSIZ0);
out.putInt(myNUSIZ1);
out.putByte((char)myVSYNC);
out.putByte((char)myVBLANK);
out.putByte((char)myNUSIZ0);
out.putByte((char)myNUSIZ1);
out.putInt(myCOLUP0);
out.putInt(myCOLUP1);
out.putInt(myCOLUPF);
out.putInt(myCOLUBK);
out.putInt(myCTRLPF);
out.putInt(myPlayfieldPriorityAndScore);
out.putByte((char)myCTRLPF);
out.putByte((char)myPlayfieldPriorityAndScore);
out.putBool(myREFP0);
out.putBool(myREFP1);
out.putInt(myPF);
out.putInt(myGRP0);
out.putInt(myGRP1);
out.putInt(myDGRP0);
out.putInt(myDGRP1);
out.putByte((char)myGRP0);
out.putByte((char)myGRP1);
out.putByte((char)myDGRP0);
out.putByte((char)myDGRP1);
out.putBool(myENAM0);
out.putBool(myENAM1);
out.putBool(myENABL);
out.putBool(myDENABL);
out.putInt(myHMP0);
out.putInt(myHMP1);
out.putInt(myHMM0);
out.putInt(myHMM1);
out.putInt(myHMBL);
out.putByte((char)myHMP0);
out.putByte((char)myHMP1);
out.putByte((char)myHMM0);
out.putByte((char)myHMM1);
out.putByte((char)myHMBL);
out.putBool(myVDELP0);
out.putBool(myVDELP1);
out.putBool(myVDELBL);
@ -362,8 +356,8 @@ bool TIA::save(Serializer& out)
out.putInt(myPOSM1);
out.putInt(myPOSBL);
out.putInt(myCurrentGRP0);
out.putInt(myCurrentGRP1);
out.putByte((char)myCurrentGRP0);
out.putByte((char)myCurrentGRP1);
// pointers
// myCurrentBLMask = ourBallMaskTable[0][0];
@ -417,36 +411,36 @@ bool TIA::load(Deserializer& in)
myCurrentScanline = (Int32) in.getInt();
myVSYNCFinishClock = (Int32) in.getInt();
myEnabledObjects = (uInt8) in.getInt();
myEnabledObjects = (uInt8) in.getByte();
myVSYNC = (uInt8) in.getInt();
myVBLANK = (uInt8) in.getInt();
myNUSIZ0 = (uInt8) in.getInt();
myNUSIZ1 = (uInt8) in.getInt();
myVSYNC = (uInt8) in.getByte();
myVBLANK = (uInt8) in.getByte();
myNUSIZ0 = (uInt8) in.getByte();
myNUSIZ1 = (uInt8) in.getByte();
myCOLUP0 = (uInt32) in.getInt();
myCOLUP1 = (uInt32) in.getInt();
myCOLUPF = (uInt32) in.getInt();
myCOLUBK = (uInt32) in.getInt();
myCTRLPF = (uInt8) in.getInt();
myPlayfieldPriorityAndScore = (uInt8) in.getInt();
myCTRLPF = (uInt8) in.getByte();
myPlayfieldPriorityAndScore = (uInt8) in.getByte();
myREFP0 = in.getBool();
myREFP1 = in.getBool();
myPF = (uInt32) in.getInt();
myGRP0 = (uInt8) in.getInt();
myGRP1 = (uInt8) in.getInt();
myDGRP0 = (uInt8) in.getInt();
myDGRP1 = (uInt8) in.getInt();
myGRP0 = (uInt8) in.getByte();
myGRP1 = (uInt8) in.getByte();
myDGRP0 = (uInt8) in.getByte();
myDGRP1 = (uInt8) in.getByte();
myENAM0 = in.getBool();
myENAM1 = in.getBool();
myENABL = in.getBool();
myDENABL = in.getBool();
myHMP0 = (Int8) in.getInt();
myHMP1 = (Int8) in.getInt();
myHMM0 = (Int8) in.getInt();
myHMM1 = (Int8) in.getInt();
myHMBL = (Int8) in.getInt();
myHMP0 = (Int8) in.getByte();
myHMP1 = (Int8) in.getByte();
myHMM0 = (Int8) in.getByte();
myHMM1 = (Int8) in.getByte();
myHMBL = (Int8) in.getByte();
myVDELP0 = in.getBool();
myVDELP1 = in.getBool();
myVDELBL = in.getBool();
@ -459,8 +453,8 @@ bool TIA::load(Deserializer& in)
myPOSM1 = (Int16) in.getInt();
myPOSBL = (Int16) in.getInt();
myCurrentGRP0 = (uInt8) in.getInt();
myCurrentGRP1 = (uInt8) in.getInt();
myCurrentGRP0 = (uInt8) in.getByte();
myCurrentGRP1 = (uInt8) in.getByte();
// pointers
// myCurrentBLMask = ourBallMaskTable[0][0];
@ -2016,9 +2010,9 @@ uInt8 TIA::peek(uInt16 addr)
}
else
{
double t = (1.6 * r * 0.01E-6);
double t = (1.5327 * r * 0.01E-6);
uInt32 needed = (uInt32)(t * 1.19E6);
if(mySystem->cycles() > (myDumpDisabledCycle + needed))
if((mySystem->cycles() - myDumpDisabledCycle) > needed)
{
return 0x80 | noise;
}
@ -2042,9 +2036,9 @@ uInt8 TIA::peek(uInt16 addr)
}
else
{
double t = (1.6 * r * 0.01E-6);
double t = (1.5327 * r * 0.01E-6);
uInt32 needed = (uInt32)(t * 1.19E6);
if(mySystem->cycles() > (myDumpDisabledCycle + needed))
if((mySystem->cycles() - myDumpDisabledCycle) > needed)
{
return 0x80 | noise;
}
@ -2068,9 +2062,9 @@ uInt8 TIA::peek(uInt16 addr)
}
else
{
double t = (1.6 * r * 0.01E-6);
double t = (1.5327 * r * 0.01E-6);
uInt32 needed = (uInt32)(t * 1.19E6);
if(mySystem->cycles() > (myDumpDisabledCycle + needed))
if((mySystem->cycles() - myDumpDisabledCycle) > needed)
{
return 0x80 | noise;
}
@ -2094,9 +2088,9 @@ uInt8 TIA::peek(uInt16 addr)
}
else
{
double t = (1.6 * r * 0.01E-6);
double t = (1.5327 * r * 0.01E-6);
uInt32 needed = (uInt32)(t * 1.19E6);
if(mySystem->cycles() > (myDumpDisabledCycle + needed))
if((mySystem->cycles() - myDumpDisabledCycle) > needed)
{
return 0x80 | noise;
}
@ -2146,7 +2140,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
if(((clock - myClockWhenFrameStarted) / 228) > myMaximumNumberOfScanlines)
{
mySystem->m6502().stop();
myPartialFrameFlag = false;
myPartialFrameFlag = false;
}
switch(addr)
@ -2169,7 +2163,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
// Since we're finished with the frame tell the processor to halt
mySystem->m6502().stop();
myPartialFrameFlag = false;
myPartialFrameFlag = false;
}
break;
}

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.hxx,v 1.42 2007-02-22 02:15:46 stephena Exp $
// $Id: TIA.hxx,v 1.43 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef TIA_HXX
@ -21,8 +21,6 @@
class Console;
class System;
class Serializer;
class Deserializer;
class Settings;
#include "bspf.hxx"
@ -42,7 +40,7 @@ class Settings;
be displayed on screen.
@author Bradford W. Mott
@version $Id: TIA.hxx,v 1.42 2007-02-22 02:15:46 stephena Exp $
@version $Id: TIA.hxx,v 1.43 2007-10-03 21:41:18 stephena Exp $
*/
class TIA : public Device , public MediaSource
{
@ -63,13 +61,6 @@ class TIA : public Device , public MediaSource
virtual ~TIA();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -96,21 +87,28 @@ class TIA : public Device , public MediaSource
virtual void install(System& system);
/**
Saves the current state of this device to the given Serializer.
Save 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.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out);
virtual bool save(Serializer& out) const;
/**
Loads the current state of this device from the given Deserializer.
Load 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.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "TIA"; }
public:
/**
Get the byte at the specified address

View File

@ -0,0 +1,86 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TrackBall22.cxx,v 1.1 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#include "Event.hxx"
#include "TrackBall22.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TrackBall22::TrackBall22(Jack jack, const Event& event)
: Controller(jack, event, Controller::TrackBall22),
myHCounter(0),
myVCounter(0)
{
if(myJack == Left)
{
myUpEvent = Event::JoystickZeroUp;
myDownEvent = Event::JoystickZeroDown;
myLeftEvent = Event::JoystickZeroLeft;
myRightEvent = Event::JoystickZeroRight;
myFireEvent = Event::JoystickZeroFire;
}
else
{
myUpEvent = Event::JoystickOneUp;
myDownEvent = Event::JoystickOneDown;
myLeftEvent = Event::JoystickOneLeft;
myRightEvent = Event::JoystickOneRight;
myFireEvent = Event::JoystickOneFire;
}
// Analog pins are never used by the CX-22
myAnalogPinValue[Five] = myAnalogPinValue[Nine] = maximumResistance;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TrackBall22::~TrackBall22()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TrackBall22::update()
{
//db TrakBallTableTB_V[2][2] = {{0x00, 0x10},{0x20, 0x30}}; /* CX-22 */
//db TrakBallTableTB_H[2][2] = {{0x40, 0x00},{0xc0, 0x80}}; /* CX-22 */
// Gray codes for rotation
static const uInt8 graytable[] = { 0x00, 0x10, 0x20, 0x30 };
// Determine which gray code we're at
if(myEvent.get(myLeftEvent) != 0)
{
myHCounter--;
cerr << "left\n";
}
else if(myEvent.get(myRightEvent) != 0)
{
myHCounter++;
cerr << "right\n";
}
// Only consider the lower-most bits (corresponding to pins 1 & 2)
myHCounter &= 0x0f;
uInt8 gray = graytable[myHCounter >> 2];
// Determine which bits are set
myDigitalPinState[One] = (gray & 0x1) != 0;
myDigitalPinState[Two] = (gray & 0x2) != 0;
myDigitalPinState[Three] = (gray & 0x1) != 0;
myDigitalPinState[Four] = (gray & 0x2) != 0;
myDigitalPinState[Six] = (myEvent.get(myFireEvent) == 0);
}

View File

@ -0,0 +1,64 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TrackBall22.hxx,v 1.1 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef TRACKBALL22_HXX
#define TRACKBALL22_HXX
#include "bspf.hxx"
#include "Control.hxx"
#include "Event.hxx"
/**
The standard Atari 2600 CX-22 Trakball controller.
@author Stephen Anthony
@version $Id: TrackBall22.hxx,v 1.1 2007-10-03 21:41:18 stephena Exp $
*/
class TrackBall22 : public Controller
{
public:
/**
Create a new CX-22 TrackBall controller plugged into the specified jack
@param jack The jack the controller is plugged into
@param event The event object to use for events
*/
TrackBall22(Jack jack, const Event& event);
/**
Destructor
*/
virtual ~TrackBall22();
public:
/**
Update the entire digital and analog pin state according to the
events currently set.
*/
virtual void update();
private:
// Counter to iterate through the gray codes
uInt32 myHCounter, myVCounter;
// Pre-compute the events we care about based on given port
// This will eliminate test for left or right port in update()
Event::Type myUpEvent, myDownEvent, myLeftEvent, myRightEvent, myFireEvent;
};
#endif

View File

@ -13,16 +13,15 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Device.hxx,v 1.6 2007-01-14 16:17:57 stephena Exp $
// $Id: Device.hxx,v 1.7 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#ifndef DEVICE_HXX
#define DEVICE_HXX
class System;
class Serializer;
class Deserializer;
#include "Serializable.hxx"
#include "bspf.hxx"
/**
@ -30,9 +29,9 @@ class Deserializer;
based system.
@author Bradford W. Mott
@version $Id: Device.hxx,v 1.6 2007-01-14 16:17:57 stephena Exp $
@version $Id: Device.hxx,v 1.7 2007-10-03 21:41:18 stephena Exp $
*/
class Device
class Device : public Serializable
{
public:
/**
@ -46,13 +45,6 @@ class Device
virtual ~Device();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const = 0;
/**
Reset device to its power-on state
*/
@ -74,21 +66,28 @@ class Device
virtual void install(System& system) = 0;
/**
Saves the current state of this device to the given Serializer.
Save 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.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out) = 0;
virtual bool save(Serializer& out) const = 0;
/**
Loads the current state of this device from the given Deserializer.
Load 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.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in) = 0;
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const = 0;
public:
/**
Get the byte at the specified address

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: M6502Hi.cxx,v 1.19 2007-01-01 18:04:51 stephena Exp $
// $Id: M6502Hi.cxx,v 1.20 2007-10-03 21:41:18 stephena Exp $
//============================================================================
#include "M6502Hi.hxx"
@ -240,12 +240,12 @@ bool M6502High::save(Serializer& out)
{
out.putString(CPU);
out.putInt(A); // Accumulator
out.putInt(X); // X index register
out.putInt(Y); // Y index register
out.putInt(SP); // Stack Pointer
out.putInt(IR); // Instruction register
out.putInt(PC); // Program Counter
out.putByte((char)A); // Accumulator
out.putByte((char)X); // X index register
out.putByte((char)Y); // Y index register
out.putByte((char)SP); // Stack Pointer
out.putByte((char)IR); // Instruction register
out.putInt(PC); // Program Counter
out.putBool(N); // N flag for processor status register
out.putBool(V); // V flag for processor status register
@ -255,7 +255,7 @@ bool M6502High::save(Serializer& out)
out.putBool(notZ); // Z flag complement for processor status register
out.putBool(C); // C flag for processor status register
out.putInt(myExecutionStatus);
out.putByte((char)myExecutionStatus);
// Indicates the number of distinct memory accesses
out.putInt(myNumberOfDistinctAccesses);
@ -287,11 +287,11 @@ bool M6502High::load(Deserializer& in)
if(in.getString() != CPU)
return false;
A = (uInt8) in.getInt(); // Accumulator
X = (uInt8) in.getInt(); // X index register
Y = (uInt8) in.getInt(); // Y index register
SP = (uInt8) in.getInt(); // Stack Pointer
IR = (uInt8) in.getInt(); // Instruction register
A = (uInt8) in.getByte(); // Accumulator
X = (uInt8) in.getByte(); // X index register
Y = (uInt8) in.getByte(); // Y index register
SP = (uInt8) in.getByte(); // Stack Pointer
IR = (uInt8) in.getByte(); // Instruction register
PC = (uInt16) in.getInt(); // Program Counter
N = in.getBool(); // N flag for processor status register
@ -302,7 +302,7 @@ bool M6502High::load(Deserializer& in)
notZ = in.getBool(); // Z flag complement for processor status register
C = in.getBool(); // C flag for processor status register
myExecutionStatus = (uInt8) in.getInt();
myExecutionStatus = (uInt8) in.getByte();
// Indicates the number of distinct memory accesses
myNumberOfDistinctAccesses = (uInt32) in.getInt();

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: M6502Low.cxx,v 1.12 2007-01-01 18:04:51 stephena Exp $
// $Id: M6502Low.cxx,v 1.13 2007-10-03 21:41:19 stephena Exp $
//============================================================================
#include "M6502Low.hxx"
@ -224,12 +224,12 @@ bool M6502Low::save(Serializer& out)
{
out.putString(CPU);
out.putInt(A); // Accumulator
out.putInt(X); // X index register
out.putInt(Y); // Y index register
out.putInt(SP); // Stack Pointer
out.putInt(IR); // Instruction register
out.putInt(PC); // Program Counter
out.putByte((char)A); // Accumulator
out.putByte((char)X); // X index register
out.putByte((char)Y); // Y index register
out.putByte((char)SP); // Stack Pointer
out.putByte((char)IR); // Instruction register
out.putInt(PC); // Program Counter
out.putBool(N); // N flag for processor status register
out.putBool(V); // V flag for processor status register
@ -239,7 +239,7 @@ bool M6502Low::save(Serializer& out)
out.putBool(notZ); // Z flag complement for processor status register
out.putBool(C); // C flag for processor status register
out.putInt(myExecutionStatus);
out.putByte((char)myExecutionStatus);
}
catch(char *msg)
{
@ -265,11 +265,11 @@ bool M6502Low::load(Deserializer& in)
if(in.getString() != CPU)
return false;
A = (uInt8) in.getInt(); // Accumulator
X = (uInt8) in.getInt(); // X index register
Y = (uInt8) in.getInt(); // Y index register
SP = (uInt8) in.getInt(); // Stack Pointer
IR = (uInt8) in.getInt(); // Instruction register
A = (uInt8) in.getByte(); // Accumulator
X = (uInt8) in.getByte(); // X index register
Y = (uInt8) in.getByte(); // Y index register
SP = (uInt8) in.getByte(); // Stack Pointer
IR = (uInt8) in.getByte(); // Instruction register
PC = (uInt16) in.getInt(); // Program Counter
N = in.getBool(); // N flag for processor status register
@ -280,7 +280,7 @@ bool M6502Low::load(Deserializer& in)
notZ = in.getBool(); // Z flag complement for processor status register
C = in.getBool(); // C flag for processor status register
myExecutionStatus = (uInt8) in.getInt();
myExecutionStatus = (uInt8) in.getByte();
}
catch(char *msg)
{

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: NullDev.cxx,v 1.5 2007-01-01 18:04:51 stephena Exp $
// $Id: NullDev.cxx,v 1.6 2007-10-03 21:41:19 stephena Exp $
//============================================================================
#include "NullDev.hxx"
@ -30,12 +30,6 @@ NullDevice::~NullDevice()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* NullDevice::name() const
{
return "NULL";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void NullDevice::reset()
{
@ -61,7 +55,7 @@ void NullDevice::poke(uInt16 address, uInt8 value)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool NullDevice::save(Serializer& out)
bool NullDevice::save(Serializer& out) const
{
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: NullDev.hxx,v 1.5 2007-01-01 18:04:51 stephena Exp $
// $Id: NullDev.hxx,v 1.6 2007-10-03 21:41:19 stephena Exp $
//============================================================================
#ifndef NULLDEVICE_HXX
@ -32,7 +32,7 @@ class Deserializer;
holes in the address space (i.e. no real device attached).
@author Bradford W. Mott
@version $Id: NullDev.hxx,v 1.5 2007-01-01 18:04:51 stephena Exp $
@version $Id: NullDev.hxx,v 1.6 2007-10-03 21:41:19 stephena Exp $
*/
class NullDevice : public Device
{
@ -48,13 +48,6 @@ class NullDevice : public Device
virtual ~NullDevice();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset device to its power-on state
*/
@ -69,20 +62,27 @@ class NullDevice : public Device
virtual void install(System& system);
/**
Saves the current state of this device to the given Serializer.
Save 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.
@param out The Serializer object to use
@return False on any errors, else true
*/
virtual bool save(Serializer& out);
bool save(Serializer& out) const;
/**
Loads the current state of this device from the given Deserializer.
Load 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.
@param in The Deserializer object to use
@return False on any errors, else true
*/
virtual bool load(Deserializer& in);
bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
string name() const { return "NullDevice"; }
public:
/**

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: System.cxx,v 1.22 2007-09-23 17:04:17 stephena Exp $
// $Id: System.cxx,v 1.23 2007-10-03 21:41:19 stephena Exp $
//============================================================================
#include <assert.h>
@ -23,8 +23,6 @@
#include "M6502.hxx"
#include "TIA.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
System::System(uInt16 n, uInt16 m)
@ -122,52 +120,6 @@ void System::attach(TIA* tia)
attach((Device*) tia);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool System::save(Serializer& out)
{
try
{
out.putString("System");
out.putInt(myCycles);
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for \'System\'" << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool System::load(Deserializer& in)
{
try
{
if(in.getString() != "System")
return false;
myCycles = (uInt32) in.getInt();
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for \'System\'" << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void System::resetCycles()
{
@ -202,85 +154,6 @@ const System::PageAccess& System::getPageAccess(uInt16 page)
return myPageAccessTable[page];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool System::saveState(const string& md5sum, Serializer& out)
{
if(!out.isOpen())
return false;
try
{
// Prepend the state file with the md5sum of this cartridge
// This is the first defensive check for an invalid state file
out.putString(md5sum);
// First save state for this system
if(!save(out))
return false;
// Next, save state for the CPU
if(!myM6502->save(out))
return false;
// Now save the state of each device
for(uInt32 i = 0; i < myNumberOfDevices; ++i)
if(!myDevices[i]->save(out))
return false;
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for \'System\'" << endl;
return false;
}
return true; // success
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool System::loadState(const string& md5sum, Deserializer& in)
{
if(!in.isOpen())
return false;
try
{
// Look at the beginning of the state file. It should contain the md5sum
// of the current cartridge. If it doesn't, this state file is invalid.
if(in.getString() != md5sum)
return false;
// First load state for this system
if(!load(in))
return false;
// Next, load state for the CPU
if(!myM6502->load(in))
return false;
// Now load the state of each device
for(uInt32 i = 0; i < myNumberOfDevices; ++i)
if(!myDevices[i]->load(in))
return false;
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for \'System\'" << endl;
return false;
}
return true; // success
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
System::System(const System& s)
: myAddressMask(s.myAddressMask),
@ -356,3 +229,68 @@ void System::unlockDataBus()
{
myDataBusLocked = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool System::save(Serializer& out) const
{
const string& device = name();
try
{
out.putString(device);
out.putInt(myCycles);
if(!myM6502->save(out))
return false;
// Now save the state of each device
for(uInt32 i = 0; i < myNumberOfDevices; ++i)
if(!myDevices[i]->save(out))
return false;
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << device << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool System::load(Deserializer& in)
{
const string& device = name();
try
{
if(in.getString() != device)
return false;
myCycles = (uInt32) in.getInt();
// Next, load state for the CPU
if(!myM6502->load(in))
return false;
// Now load the state of each device
for(uInt32 i = 0; i < myNumberOfDevices; ++i)
if(!myDevices[i]->load(in))
return false;
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << device << 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: System.hxx,v 1.16 2007-01-01 18:04:51 stephena Exp $
// $Id: System.hxx,v 1.17 2007-10-03 21:41:19 stephena Exp $
//============================================================================
#ifndef SYSTEM_HXX
@ -23,12 +23,11 @@ class Device;
class M6502;
class TIA;
class NullDevice;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Device.hxx"
#include "NullDev.hxx"
#include "Serializable.hxx"
/**
This class represents a system consisting of a 6502 microprocessor
@ -47,9 +46,9 @@ class Deserializer;
dynamic code for that page of memory.
@author Bradford W. Mott
@version $Id: System.hxx,v 1.16 2007-01-01 18:04:51 stephena Exp $
@version $Id: System.hxx,v 1.17 2007-10-03 21:41:19 stephena Exp $
*/
class System
class System : public Serializable
{
public:
/**
@ -73,23 +72,6 @@ class System
*/
void reset();
/**
Saves the current state of this system class to the given Serializer.
@param out The serializer device to save to.
@return The result of the save. True on success, false on failure.
*/
bool save(Serializer& out);
/**
Loads the current state of this system class from the given Deserializer.
@param in The deserializer device to load from.
@return The result of the load. True on success, false on failure.
*/
bool load(Deserializer& in);
public:
/**
Attach the specified device and claim ownership of it. The device
will be asked to install itself.
@ -114,28 +96,6 @@ class System
*/
void attach(TIA* tia);
/**
Saves the current state of Stella to the given file. Calls
save on every device and CPU attached to this system.
@param md5sum MD5 of the current ROM
@param out The serializer device to save to
@return False on any errors, else true
*/
bool saveState(const string& md5sum, Serializer& out);
/**
Loads the current state of Stella from the given file. Calls
load on every device and CPU attached to this system.
@param md5sum MD5 of the current ROM
@param in The deserializer device to load from
@return False on any errors, else true
*/
bool loadState(const string& md5sum, Deserializer& in);
public:
/**
Answer the 6502 microprocessor attached to the system. If a
@ -237,7 +197,10 @@ class System
@return the data bus state
*/
uInt8 getDataBusState() const;
inline uInt8 getDataBusState() const
{
return myDataBusState;
}
/**
Get the byte at the specified address. No masking of the
@ -315,6 +278,29 @@ class System
*/
const PageAccess& getPageAccess(uInt16 page);
/**
Save the current state of this system to the given Serializer.
@param out The Serializer object to use
@return False on any errors, else true
*/
bool save(Serializer& out) const;
/**
Load the current state of this system from the given Deserializer.
@param in The Deserializer object to use
@return False on any errors, else true
*/
bool load(Deserializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
virtual string name() const { return "System"; }
private:
// Mask to apply to an address before accessing memory
const uInt16 myAddressMask;
@ -365,10 +351,4 @@ class System
System& operator = (const System&);
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline uInt8 System::getDataBusState() const
{
return myDataBusState;
}
#endif

View File

@ -51,6 +51,7 @@ MODULE_OBJS := \
src/emucore/StateManager.o \
src/emucore/TIA.o \
src/emucore/TIASnd.o \
src/emucore/TrackBall22.o \
src/emucore/unzip.o \
src/emucore/MediaFactory.o