Some cleanups and code reorganization to the Cart classes, adding comments,

etc.

Added stub for Cart0840 bankswitching.  The code is mostly ready; I'm just
waiting for the go-ahead to release it.

Updated ROM properties for those ROMs affected by the keypad fixes in the
last commit.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1279 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2007-01-14 16:17:57 +00:00
parent 309fbe2e94
commit 12a55685a1
50 changed files with 2754 additions and 1837 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart.cxx,v 1.30 2007-01-07 01:26:52 stephena Exp $ // $Id: Cart.cxx,v 1.31 2007-01-14 16:17:51 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -21,6 +21,7 @@
#include "bspf.hxx" #include "bspf.hxx"
#include "Cart.hxx" #include "Cart.hxx"
#include "Cart0840.hxx"
#include "Cart2K.hxx" #include "Cart2K.hxx"
#include "Cart3E.hxx" #include "Cart3E.hxx"
#include "Cart3F.hxx" #include "Cart3F.hxx"
@ -130,6 +131,8 @@ Cartridge* Cartridge::create(const uInt8* image, uInt32 size,
cartridge = new CartridgeCV(image, size); cartridge = new CartridgeCV(image, size);
else if(type == "UA") else if(type == "UA")
cartridge = new CartridgeUA(image); cartridge = new CartridgeUA(image);
else if(type == "0840")
cartridge = new Cartridge0840(image);
else else
cerr << "ERROR: Invalid cartridge type " << type << " ..." << endl; cerr << "ERROR: Invalid cartridge type " << type << " ..." << endl;
@ -147,6 +150,24 @@ Cartridge::~Cartridge()
{ {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge::save(ofstream& out)
{
int size = -1;
uInt8* image = getImage(size);
if(image == 0 || size <= 0)
{
cerr << "save not supported" << endl;
return false;
}
for(int i=0; i<size; i++)
out << image[i];
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Cartridge::autodetectType(const uInt8* image, uInt32 size) string Cartridge::autodetectType(const uInt8* image, uInt32 size)
{ {
@ -346,60 +367,6 @@ bool Cartridge::isProbablyE7(const uInt8* image, uInt32 size)
return (count1 > 0 || count2 > 0); return (count1 > 0 || count2 > 0);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// default implementations of bankswitching-related methods.
// These are suitable to be inherited by a cart type that
// doesn't support bankswitching at all.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge::bank(uInt16 b)
{
// do nothing.
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge::bank()
{
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge::bankCount()
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge::patch(uInt16 address, uInt8 value)
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge::save(ofstream& out)
{
int size = -1;
uInt8* image = getImage(size);
if(image == 0 || size <= 0)
{
cerr << "save not supported" << endl;
return false;
}
for(int i=0; i<size; i++)
out << image[i];
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge::getImage(int& size)
{
size = 0;
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge::Cartridge(const Cartridge&) Cartridge::Cartridge(const Cartridge&)
{ {

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart.hxx,v 1.16 2007-01-01 18:04:45 stephena Exp $ // $Id: Cart.hxx,v 1.17 2007-01-14 16:17:52 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGE_HXX #ifndef CARTRIDGE_HXX
@ -33,7 +33,7 @@ class Settings;
game and handles any bankswitching performed by the cartridge. game and handles any bankswitching performed by the cartridge.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Cart.hxx,v 1.16 2007-01-01 18:04:45 stephena Exp $ @version $Id: Cart.hxx,v 1.17 2007-01-14 16:17:52 stephena Exp $
*/ */
class Cartridge : public Device class Cartridge : public Device
{ {
@ -51,7 +51,6 @@ class Cartridge : public Device
static Cartridge* create(const uInt8* image, uInt32 size, static Cartridge* create(const uInt8* image, uInt32 size,
const Properties& props, const Settings& settings); const Properties& props, const Settings& settings);
public:
/** /**
Create a new cartridge Create a new cartridge
*/ */
@ -67,18 +66,61 @@ class Cartridge : public Device
*/ */
static const string& about() { return myAboutString; } static const string& about() { return myAboutString; }
virtual void bank(uInt16 b); // set bank /**
virtual int bank(); // get current bank (-1 if no bankswitching supported) Save the internal (patched) ROM image.
virtual int bankCount(); // count # of banks
virtual bool patch(uInt16 address, uInt8 value); // yes, this writes to ROM @param out The output file stream to save the image
bool save(ofstream& out); // need a way to save patched ROMs */
virtual uInt8* getImage(int& size); // save() uses this bool save(ofstream& out);
void lockBank() { bankLocked = true; }
/**
Lock/unlock bankswitching capability.
*/
void lockBank() { bankLocked = true; }
void unlockBank() { bankLocked = false; } void unlockBank() { bankLocked = false; }
public:
//////////////////////////////////////////////////////////////////////
// The following methods are cart-specific and must be implemented
// in derived classes.
//////////////////////////////////////////////////////////////////////
/**
Set the specified bank.
*/
virtual void bank(uInt16 bank) = 0;
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank() = 0;
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount() = 0;
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value) = 0;
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size) = 0;
protected: protected:
// If bankLocked is true, ignore attempts at bankswitching. This is used // If bankLocked is true, ignore attempts at bankswitching. This is used
// by the debugger, when disassembling/dumping ROM. // by the debugger, when disassembling/dumping ROM.
bool bankLocked; bool bankLocked;
private: private:
@ -131,5 +173,5 @@ class Cartridge : public Device
// Assignment operator isn't supported by cartridges so make it private // Assignment operator isn't supported by cartridges so make it private
Cartridge& operator = (const Cartridge&); Cartridge& operator = (const Cartridge&);
}; };
#endif
#endif

View File

@ -0,0 +1,103 @@
//============================================================================
//
// 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: Cart0840.cxx,v 1.0 2006/11/17
//============================================================================
#include <cassert>
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "Cart0840.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge0840::Cartridge0840(const uInt8* image)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge0840::~Cartridge0840()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* Cartridge0840::name() const
{
return "Cartridge0840";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge0840::reset()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge0840::install(System& system)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 Cartridge0840::peek(uInt16 address)
{
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge0840::bank()
{
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge0840::bankCount()
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge0840::patch(uInt16 address, uInt8 value)
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge0840::getImage(int& size)
{
size = 0;
return 0;
}

View File

@ -0,0 +1,140 @@
//============================================================================
//
// 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: Cart0840.hxx,v 1.0 2006/11/14
//============================================================================
#ifndef CARTRIDGE0840_HXX
#define CARTRIDGE0840_HXX
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
/**
Cartridge class used for 0840 "Econobanking" 8K bankswitched games. There
are two 4K banks.
@author Fred X. Quimby
*/
class Cartridge0840 : public Cartridge
{
public:
/**
Create a new cartridge using the specified image
@param image Pointer to the ROM image
*/
Cartridge0840(const uInt8* image);
/**
Destructor
*/
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
*/
virtual void reset();
/**
Install cartridge in the specified system. Invoked by the system
when the cartridge is attached to it.
@param system The system the device should install itself in
*/
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.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size);
public:
/**
Get the byte at the specified address.
@return The byte at the specified address
*/
virtual uInt8 peek(uInt16 address);
/**
Change the byte at the specified address to the given value
@param address The address where the value should be stored
@param value The value to be stored at the address
*/
virtual void poke(uInt16 address, uInt8 value);
};
#endif

View File

@ -13,15 +13,15 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart2K.cxx,v 1.8 2007-01-01 18:04:45 stephena Exp $ // $Id: Cart2K.cxx,v 1.9 2007-01-14 16:17:52 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "Cart2K.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "Cart2K.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge2K::Cartridge2K(const uInt8* image) Cartridge2K::Cartridge2K(const uInt8* image)
@ -83,13 +83,6 @@ void Cartridge2K::poke(uInt16, uInt8)
// This is ROM so poking has no effect :-) // This is ROM so poking has no effect :-)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge2K::patch(uInt16 address, uInt8 value)
{
myImage[address & 0x07FF] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge2K::save(Serializer& out) bool Cartridge2K::save(Serializer& out)
{ {
@ -99,7 +92,7 @@ bool Cartridge2K::save(Serializer& out)
{ {
out.putString(cart); out.putString(cart);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -123,7 +116,7 @@ bool Cartridge2K::load(Deserializer& in)
if(in.getString() != cart) if(in.getString() != cart)
return false; return false;
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -138,7 +131,34 @@ bool Cartridge2K::load(Deserializer& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge2K::getImage(int& size) { 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; size = 2048;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,12 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart2K.hxx,v 1.8 2007-01-01 18:04:45 stephena Exp $ // $Id: Cart2K.hxx,v 1.9 2007-01-14 16:17:52 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGE2K_HXX #ifndef CARTRIDGE2K_HXX
#define CARTRIDGE2K_HXX #define CARTRIDGE2K_HXX
class Cartridge2K;
class System; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -33,7 +32,7 @@ class Deserializer;
2600's 4K cartridge addressing space. 2600's 4K cartridge addressing space.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Cart2K.hxx,v 1.8 2007-01-01 18:04:45 stephena Exp $ @version $Id: Cart2K.hxx,v 1.9 2007-01-14 16:17:52 stephena Exp $
*/ */
class Cartridge2K : public Cartridge class Cartridge2K : public Cartridge
{ {
@ -87,6 +86,40 @@ class Cartridge2K : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -105,11 +138,9 @@ class Cartridge2K : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
private: private:
// The 2k ROM image for the cartridge // The 2k ROM image for the cartridge
uInt8 myImage[2048]; uInt8 myImage[2048];
}; };
#endif
#endif

View File

@ -13,21 +13,21 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart3E.cxx,v 1.11 2007-01-01 18:04:45 stephena Exp $ // $Id: Cart3E.cxx,v 1.12 2007-01-14 16:17:52 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "Cart3E.hxx"
#include "Random.hxx" #include "Random.hxx"
#include "System.hxx" #include "System.hxx"
#include "TIA.hxx" #include "TIA.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "Cart3E.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge3E::Cartridge3E(const uInt8* image, uInt32 size) Cartridge3E::Cartridge3E(const uInt8* image, uInt32 size)
: mySize(size) : mySize(size)
{ {
// Allocate array for the ROM image // Allocate array for the ROM image
myImage = new uInt8[mySize]; myImage = new uInt8[mySize];
@ -142,22 +142,67 @@ void Cartridge3E::poke(uInt16 address, uInt8 value)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3E::patch(uInt16 address, uInt8 value) bool Cartridge3E::save(Serializer& out)
{ {
address = address & 0x0FFF; string cart = name();
if(address < 0x0800)
try
{ {
if(myCurrentBank < 256) out.putString(cart);
myImage[(address & 0x07FF) + myCurrentBank * 2048] = value; out.putInt(myCurrentBank);
else
myRam[(address & 0x03FF) + (myCurrentBank - 256) * 1024] = value; // Output RAM
out.putInt(32768);
for(uInt32 addr = 0; addr < 32768; ++addr)
out.putInt(myRam[addr]);
} }
else catch(const char* msg)
{ {
myImage[(address & 0x07FF) + mySize - 2048] = value; cerr << msg << endl;
return false;
} }
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
return true; 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) void Cartridge3E::bank(uInt16 bank)
@ -227,81 +272,38 @@ void Cartridge3E::bank(uInt16 bank)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge3E::bank() { int Cartridge3E::bank()
{
return myCurrentBank; return myCurrentBank;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge3E::bankCount() { int Cartridge3E::bankCount()
return mySize/2048;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3E::save(Serializer& out)
{ {
string cart = name(); return mySize / 2048;
try
{
out.putString(cart);
out.putInt(myCurrentBank);
// Output RAM
out.putInt(32768);
for(uInt32 addr = 0; addr < 32768; ++addr)
out.putInt(myRam[addr]);
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3E::load(Deserializer& in) bool Cartridge3E::patch(uInt16 address, uInt8 value)
{ {
string cart = name(); address = address & 0x0FFF;
if(address < 0x0800)
try
{ {
if(in.getString() != cart) if(myCurrentBank < 256)
return false; myImage[(address & 0x07FF) + myCurrentBank * 2048] = value;
else
myCurrentBank = (uInt16) in.getInt(); myRam[(address & 0x03FF) + (myCurrentBank - 256) * 1024] = value;
// Input RAM
uInt32 limit = (uInt32) in.getInt();
for(uInt32 addr = 0; addr < limit; ++addr)
myRam[addr] = (uInt8) in.getInt();
} }
catch(char *msg) else
{ {
cerr << msg << endl; myImage[(address & 0x07FF) + mySize - 2048] = value;
return false;
} }
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
// Now, go to the current bank
bank(myCurrentBank);
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge3E::getImage(int& size) { uInt8* Cartridge3E::getImage(int& size)
{
size = mySize; size = mySize;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart3E.hxx,v 1.4 2007-01-01 18:04:45 stephena Exp $ // $Id: Cart3E.hxx,v 1.5 2007-01-14 16:17:52 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGE3E_HXX #ifndef CARTRIDGE3E_HXX
#define CARTRIDGE3E_HXX #define CARTRIDGE3E_HXX
class Cartridge3E; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -59,7 +59,7 @@ class Deserializer;
any problems. (Famous last words...) any problems. (Famous last words...)
@author B. Watson @author B. Watson
@version $Id: Cart3E.hxx,v 1.4 2007-01-01 18:04:45 stephena Exp $ @version $Id: Cart3E.hxx,v 1.5 2007-01-14 16:17:52 stephena Exp $
*/ */
class Cartridge3E : public Cartridge class Cartridge3E : public Cartridge
@ -115,6 +115,40 @@ class Cartridge3E : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -133,18 +167,6 @@ class Cartridge3E : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Map the specified bank into the first segment
@param bank The bank that should be mapped
*/
void bank(uInt16 bank);
int bank();
int bankCount();
private: private:
// Indicates which bank is currently active for the first segment // Indicates which bank is currently active for the first segment
uInt16 myCurrentBank; uInt16 myCurrentBank;
@ -158,5 +180,5 @@ class Cartridge3E : public Cartridge
// Size of the ROM image // Size of the ROM image
uInt32 mySize; uInt32 mySize;
}; };
#endif
#endif

View File

@ -13,20 +13,20 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart3F.cxx,v 1.14 2007-01-01 18:04:45 stephena Exp $ // $Id: Cart3F.cxx,v 1.15 2007-01-14 16:17:52 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "Cart3F.hxx"
#include "System.hxx" #include "System.hxx"
#include "TIA.hxx" #include "TIA.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "Cart3F.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge3F::Cartridge3F(const uInt8* image, uInt32 size) Cartridge3F::Cartridge3F(const uInt8* image, uInt32 size)
: mySize(size) : mySize(size)
{ {
// Allocate array for the ROM image // Allocate array for the ROM image
myImage = new uInt8[mySize]; myImage = new uInt8[mySize];
@ -123,19 +123,57 @@ void Cartridge3F::poke(uInt16 address, uInt8 value)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3F::patch(uInt16 address, uInt8 value) bool Cartridge3F::save(Serializer& out)
{ {
address = address & 0x0FFF; string cart = name();
if(address < 0x0800)
try
{ {
myImage[(address & 0x07FF) + myCurrentBank * 2048] = value; out.putString(cart);
out.putInt(myCurrentBank);
} }
else catch(const char* msg)
{ {
myImage[(address & 0x07FF) + mySize - 2048] = value; cerr << msg << endl;
return false;
} }
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
return true; 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) void Cartridge3F::bank(uInt16 bank)
@ -171,71 +209,35 @@ void Cartridge3F::bank(uInt16 bank)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge3F::bank() { int Cartridge3F::bank()
{
return myCurrentBank; return myCurrentBank;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge3F::bankCount() { int Cartridge3F::bankCount()
return mySize/2048;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3F::save(Serializer& out)
{ {
string cart = name(); return mySize / 2048;
try
{
out.putString(cart);
out.putInt(myCurrentBank);
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge3F::load(Deserializer& in) bool Cartridge3F::patch(uInt16 address, uInt8 value)
{ {
string cart = name(); address = address & 0x0FFF;
if(address < 0x0800)
try
{ {
if(in.getString() != cart) myImage[(address & 0x07FF) + myCurrentBank * 2048] = value;
return false;
myCurrentBank = (uInt16) in.getInt();
} }
catch(char *msg) else
{ {
cerr << msg << endl; myImage[(address & 0x07FF) + mySize - 2048] = value;
return false;
} }
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
// Now, go to the current bank
bank(myCurrentBank);
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge3F::getImage(int& size) { uInt8* Cartridge3F::getImage(int& size)
{
size = mySize; size = mySize;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart3F.hxx,v 1.9 2007-01-01 18:04:45 stephena Exp $ // $Id: Cart3F.hxx,v 1.10 2007-01-14 16:17:52 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGE3F_HXX #ifndef CARTRIDGE3F_HXX
#define CARTRIDGE3F_HXX #define CARTRIDGE3F_HXX
class Cartridge3F; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -37,7 +37,7 @@ class Deserializer;
only used 8K this bankswitching scheme supports up to 512K. only used 8K this bankswitching scheme supports up to 512K.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Cart3F.hxx,v 1.9 2007-01-01 18:04:45 stephena Exp $ @version $Id: Cart3F.hxx,v 1.10 2007-01-14 16:17:52 stephena Exp $
*/ */
class Cartridge3F : public Cartridge class Cartridge3F : public Cartridge
{ {
@ -92,6 +92,42 @@ class Cartridge3F : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size);
public: public:
/** /**
Get the byte at the specified address Get the byte at the specified address
@ -108,20 +144,6 @@ class Cartridge3F : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Map the specified bank into the first segment
@param bank The bank that should be mapped
*/
void bank(uInt16 bank);
int bank();
int bankCount();
virtual uInt8* getImage(int& size);
private: private:
// Indicates which bank is currently active for the first segment // Indicates which bank is currently active for the first segment
uInt16 myCurrentBank; uInt16 myCurrentBank;
@ -132,5 +154,5 @@ class Cartridge3F : public Cartridge
// Size of the ROM image // Size of the ROM image
uInt32 mySize; uInt32 mySize;
}; };
#endif
#endif

View File

@ -13,27 +13,19 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart4A50.cxx,v 1.3 2007-01-01 18:04:45 stephena Exp $ // $Id: Cart4A50.cxx,v 1.4 2007-01-14 16:17:52 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "Cart4A50.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "Cart4A50.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge4A50::Cartridge4A50(const uInt8* image) Cartridge4A50::Cartridge4A50(const uInt8* image)
{ {
cerr << "Cartridge4A50 ctor\n";
/*
// Copy the ROM image into my buffer
for(uInt32 addr = 0; addr < 4096; ++addr)
{
myImage[addr] = image[addr];
}
*/
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -55,31 +47,12 @@ void Cartridge4A50::reset()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4A50::install(System& system) void Cartridge4A50::install(System& system)
{ {
/*
mySystem = &system;
uInt16 shift = mySystem->pageShift();
uInt16 mask = mySystem->pageMask();
// Make sure the system we're being installed in has a page size that'll work
assert((0x1000 & mask) == 0);
System::PageAccess access;
access.directPokeBase = 0;
access.device = this;
// Map ROM image into the system
for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift))
{
access.directPeekBase = &myImage[address & 0x0FFF];
mySystem->setPageAccess(address >> mySystem->pageShift(), access);
}
*/
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 Cartridge4A50::peek(uInt16 address) uInt8 Cartridge4A50::peek(uInt16 address)
{ {
return 0; // myImage[address & 0x0FFF]; return 0;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -87,71 +60,44 @@ void Cartridge4A50::poke(uInt16, uInt8)
{ {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::patch(uInt16 address, uInt8 value)
{
return false;
/*
myImage[address & 0x0FFF] = value;
return true;
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::save(Serializer& out) bool Cartridge4A50::save(Serializer& out)
{ {
/* return false;
string cart = name();
try
{
out.putString(cart);
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
*/
return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::load(Deserializer& in) bool Cartridge4A50::load(Deserializer& in)
{ {
/* return false;
string cart = name();
try
{
if(in.getString() != cart)
return false;
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
*/
return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4A50::bank(uInt16 b)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge4A50::bank()
{
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Cartridge4A50::bankCount()
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::patch(uInt16 address, uInt8 value)
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge4A50::getImage(int& size) uInt8* Cartridge4A50::getImage(int& size)
{ {
/* size = 0;
size = 4096;
return &myImage[0];
*/
return 0; return 0;
} }

View File

@ -13,13 +13,12 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart4A50.hxx,v 1.4 2007-01-01 18:04:45 stephena Exp $ // $Id: Cart4A50.hxx,v 1.5 2007-01-14 16:17:52 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGE4A50_HXX #ifndef CARTRIDGE4A50_HXX
#define CARTRIDGE4A50_HXX #define CARTRIDGE4A50_HXX
class Cartridge4A50;
class System; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -32,7 +31,7 @@ class Deserializer;
not bankswitched. not bankswitched.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Cart4A50.hxx,v 1.4 2007-01-01 18:04:45 stephena Exp $ @version $Id: Cart4A50.hxx,v 1.5 2007-01-14 16:17:52 stephena Exp $
*/ */
class Cartridge4A50 : public Cartridge class Cartridge4A50 : public Cartridge
{ {
@ -86,6 +85,40 @@ class Cartridge4A50 : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -103,12 +136,6 @@ class Cartridge4A50 : public Cartridge
@param value The value to be stored at the address @param value The value to be stored at the address
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
private:
// The 4K ROM image for the cartridge
// uInt8 myImage[4096];
}; };
#endif #endif

View File

@ -13,15 +13,15 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart4K.cxx,v 1.9 2007-01-01 18:04:45 stephena Exp $ // $Id: Cart4K.cxx,v 1.10 2007-01-14 16:17:52 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "Cart4K.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "Cart4K.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge4K::Cartridge4K(const uInt8* image) Cartridge4K::Cartridge4K(const uInt8* image)
@ -83,13 +83,6 @@ void Cartridge4K::poke(uInt16, uInt8)
// This is ROM so poking has no effect :-) // This is ROM so poking has no effect :-)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::patch(uInt16 address, uInt8 value)
{
myImage[address & 0x0FFF] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::save(Serializer& out) bool Cartridge4K::save(Serializer& out)
{ {
@ -99,7 +92,7 @@ bool Cartridge4K::save(Serializer& out)
{ {
out.putString(cart); out.putString(cart);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -123,7 +116,7 @@ bool Cartridge4K::load(Deserializer& in)
if(in.getString() != cart) if(in.getString() != cart)
return false; return false;
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -138,7 +131,34 @@ bool Cartridge4K::load(Deserializer& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge4K::getImage(int& size) { 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; size = 4096;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,12 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Cart4K.hxx,v 1.8 2007-01-01 18:04:45 stephena Exp $ // $Id: Cart4K.hxx,v 1.9 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGE4K_HXX #ifndef CARTRIDGE4K_HXX
#define CARTRIDGE4K_HXX #define CARTRIDGE4K_HXX
class Cartridge4K;
class System; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -32,7 +31,7 @@ class Deserializer;
not bankswitched. not bankswitched.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Cart4K.hxx,v 1.8 2007-01-01 18:04:45 stephena Exp $ @version $Id: Cart4K.hxx,v 1.9 2007-01-14 16:17:53 stephena Exp $
*/ */
class Cartridge4K : public Cartridge class Cartridge4K : public Cartridge
{ {
@ -86,6 +85,40 @@ class Cartridge4K : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -104,11 +137,9 @@ class Cartridge4K : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
private: private:
// The 4K ROM image for the cartridge // The 4K ROM image for the cartridge
uInt8 myImage[4096]; uInt8 myImage[4096];
}; };
#endif
#endif

View File

@ -13,22 +13,21 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartAR.cxx,v 1.17 2007-01-01 18:04:45 stephena Exp $ // $Id: CartAR.cxx,v 1.18 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include <string.h>
#include "CartAR.hxx"
#include "M6502Hi.hxx" #include "M6502Hi.hxx"
#include "Random.hxx" #include "Random.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartAR.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeAR::CartridgeAR(const uInt8* image, uInt32 size, bool fastbios) CartridgeAR::CartridgeAR(const uInt8* image, uInt32 size, bool fastbios)
: my6502(0) : my6502(0)
{ {
uInt32 i; uInt32 i;
@ -197,13 +196,6 @@ void CartridgeAR::poke(uInt16 addr, uInt8)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeAR::patch(uInt16 address, uInt8 value)
{
// myImage[address & 0x0FFF] = value;
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeAR::bankConfiguration(uInt8 configuration) void CartridgeAR::bankConfiguration(uInt8 configuration)
{ {
@ -297,27 +289,6 @@ void CartridgeAR::bankConfiguration(uInt8 configuration)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeAR::bank(uInt16 b)
{
if(bankLocked)
return;
bankConfiguration(b);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeAR::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeAR::bankCount()
{
return 32;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeAR::initializeROM(bool fastbios) void CartridgeAR::initializeROM(bool fastbios)
{ {
@ -510,7 +481,7 @@ bool CartridgeAR::save(Serializer& out)
// Indicates if a write is pending or not // Indicates if a write is pending or not
out.putBool(myWritePending); out.putBool(myWritePending);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -578,7 +549,7 @@ bool CartridgeAR::load(Deserializer& in)
// Indicates if a write is pending or not // Indicates if a write is pending or not
myWritePending = in.getBool(); myWritePending = in.getBool();
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -592,6 +563,33 @@ bool CartridgeAR::load(Deserializer& in)
return true; 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) uInt8* CartridgeAR::getImage(int& size)
{ {

View File

@ -13,14 +13,14 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartAR.hxx,v 1.11 2007-01-01 18:04:45 stephena Exp $ // $Id: CartAR.hxx,v 1.12 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEAR_HXX #ifndef CARTRIDGEAR_HXX
#define CARTRIDGEAR_HXX #define CARTRIDGEAR_HXX
class CartridgeAR;
class M6502High; class M6502High;
class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -37,7 +37,7 @@ class Deserializer;
and one bank of ROM. All 6K of the RAM can be read and written. and one bank of ROM. All 6K of the RAM can be read and written.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartAR.hxx,v 1.11 2007-01-01 18:04:45 stephena Exp $ @version $Id: CartAR.hxx,v 1.12 2007-01-14 16:17:53 stephena Exp $
*/ */
class CartridgeAR : public Cartridge class CartridgeAR : public Cartridge
{ {
@ -100,6 +100,42 @@ class CartridgeAR : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size);
public: public:
/** /**
Get the byte at the specified address Get the byte at the specified address
@ -116,20 +152,6 @@ class CartridgeAR : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Install pages for the specified bank in the system
@param bank The bank that should be installed in the system
*/
void bank(uInt16 bank);
int bank();
int bankCount();
virtual uInt8* getImage(int& size);
private: private:
// Handle a change to the bank configuration // Handle a change to the bank configuration
void bankConfiguration(uInt8 configuration); void bankConfiguration(uInt8 configuration);
@ -182,5 +204,5 @@ class CartridgeAR : public Cartridge
uInt16 myCurrentBank; uInt16 myCurrentBank;
}; };
#endif
#endif

View File

@ -13,16 +13,16 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartCV.cxx,v 1.13 2007-01-01 18:04:45 stephena Exp $ // $Id: CartCV.cxx,v 1.14 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartCV.hxx"
#include "Random.hxx" #include "Random.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartCV.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeCV::CartridgeCV(const uInt8* image, uInt32 size) CartridgeCV::CartridgeCV(const uInt8* image, uInt32 size)
@ -131,13 +131,6 @@ void CartridgeCV::poke(uInt16, uInt8)
// This is ROM so poking has no effect :-) // This is ROM so poking has no effect :-)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeCV::patch(uInt16 address, uInt8 value)
{
myImage[address & 0x07FF] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeCV::save(Serializer& out) bool CartridgeCV::save(Serializer& out)
{ {
@ -152,7 +145,7 @@ bool CartridgeCV::save(Serializer& out)
for(uInt32 addr = 0; addr < 1024; ++addr) for(uInt32 addr = 0; addr < 1024; ++addr)
out.putInt(myRAM[addr]); out.putInt(myRAM[addr]);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -181,7 +174,7 @@ bool CartridgeCV::load(Deserializer& in)
for(uInt32 addr = 0; addr < limit; ++addr) for(uInt32 addr = 0; addr < limit; ++addr)
myRAM[addr] = (uInt8) in.getInt(); myRAM[addr] = (uInt8) in.getInt();
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -195,6 +188,32 @@ bool CartridgeCV::load(Deserializer& in)
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCV::bank(uInt16 bank)
{
// Doesn't support bankswitching
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeCV::bank()
{
// Doesn't support bankswitching
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeCV::bankCount()
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeCV::patch(uInt16 address, uInt8 value)
{
myImage[address & 0x07FF] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeCV::getImage(int& size) uInt8* CartridgeCV::getImage(int& size)
{ {

View File

@ -13,13 +13,12 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartCV.hxx,v 1.8 2007-01-01 18:04:45 stephena Exp $ // $Id: CartCV.hxx,v 1.9 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGECV_HXX #ifndef CARTRIDGECV_HXX
#define CARTRIDGECV_HXX #define CARTRIDGECV_HXX
class CartridgeCV;
class System; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -35,7 +34,7 @@ class Deserializer;
$F800-$FFFF ROM $F800-$FFFF ROM
@author Eckhard Stolberg @author Eckhard Stolberg
@version $Id: CartCV.hxx,v 1.8 2007-01-01 18:04:45 stephena Exp $ @version $Id: CartCV.hxx,v 1.9 2007-01-14 16:17:53 stephena Exp $
*/ */
class CartridgeCV : public Cartridge class CartridgeCV : public Cartridge
{ {
@ -89,6 +88,40 @@ class CartridgeCV : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -107,8 +140,6 @@ class CartridgeCV : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
private: private:
// The 2k ROM image for the cartridge // The 2k ROM image for the cartridge
uInt8 myImage[2048]; uInt8 myImage[2048];
@ -116,5 +147,5 @@ class CartridgeCV : public Cartridge
// The 1024 bytes of RAM // The 1024 bytes of RAM
uInt8 myRAM[1024]; uInt8 myRAM[1024];
}; };
#endif
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartDPC.cxx,v 1.17 2007-01-01 18:04:45 stephena Exp $ // $Id: CartDPC.cxx,v 1.18 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <assert.h>
@ -427,50 +427,6 @@ void CartridgeDPC::poke(uInt16 address, uInt8 value)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeDPC::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myProgramImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDPC::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 Program ROM image into the system
for(uInt32 address = 0x1080; address < (0x1FF8U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myProgramImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeDPC::bank() {
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeDPC::bankCount() {
return 2; // TODO: support the display ROM somehow
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeDPC::save(Serializer& out) bool CartridgeDPC::save(Serializer& out)
{ {
@ -516,7 +472,7 @@ bool CartridgeDPC::save(Serializer& out)
out.putInt(mySystemCycles); out.putInt(mySystemCycles);
out.putInt((uInt32)(myFractionalClocks * 100000000.0)); out.putInt((uInt32)(myFractionalClocks * 100000000.0));
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -577,7 +533,7 @@ bool CartridgeDPC::load(Deserializer& in)
mySystemCycles = in.getInt(); mySystemCycles = in.getInt();
myFractionalClocks = (double)in.getInt() / 100000000.0; myFractionalClocks = (double)in.getInt() / 100000000.0;
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -594,6 +550,51 @@ bool CartridgeDPC::load(Deserializer& in)
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDPC::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 Program ROM image into the system
for(uInt32 address = 0x1080; address < (0x1FF8U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myProgramImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeDPC::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeDPC::bankCount()
{
return 2; // TODO: support the display ROM somehow
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeDPC::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myProgramImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeDPC::getImage(int& size) uInt8* CartridgeDPC::getImage(int& size)
{ {

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartDPC.hxx,v 1.9 2007-01-01 18:04:45 stephena Exp $ // $Id: CartDPC.hxx,v 1.10 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEDCP_HXX #ifndef CARTRIDGEDCP_HXX
#define CARTRIDGEDCP_HXX #define CARTRIDGEDCP_HXX
class CartridgeDPC; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -32,7 +32,7 @@ class Deserializer;
see David P. Crane's United States Patent Number 4,644,495. see David P. Crane's United States Patent Number 4,644,495.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartDPC.hxx,v 1.9 2007-01-01 18:04:45 stephena Exp $ @version $Id: CartDPC.hxx,v 1.10 2007-01-14 16:17:53 stephena Exp $
*/ */
class CartridgeDPC : public Cartridge class CartridgeDPC : public Cartridge
{ {
@ -93,6 +93,40 @@ class CartridgeDPC : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -111,18 +145,7 @@ class CartridgeDPC : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
/**
Install pages for the specified bank in the system
@param bank The bank that should be installed in the system
*/
void bank(uInt16 bank);
int bank(); // get current bank (-1 if no bankswitching supported)
int bankCount(); // count # of banks
bool patch(uInt16 address, uInt8 value);
private: private:
/** /**
Clocks the random number generator to move it to its next state Clocks the random number generator to move it to its next state
*/ */
@ -171,5 +194,5 @@ class CartridgeDPC : public Cartridge
// Fractional DPC music OSC clocks unused during the last update // Fractional DPC music OSC clocks unused during the last update
double myFractionalClocks; double myFractionalClocks;
}; };
#endif
#endif

View File

@ -13,15 +13,15 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartE0.cxx,v 1.12 2007-01-01 18:04:45 stephena Exp $ // $Id: CartE0.cxx,v 1.13 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartE0.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartE0.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeE0::CartridgeE0(const uInt8* image) CartridgeE0::CartridgeE0(const uInt8* image)
@ -136,14 +136,6 @@ void CartridgeE0::poke(uInt16 address, uInt8)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE0::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[(myCurrentSlice[address >> 10] << 10) + (address & 0x03FF)] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeE0::segmentZero(uInt16 slice) void CartridgeE0::segmentZero(uInt16 slice)
{ {
@ -217,7 +209,7 @@ bool CartridgeE0::save(Serializer& out)
for(uInt32 i = 0; i < 4; ++i) for(uInt32 i = 0; i < 4; ++i)
out.putInt(myCurrentSlice[i]); out.putInt(myCurrentSlice[i]);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -245,7 +237,7 @@ bool CartridgeE0::load(Deserializer& in)
for(uInt32 i = 0; i < limit; ++i) for(uInt32 i = 0; i < limit; ++i)
myCurrentSlice[i] = (uInt16) in.getInt(); myCurrentSlice[i] = (uInt16) in.getInt();
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -259,9 +251,37 @@ bool CartridgeE0::load(Deserializer& in)
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeE0::bank(uInt16 bank)
{
// FIXME - get this working, so we can debug E0 carts
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeE0::getImage(int& size) { 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; size = 8192;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartE0.hxx,v 1.8 2007-01-01 18:04:46 stephena Exp $ // $Id: CartE0.hxx,v 1.9 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEE0_HXX #ifndef CARTRIDGEE0_HXX
#define CARTRIDGEE0_HXX #define CARTRIDGEE0_HXX
class CartridgeF8; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -36,7 +36,7 @@ class Deserializer;
always points to the last 1K of the ROM image. always points to the last 1K of the ROM image.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartE0.hxx,v 1.8 2007-01-01 18:04:46 stephena Exp $ @version $Id: CartE0.hxx,v 1.9 2007-01-14 16:17:53 stephena Exp $
*/ */
class CartridgeE0 : public Cartridge class CartridgeE0 : public Cartridge
{ {
@ -90,6 +90,40 @@ class CartridgeE0 : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -108,8 +142,6 @@ class CartridgeE0 : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
private: private:
/** /**
Install the specified slice for segment zero Install the specified slice for segment zero
@ -139,5 +171,5 @@ class CartridgeE0 : public Cartridge
// The 8K ROM image of the cartridge // The 8K ROM image of the cartridge
uInt8 myImage[8192]; uInt8 myImage[8192];
}; };
#endif
#endif

View File

@ -13,16 +13,16 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartE7.cxx,v 1.15 2007-01-01 18:04:46 stephena Exp $ // $Id: CartE7.cxx,v 1.16 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartE7.hxx"
#include "Random.hxx" #include "Random.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartE7.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeE7::CartridgeE7(const uInt8* image) CartridgeE7::CartridgeE7(const uInt8* image)
@ -137,74 +137,6 @@ void CartridgeE7::poke(uInt16 address, uInt8)
// way page accessing has been setup // way page accessing has been setup
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE7::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[(myCurrentSlice[address >> 11] << 11) + (address & 0x07FF)] = value;
bank(myCurrentSlice[0]);
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeE7::bank(uInt16 slice)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentSlice[0] = slice;
uInt16 offset = slice << 11;
uInt16 shift = mySystem->pageShift();
// Setup the page access methods for the current bank
if(slice != 7)
{
System::PageAccess access;
access.device = this;
access.directPokeBase = 0;
// Map ROM image into first segment
for(uInt32 address = 0x1000; address < 0x1800; address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x07FF)];
mySystem->setPageAccess(address >> shift, access);
}
}
else
{
System::PageAccess access;
access.device = this;
// Set the page accessing method for the 1K slice of RAM writing pages
access.directPeekBase = 0;
access.directPokeBase = 0;
for(uInt32 j = 0x1000; j < 0x1400; j += (1 << shift))
{
access.directPokeBase = &myRAM[j & 0x03FF];
mySystem->setPageAccess(j >> shift, access);
}
// Set the page accessing method for the 1K slice of RAM reading pages
access.directPeekBase = 0;
access.directPokeBase = 0;
for(uInt32 k = 0x1400; k < 0x1800; k += (1 << shift))
{
access.directPeekBase = &myRAM[k & 0x03FF];
mySystem->setPageAccess(k >> shift, access);
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeE7::bank() {
return myCurrentSlice[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeE7::bankCount() {
return 8;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeE7::bankRAM(uInt16 bank) void CartridgeE7::bankRAM(uInt16 bank)
{ {
@ -258,7 +190,7 @@ bool CartridgeE7::save(Serializer& out)
for(i = 0; i < 2048; ++i) for(i = 0; i < 2048; ++i)
out.putInt(myRAM[i]); out.putInt(myRAM[i]);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -295,7 +227,7 @@ bool CartridgeE7::load(Deserializer& in)
for(i = 0; i < limit; ++i) for(i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt(); myRAM[i] = (uInt8) in.getInt();
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -314,7 +246,78 @@ bool CartridgeE7::load(Deserializer& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeE7::getImage(int& size) { void CartridgeE7::bank(uInt16 slice)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentSlice[0] = slice;
uInt16 offset = slice << 11;
uInt16 shift = mySystem->pageShift();
// Setup the page access methods for the current bank
if(slice != 7)
{
System::PageAccess access;
access.device = this;
access.directPokeBase = 0;
// Map ROM image into first segment
for(uInt32 address = 0x1000; address < 0x1800; address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x07FF)];
mySystem->setPageAccess(address >> shift, access);
}
}
else
{
System::PageAccess access;
access.device = this;
// Set the page accessing method for the 1K slice of RAM writing pages
access.directPeekBase = 0;
access.directPokeBase = 0;
for(uInt32 j = 0x1000; j < 0x1400; j += (1 << shift))
{
access.directPokeBase = &myRAM[j & 0x03FF];
mySystem->setPageAccess(j >> shift, access);
}
// Set the page accessing method for the 1K slice of RAM reading pages
access.directPeekBase = 0;
access.directPokeBase = 0;
for(uInt32 k = 0x1400; k < 0x1800; k += (1 << shift))
{
access.directPeekBase = &myRAM[k & 0x03FF];
mySystem->setPageAccess(k >> shift, access);
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeE7::bank()
{
return myCurrentSlice[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeE7::bankCount()
{
return 8;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE7::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[(myCurrentSlice[address >> 11] << 11) + (address & 0x07FF)] = value;
bank(myCurrentSlice[0]);
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeE7::getImage(int& size)
{
size = 16384; size = 16384;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartE7.hxx,v 1.9 2007-01-01 18:04:46 stephena Exp $ // $Id: CartE7.hxx,v 1.10 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEE7_HXX #ifndef CARTRIDGEE7_HXX
#define CARTRIDGEE7_HXX #define CARTRIDGEE7_HXX
class CartridgeE7; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -53,7 +53,7 @@ class Deserializer;
here by accessing 1FF8 to 1FFB. here by accessing 1FF8 to 1FFB.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartE7.hxx,v 1.9 2007-01-01 18:04:46 stephena Exp $ @version $Id: CartE7.hxx,v 1.10 2007-01-14 16:17:53 stephena Exp $
*/ */
class CartridgeE7 : public Cartridge class CartridgeE7 : public Cartridge
{ {
@ -107,6 +107,40 @@ class CartridgeE7 : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -125,18 +159,6 @@ class CartridgeE7 : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Map the specfied bank into the first segment
@param bank The bank that should be installed in the system
*/
void bank(uInt16 bank);
int bank();
int bankCount();
private: private:
/** /**
Install pages for the specified 256 byte bank of RAM Install pages for the specified 256 byte bank of RAM
@ -158,5 +180,5 @@ class CartridgeE7 : public Cartridge
// The 2048 bytes of RAM // The 2048 bytes of RAM
uInt8 myRAM[2048]; uInt8 myRAM[2048];
}; };
#endif
#endif

View File

@ -13,16 +13,16 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF4.cxx,v 1.10 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF4.cxx,v 1.11 2007-01-14 16:17:53 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include <iostream>
#include "CartF4.hxx"
#include "Random.hxx" #include "Random.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include "CartF4.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeF4::CartridgeF4(const uInt8* image) CartridgeF4::CartridgeF4(const uInt8* image)
@ -102,49 +102,6 @@ void CartridgeF4::poke(uInt16 address, uInt8)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
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::save(Serializer& out) bool CartridgeF4::save(Serializer& out)
{ {
@ -155,7 +112,7 @@ bool CartridgeF4::save(Serializer& out)
out.putString(cart); out.putString(cart);
out.putInt(myCurrentBank); out.putInt(myCurrentBank);
} }
catch(char* msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -183,7 +140,7 @@ bool CartridgeF4::load(Deserializer& in)
myCurrentBank = (uInt16)in.getInt(); myCurrentBank = (uInt16)in.getInt();
} }
catch(char* msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -200,9 +157,54 @@ bool CartridgeF4::load(Deserializer& in)
return true; 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);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF4::getImage(int& size) { 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; size = 32768;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF4.hxx,v 1.7 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF4.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEF4_HXX #ifndef CARTRIDGEF4_HXX
#define CARTRIDGEF4_HXX #define CARTRIDGEF4_HXX
class CartridgeF4; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -31,7 +31,7 @@ class Deserializer;
are eight 4K banks. are eight 4K banks.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartF4.hxx,v 1.7 2007-01-01 18:04:46 stephena Exp $ @version $Id: CartF4.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
*/ */
class CartridgeF4 : public Cartridge class CartridgeF4 : public Cartridge
{ {
@ -85,6 +85,40 @@ class CartridgeF4 : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -103,19 +137,6 @@ class CartridgeF4 : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Install pages for the specified bank in the system
@param bank The bank that should be installed in the system
*/
void bank(uInt16 bank);
int bank();
int bankCount();
private: private:
// Indicates which bank is currently active // Indicates which bank is currently active
uInt16 myCurrentBank; uInt16 myCurrentBank;
@ -123,5 +144,5 @@ class CartridgeF4 : public Cartridge
// The 16K ROM image of the cartridge // The 16K ROM image of the cartridge
uInt8 myImage[32768]; uInt8 myImage[32768];
}; };
#endif
#endif

View File

@ -13,16 +13,16 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF4SC.cxx,v 1.13 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF4SC.cxx,v 1.14 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartF4SC.hxx"
#include "Random.hxx" #include "Random.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartF4SC.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeF4SC::CartridgeF4SC(const uInt8* image) CartridgeF4SC::CartridgeF4SC(const uInt8* image)
@ -132,49 +132,6 @@ void CartridgeF4SC::poke(uInt16 address, uInt8)
// has been setup // has been setup
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4SC::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF4SC::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 = 0x1100; address < (0x1FF4U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF4SC::bank() {
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF4SC::bankCount() {
return 8;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4SC::save(Serializer& out) bool CartridgeF4SC::save(Serializer& out)
{ {
@ -191,7 +148,7 @@ bool CartridgeF4SC::save(Serializer& out)
for(uInt32 i = 0; i < 128; ++i) for(uInt32 i = 0; i < 128; ++i)
out.putInt(myRAM[i]); out.putInt(myRAM[i]);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -221,7 +178,7 @@ bool CartridgeF4SC::load(Deserializer& in)
for(uInt32 i = 0; i < limit; ++i) for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt(); myRAM[i] = (uInt8) in.getInt();
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -239,7 +196,53 @@ bool CartridgeF4SC::load(Deserializer& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF4SC::getImage(int& size) { void CartridgeF4SC::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 = 0x1100; address < (0x1FF4U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF4SC::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF4SC::bankCount()
{
return 8;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4SC::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF4SC::getImage(int& size)
{
size = 32768; size = 32768;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF4SC.hxx,v 1.8 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF4SC.hxx,v 1.9 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEF4SC_HXX #ifndef CARTRIDGEF4SC_HXX
#define CARTRIDGEF4SC_HXX #define CARTRIDGEF4SC_HXX
class CartridgeF4SC; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -31,7 +31,7 @@ class Deserializer;
128 bytes of RAM. There are eight 4K banks. 128 bytes of RAM. There are eight 4K banks.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartF4SC.hxx,v 1.8 2007-01-01 18:04:46 stephena Exp $ @version $Id: CartF4SC.hxx,v 1.9 2007-01-14 16:17:54 stephena Exp $
*/ */
class CartridgeF4SC : public Cartridge class CartridgeF4SC : public Cartridge
{ {
@ -85,6 +85,40 @@ class CartridgeF4SC : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -103,18 +137,6 @@ class CartridgeF4SC : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Install pages for the specified bank in the system
@param bank The bank that should be installed in the system
*/
void bank(uInt16 bank);
int bank();
int bankCount();
private: private:
// Indicates which bank is currently active // Indicates which bank is currently active
uInt16 myCurrentBank; uInt16 myCurrentBank;
@ -125,5 +147,5 @@ class CartridgeF4SC : public Cartridge
// The 128 bytes of RAM // The 128 bytes of RAM
uInt8 myRAM[128]; uInt8 myRAM[128];
}; };
#endif
#endif

View File

@ -13,15 +13,15 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF6.cxx,v 1.12 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF6.cxx,v 1.13 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartF6.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartF6.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeF6::CartridgeF6(const uInt8* image) CartridgeF6::CartridgeF6(const uInt8* image)
@ -144,12 +144,58 @@ void CartridgeF6::poke(uInt16 address, uInt8)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6::patch(uInt16 address, uInt8 value) bool CartridgeF6::save(Serializer& out)
{ {
address = address & 0x0FFF; string cart = name();
myImage[myCurrentBank * 4096 + address] = value;
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; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6::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 CartridgeF6::bank(uInt16 bank) void CartridgeF6::bank(uInt16 bank)
@ -177,71 +223,28 @@ void CartridgeF6::bank(uInt16 bank)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF6::bank() { int CartridgeF6::bank()
{
return myCurrentBank; return myCurrentBank;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF6::bankCount() { int CartridgeF6::bankCount()
{
return 4; return 4;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6::save(Serializer& out) bool CartridgeF6::patch(uInt16 address, uInt8 value)
{ {
string cart = name(); address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
try
{
out.putString(cart);
out.putInt(myCurrentBank);
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6::load(Deserializer& in) uInt8* CartridgeF6::getImage(int& size)
{ {
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
// Remember what bank we were in
bank(myCurrentBank);
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF6::getImage(int& size) {
size = 16384; size = 16384;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF6.hxx,v 1.9 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF6.hxx,v 1.10 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEF6_HXX #ifndef CARTRIDGEF6_HXX
#define CARTRIDGEF6_HXX #define CARTRIDGEF6_HXX
class CartridgeF6; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -31,7 +31,7 @@ class Deserializer;
are four 4K banks. are four 4K banks.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartF6.hxx,v 1.9 2007-01-01 18:04:46 stephena Exp $ @version $Id: CartF6.hxx,v 1.10 2007-01-14 16:17:54 stephena Exp $
*/ */
class CartridgeF6 : public Cartridge class CartridgeF6 : public Cartridge
{ {
@ -85,6 +85,40 @@ class CartridgeF6 : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -103,18 +137,6 @@ class CartridgeF6 : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Install pages for the specified bank in the system
@param bank The bank that should be installed in the system
*/
void bank(uInt16 bank);
int bank();
int bankCount();
private: private:
// Indicates which bank is currently active // Indicates which bank is currently active
uInt16 myCurrentBank; uInt16 myCurrentBank;
@ -122,5 +144,5 @@ class CartridgeF6 : public Cartridge
// The 16K ROM image of the cartridge // The 16K ROM image of the cartridge
uInt8 myImage[16384]; uInt8 myImage[16384];
}; };
#endif
#endif

View File

@ -13,16 +13,16 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF6SC.cxx,v 1.12 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF6SC.cxx,v 1.13 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartF6SC.hxx"
#include "Random.hxx" #include "Random.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartF6SC.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeF6SC::CartridgeF6SC(const uInt8* image) CartridgeF6SC::CartridgeF6SC(const uInt8* image)
@ -176,49 +176,6 @@ void CartridgeF6SC::poke(uInt16 address, uInt8)
// has been setup // has been setup
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6SC::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF6SC::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 = 0x1100; address < (0x1FF6U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF6SC::bank() {
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF6SC::bankCount() {
return 4;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6SC::save(Serializer& out) bool CartridgeF6SC::save(Serializer& out)
{ {
@ -236,7 +193,7 @@ bool CartridgeF6SC::save(Serializer& out)
out.putInt(myRAM[i]); out.putInt(myRAM[i]);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -267,7 +224,7 @@ bool CartridgeF6SC::load(Deserializer& in)
for(uInt32 i = 0; i < limit; ++i) for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt(); myRAM[i] = (uInt8) in.getInt();
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -285,7 +242,53 @@ bool CartridgeF6SC::load(Deserializer& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF6SC::getImage(int& size) { void CartridgeF6SC::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 = 0x1100; address < (0x1FF6U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF6SC::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF6SC::bankCount()
{
return 4;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6SC::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF6SC::getImage(int& size)
{
size = 16384; size = 16384;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF6SC.hxx,v 1.8 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF6SC.hxx,v 1.9 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEF6SC_HXX #ifndef CARTRIDGEF6SC_HXX
#define CARTRIDGEF6SC_HXX #define CARTRIDGEF6SC_HXX
class CartridgeF6SC; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -31,7 +31,7 @@ class Deserializer;
128 bytes of RAM. There are four 4K banks. 128 bytes of RAM. There are four 4K banks.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartF6SC.hxx,v 1.8 2007-01-01 18:04:46 stephena Exp $ @version $Id: CartF6SC.hxx,v 1.9 2007-01-14 16:17:54 stephena Exp $
*/ */
class CartridgeF6SC : public Cartridge class CartridgeF6SC : public Cartridge
{ {
@ -85,6 +85,40 @@ class CartridgeF6SC : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -103,18 +137,6 @@ class CartridgeF6SC : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Install pages for the specified bank in the system
@param bank The bank that should be installed in the system
*/
void bank(uInt16 bank);
int bank();
int bankCount();
private: private:
// Indicates which bank is currently active // Indicates which bank is currently active
uInt16 myCurrentBank; uInt16 myCurrentBank;
@ -125,5 +147,5 @@ class CartridgeF6SC : public Cartridge
// The 128 bytes of RAM // The 128 bytes of RAM
uInt8 myRAM[128]; uInt8 myRAM[128];
}; };
#endif
#endif

View File

@ -13,15 +13,15 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF8.cxx,v 1.14 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF8.cxx,v 1.15 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartF8.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartF8.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeF8::CartridgeF8(const uInt8* image, bool swapbanks) CartridgeF8::CartridgeF8(const uInt8* image, bool swapbanks)
@ -32,6 +32,8 @@ CartridgeF8::CartridgeF8(const uInt8* image, bool swapbanks)
myImage[addr] = image[addr]; myImage[addr] = image[addr];
} }
// Normally bank 1 is the reset bank, unless we're dealing with ROMs
// that have been incorrectly created with banks in the opposite order
myResetBank = swapbanks ? 0 : 1; myResetBank = swapbanks ? 0 : 1;
} }
@ -49,7 +51,7 @@ const char* CartridgeF8::name() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF8::reset() void CartridgeF8::reset()
{ {
// Upon reset we switch to the reset bank (normally bank 1) // Upon reset we switch to the reset bank
bank(myResetBank); bank(myResetBank);
} }
@ -126,13 +128,58 @@ void CartridgeF8::poke(uInt16 address, uInt8)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8::patch(uInt16 address, uInt8 value) bool CartridgeF8::save(Serializer& out)
{ {
address &= 0xfff; string cart = name();
myImage[myCurrentBank * 4096 + address] = value;
bank(myCurrentBank); try
return true; {
} 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) void CartridgeF8::bank(uInt16 bank)
@ -159,60 +206,6 @@ void CartridgeF8::bank(uInt16 bank)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8::save(Serializer& out)
{
string cart = name();
try
{
out.putString(cart);
out.putInt(myCurrentBank);
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8::load(Deserializer& in)
{
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16) in.getInt();
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
// Remember what bank we were in
bank(myCurrentBank);
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF8::bank() int CartridgeF8::bank()
{ {
@ -225,6 +218,15 @@ int CartridgeF8::bankCount()
return 2; return 2;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8::patch(uInt16 address, uInt8 value)
{
address &= 0xfff;
myImage[myCurrentBank * 4096 + address] = value;
bank(myCurrentBank);
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF8::getImage(int& size) uInt8* CartridgeF8::getImage(int& size)
{ {

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF8.hxx,v 1.9 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF8.hxx,v 1.10 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEF8_HXX #ifndef CARTRIDGEF8_HXX
#define CARTRIDGEF8_HXX #define CARTRIDGEF8_HXX
class CartridgeF8; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -31,7 +31,7 @@ class Deserializer;
are two 4K banks. are two 4K banks.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartF8.hxx,v 1.9 2007-01-01 18:04:46 stephena Exp $ @version $Id: CartF8.hxx,v 1.10 2007-01-14 16:17:54 stephena Exp $
*/ */
class CartridgeF8 : public Cartridge class CartridgeF8 : public Cartridge
{ {
@ -86,6 +86,40 @@ class CartridgeF8 : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -104,17 +138,6 @@ class CartridgeF8 : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Install pages for the specified bank in the system
@param bank The bank that should be installed in the system
*/
void bank(uInt16 bank);
int bank();
int bankCount();
private: private:
// Indicates which bank is currently active // Indicates which bank is currently active
uInt16 myCurrentBank; uInt16 myCurrentBank;
@ -125,5 +148,5 @@ class CartridgeF8 : public Cartridge
// The 8K ROM image of the cartridge // The 8K ROM image of the cartridge
uInt8 myImage[8192]; uInt8 myImage[8192];
}; };
#endif
#endif

View File

@ -13,16 +13,16 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF8SC.cxx,v 1.12 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF8SC.cxx,v 1.13 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartF8SC.hxx"
#include "Random.hxx" #include "Random.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartF8SC.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeF8SC::CartridgeF8SC(const uInt8* image) CartridgeF8SC::CartridgeF8SC(const uInt8* image)
@ -160,49 +160,6 @@ void CartridgeF8SC::poke(uInt16 address, uInt8)
// has been setup // has been setup
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF8SC::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF8SC::bankCount()
{
return 2;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8SC::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF8SC::bank(uInt16 bank)
{
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank << 12;
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 = 0x1100; address < (0x1FF8U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8SC::save(Serializer& out) bool CartridgeF8SC::save(Serializer& out)
{ {
@ -219,7 +176,7 @@ bool CartridgeF8SC::save(Serializer& out)
for(uInt32 i = 0; i < 128; ++i) for(uInt32 i = 0; i < 128; ++i)
out.putInt(myRAM[i]); out.putInt(myRAM[i]);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -249,7 +206,7 @@ bool CartridgeF8SC::load(Deserializer& in)
for(uInt32 i = 0; i < limit; ++i) for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt(); myRAM[i] = (uInt8) in.getInt();
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -266,6 +223,51 @@ bool CartridgeF8SC::load(Deserializer& in)
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF8SC::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank << 12;
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 = 0x1100; address < (0x1FF8U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF8SC::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeF8SC::bankCount()
{
return 2;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF8SC::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeF8SC::getImage(int& size) uInt8* CartridgeF8SC::getImage(int& size)
{ {

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartF8SC.hxx,v 1.7 2007-01-01 18:04:46 stephena Exp $ // $Id: CartF8SC.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEF8SC_HXX #ifndef CARTRIDGEF8SC_HXX
#define CARTRIDGEF8SC_HXX #define CARTRIDGEF8SC_HXX
class CartridgeF8SC; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -31,7 +31,7 @@ class Deserializer;
128 bytes of RAM. There are two 4K banks. 128 bytes of RAM. There are two 4K banks.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartF8SC.hxx,v 1.7 2007-01-01 18:04:46 stephena Exp $ @version $Id: CartF8SC.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
*/ */
class CartridgeF8SC : public Cartridge class CartridgeF8SC : public Cartridge
{ {
@ -85,6 +85,40 @@ class CartridgeF8SC : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -103,19 +137,6 @@ class CartridgeF8SC : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Install pages for the specified bank in the system
@param bank The bank that should be installed in the system
*/
void bank(uInt16 bank);
int bank();
int bankCount();
private: private:
// Indicates which bank is currently active // Indicates which bank is currently active
uInt16 myCurrentBank; uInt16 myCurrentBank;
@ -126,5 +147,5 @@ class CartridgeF8SC : public Cartridge
// The 128 bytes of RAM // The 128 bytes of RAM
uInt8 myRAM[128]; uInt8 myRAM[128];
}; };
#endif
#endif

View File

@ -13,16 +13,16 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartFASC.cxx,v 1.11 2007-01-01 18:04:46 stephena Exp $ // $Id: CartFASC.cxx,v 1.12 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartFASC.hxx"
#include "Random.hxx" #include "Random.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartFASC.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeFASC::CartridgeFASC(const uInt8* image) CartridgeFASC::CartridgeFASC(const uInt8* image)
@ -166,49 +166,6 @@ void CartridgeFASC::poke(uInt16 address, uInt8)
// has been setup // has been setup
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFASC::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeFASC::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 = 0x1200; address < (0x1FF8U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeFASC::bank() {
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeFASC::bankCount() {
return 3;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFASC::save(Serializer& out) bool CartridgeFASC::save(Serializer& out)
{ {
@ -225,7 +182,7 @@ bool CartridgeFASC::save(Serializer& out)
for(uInt32 i = 0; i < 256; ++i) for(uInt32 i = 0; i < 256; ++i)
out.putInt(myRAM[i]); out.putInt(myRAM[i]);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -255,7 +212,7 @@ bool CartridgeFASC::load(Deserializer& in)
for(uInt32 i = 0; i < limit; ++i) for(uInt32 i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt(); myRAM[i] = (uInt8) in.getInt();
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -273,7 +230,53 @@ bool CartridgeFASC::load(Deserializer& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeFASC::getImage(int& size) { void CartridgeFASC::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 = 0x1200; address < (0x1FF8U & ~mask);
address += (1 << shift))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> shift, access);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeFASC::bank()
{
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeFASC::bankCount()
{
return 3;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFASC::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeFASC::getImage(int& size)
{
size = 12288; size = 12288;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartFASC.hxx,v 1.7 2007-01-01 18:04:46 stephena Exp $ // $Id: CartFASC.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEFASC_HXX #ifndef CARTRIDGEFASC_HXX
#define CARTRIDGEFASC_HXX #define CARTRIDGEFASC_HXX
class CartridgeFASC; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -31,7 +31,7 @@ class Deserializer;
three 4K banks and 256 bytes of RAM. three 4K banks and 256 bytes of RAM.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartFASC.hxx,v 1.7 2007-01-01 18:04:46 stephena Exp $ @version $Id: CartFASC.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
*/ */
class CartridgeFASC : public Cartridge class CartridgeFASC : public Cartridge
{ {
@ -85,6 +85,40 @@ class CartridgeFASC : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -103,18 +137,6 @@ class CartridgeFASC : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Install pages for the specified bank in the system
@param bank The bank that should be installed in the system
*/
void bank(uInt16 bank);
int bank();
int bankCount();
private: private:
// Indicates which bank is currently active // Indicates which bank is currently active
uInt16 myCurrentBank; uInt16 myCurrentBank;
@ -125,5 +147,5 @@ class CartridgeFASC : public Cartridge
// The 256 bytes of RAM on the cartridge // The 256 bytes of RAM on the cartridge
uInt8 myRAM[256]; uInt8 myRAM[256];
}; };
#endif
#endif

View File

@ -13,15 +13,15 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartFE.cxx,v 1.7 2007-01-01 18:04:46 stephena Exp $ // $Id: CartFE.cxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartFE.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartFE.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeFE::CartridgeFE(const uInt8* image) CartridgeFE::CartridgeFE(const uInt8* image)
@ -82,13 +82,6 @@ void CartridgeFE::poke(uInt16, uInt8)
{ {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFE::patch(uInt16 address, uInt8 value)
{
myImage[(address & 0x0FFF) + (((address & 0x2000) == 0) ? 4096 : 0)] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFE::save(Serializer& out) bool CartridgeFE::save(Serializer& out)
{ {
@ -98,7 +91,7 @@ bool CartridgeFE::save(Serializer& out)
{ {
out.putString(cart); out.putString(cart);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -122,7 +115,7 @@ bool CartridgeFE::load(Deserializer& in)
if(in.getString() != cart) if(in.getString() != cart)
return false; return false;
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -137,7 +130,34 @@ bool CartridgeFE::load(Deserializer& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeFE::getImage(int& size) { 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; size = 8192;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartFE.hxx,v 1.7 2007-01-01 18:04:46 stephena Exp $ // $Id: CartFE.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEFE_HXX #ifndef CARTRIDGEFE_HXX
#define CARTRIDGEFE_HXX #define CARTRIDGEFE_HXX
class CartridgeFE; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -43,7 +43,7 @@ class Deserializer;
monitoring the bus. monitoring the bus.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartFE.hxx,v 1.7 2007-01-01 18:04:46 stephena Exp $ @version $Id: CartFE.hxx,v 1.8 2007-01-14 16:17:54 stephena Exp $
*/ */
class CartridgeFE : public Cartridge class CartridgeFE : public Cartridge
{ {
@ -97,6 +97,40 @@ class CartridgeFE : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -115,11 +149,9 @@ class CartridgeFE : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
private: private:
// The 8K ROM image of the cartridge // The 8K ROM image of the cartridge
uInt8 myImage[8192]; uInt8 myImage[8192];
}; };
#endif
#endif

View File

@ -13,15 +13,15 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartMB.cxx,v 1.10 2007-01-01 18:04:46 stephena Exp $ // $Id: CartMB.cxx,v 1.11 2007-01-14 16:17:55 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartMB.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartMB.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeMB::CartridgeMB(const uInt8* image) CartridgeMB::CartridgeMB(const uInt8* image)
@ -97,14 +97,6 @@ void CartridgeMB::poke(uInt16 address, uInt8)
if(address == 0x0FF0) incbank(); if(address == 0x0FF0) incbank();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMB::patch(uInt16 address, uInt8 value)
{
address = address & 0x0FFF;
myImage[myCurrentBank * 4096 + address] = value;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeMB::incbank() void CartridgeMB::incbank()
{ {
@ -131,22 +123,6 @@ void CartridgeMB::incbank()
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeMB::bank(uInt16 b) {
myCurrentBank = (b - 1);
incbank();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeMB::bank() {
return myCurrentBank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeMB::bankCount() {
return 16;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMB::save(Serializer& out) bool CartridgeMB::save(Serializer& out)
{ {
@ -158,7 +134,7 @@ bool CartridgeMB::save(Serializer& out)
out.putInt(myCurrentBank); out.putInt(myCurrentBank);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -184,7 +160,7 @@ bool CartridgeMB::load(Deserializer& in)
myCurrentBank = (uInt16) in.getInt(); myCurrentBank = (uInt16) in.getInt();
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -203,7 +179,37 @@ bool CartridgeMB::load(Deserializer& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeMB::getImage(int& size) { 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; size = 65536;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartMB.hxx,v 1.7 2007-01-01 18:04:46 stephena Exp $ // $Id: CartMB.hxx,v 1.8 2007-01-14 16:17:55 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEMB_HXX #ifndef CARTRIDGEMB_HXX
#define CARTRIDGEMB_HXX #define CARTRIDGEMB_HXX
class CartridgeMB; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -32,7 +32,7 @@ class Deserializer;
Accessing $1FF0 switches to next bank. Accessing $1FF0 switches to next bank.
@author Eckhard Stolberg @author Eckhard Stolberg
@version $Id: CartMB.hxx,v 1.7 2007-01-01 18:04:46 stephena Exp $ @version $Id: CartMB.hxx,v 1.8 2007-01-14 16:17:55 stephena Exp $
*/ */
class CartridgeMB : public Cartridge class CartridgeMB : public Cartridge
{ {
@ -86,6 +86,40 @@ class CartridgeMB : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -104,14 +138,6 @@ class CartridgeMB : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
void bank(uInt16 b);
int bank();
int bankCount();
private: private:
/** /**
Install pages for the next bank in the system Install pages for the next bank in the system
@ -125,5 +151,5 @@ class CartridgeMB : public Cartridge
// The 64K ROM image of the cartridge // The 64K ROM image of the cartridge
uInt8 myImage[65536]; uInt8 myImage[65536];
}; };
#endif
#endif

View File

@ -13,20 +13,20 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartMC.cxx,v 1.11 2007-01-01 18:04:47 stephena Exp $ // $Id: CartMC.cxx,v 1.12 2007-01-14 16:17:55 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "CartMC.hxx"
#include "Random.hxx" #include "Random.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include <iostream> #include "CartMC.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeMC::CartridgeMC(const uInt8* image, uInt32 size) CartridgeMC::CartridgeMC(const uInt8* image, uInt32 size)
: mySlot3Locked(false) : mySlot3Locked(false)
{ {
uInt32 i; uInt32 i;
@ -219,13 +219,6 @@ void CartridgeMC::poke(uInt16 address, uInt8 value)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMC::patch(uInt16 address, uInt8 value)
{
// TODO: implement
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMC::save(Serializer& out) bool CartridgeMC::save(Serializer& out)
{ {
@ -246,7 +239,7 @@ bool CartridgeMC::save(Serializer& out)
for(i = 0; i < 32 * 1024; ++i) for(i = 0; i < 32 * 1024; ++i)
out.putInt(myRAM[i]); out.putInt(myRAM[i]);
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -283,7 +276,7 @@ bool CartridgeMC::load(Deserializer& in)
for(i = 0; i < limit; ++i) for(i = 0; i < limit; ++i)
myRAM[i] = (uInt8) in.getInt(); myRAM[i] = (uInt8) in.getInt();
} }
catch(char *msg) catch(const char* msg)
{ {
cerr << msg << endl; cerr << msg << endl;
return false; return false;
@ -298,7 +291,35 @@ bool CartridgeMC::load(Deserializer& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeMC::getImage(int& size) { void CartridgeMC::bank(uInt16 b)
{
// TODO: add support for debugger
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeMC::bank()
{
// TODO: add support for debugger
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeMC::bankCount()
{
// TODO: add support for debugger
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMC::patch(uInt16 address, uInt8 value)
{
// TODO: implement
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeMC::getImage(int& size)
{
size = 128 * 1024; // FIXME: keep track of original size size = 128 * 1024; // FIXME: keep track of original size
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartMC.hxx,v 1.7 2007-01-01 18:04:47 stephena Exp $ // $Id: CartMC.hxx,v 1.8 2007-01-14 16:17:55 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEMC_HXX #ifndef CARTRIDGEMC_HXX
#define CARTRIDGEMC_HXX #define CARTRIDGEMC_HXX
class CartridgeMC; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -135,7 +135,7 @@ class Deserializer;
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartMC.hxx,v 1.7 2007-01-01 18:04:47 stephena Exp $ @version $Id: CartMC.hxx,v 1.8 2007-01-14 16:17:55 stephena Exp $
*/ */
class CartridgeMC : public Cartridge class CartridgeMC : public Cartridge
{ {
@ -192,6 +192,40 @@ class CartridgeMC : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -210,8 +244,6 @@ class CartridgeMC : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
private: private:
// Indicates which block is currently active for the four segments // Indicates which block is currently active for the four segments
uInt8 myCurrentBlock[4]; uInt8 myCurrentBlock[4];
@ -225,4 +257,5 @@ class CartridgeMC : public Cartridge
// Pointer to the 128K bytes of ROM for the cartridge // Pointer to the 128K bytes of ROM for the cartridge
uInt8* myImage; uInt8* myImage;
}; };
#endif #endif

View File

@ -13,15 +13,15 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartUA.cxx,v 1.9 2007-01-01 18:04:47 stephena Exp $ // $Id: CartUA.cxx,v 1.10 2007-01-14 16:17:55 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
#include <iostream>
#include "CartUA.hxx"
#include "System.hxx" #include "System.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include "CartUA.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeUA::CartridgeUA(const uInt8* image) CartridgeUA::CartridgeUA(const uInt8* image)
@ -138,13 +138,58 @@ void CartridgeUA::poke(uInt16 address, uInt8 value)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeUA::patch(uInt16 address, uInt8 value) bool CartridgeUA::save(Serializer& out)
{ {
address &= 0x0fff; string cart = name();
myImage[myCurrentBank * 4096] = value;
bank(myCurrentBank); // TODO: see if this is really necessary try
return true; {
} 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 CartridgeUA::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 CartridgeUA::bank(uInt16 bank) void CartridgeUA::bank(uInt16 bank)
@ -171,72 +216,29 @@ void CartridgeUA::bank(uInt16 bank)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeUA::bank() { int CartridgeUA::bank()
{
return myCurrentBank; return myCurrentBank;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeUA::bankCount() { int CartridgeUA::bankCount()
{
return 2; return 2;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeUA::save(Serializer& out) bool CartridgeUA::patch(uInt16 address, uInt8 value)
{ {
string cart = name(); address &= 0x0fff;
myImage[myCurrentBank * 4096] = value;
try bank(myCurrentBank); // TODO: see if this is really necessary
{
out.putString(cart);
out.putInt(myCurrentBank);
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeUA::load(Deserializer& in) uInt8* CartridgeUA::getImage(int& size)
{ {
string cart = name();
try
{
if(in.getString() != cart)
return false;
myCurrentBank = (uInt16)in.getInt();
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
// Remember what bank we were in
bank(myCurrentBank);
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* CartridgeUA::getImage(int& size) {
size = 8192; size = 8192;
return &myImage[0]; return &myImage[0];
} }

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CartUA.hxx,v 1.6 2007-01-01 18:04:47 stephena Exp $ // $Id: CartUA.hxx,v 1.7 2007-01-14 16:17:55 stephena Exp $
//============================================================================ //============================================================================
#ifndef CARTRIDGEUA_HXX #ifndef CARTRIDGEUA_HXX
#define CARTRIDGEUA_HXX #define CARTRIDGEUA_HXX
class CartridgeUA; class System;
class Serializer; class Serializer;
class Deserializer; class Deserializer;
@ -32,7 +32,7 @@ class Deserializer;
are two 4K banks. are two 4K banks.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: CartUA.hxx,v 1.6 2007-01-01 18:04:47 stephena Exp $ @version $Id: CartUA.hxx,v 1.7 2007-01-14 16:17:55 stephena Exp $
*/ */
class CartridgeUA : public Cartridge class CartridgeUA : public Cartridge
{ {
@ -86,6 +86,40 @@ class CartridgeUA : public Cartridge
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
virtual void bank(uInt16 bank);
/**
Get the current bank.
@return The current bank, or -1 if bankswitching not supported
*/
virtual int bank();
/**
Query the number of banks supported by the cartridge.
*/
virtual int bankCount();
/**
Patch the cartridge ROM.
@param address The ROM address to patch
@param value The value to place into the address
@return Success or failure of the patch operation
*/
virtual bool patch(uInt16 address, uInt8 value);
/**
Access the internal ROM image for this cartridge.
@param size Set to the size of the internal ROM image data
@return A pointer to the internal ROM image data
*/
virtual uInt8* getImage(int& size); virtual uInt8* getImage(int& size);
public: public:
@ -104,19 +138,6 @@ class CartridgeUA : public Cartridge
*/ */
virtual void poke(uInt16 address, uInt8 value); virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
/**
Install pages for the specified bank in the system
@param bank The bank that should be installed in the system
*/
void bank(uInt16 bank);
int bank();
int bankCount();
private: private:
// Indicates which bank is currently active // Indicates which bank is currently active
uInt16 myCurrentBank; uInt16 myCurrentBank;
@ -127,5 +148,5 @@ class CartridgeUA : public Cartridge
// Previous Device's page access // Previous Device's page access
System::PageAccess myHotSpotPageAccess; System::PageAccess myHotSpotPageAccess;
}; };
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Device.hxx,v 1.5 2007-01-01 18:04:50 stephena Exp $ // $Id: Device.hxx,v 1.6 2007-01-14 16:17:57 stephena Exp $
//============================================================================ //============================================================================
#ifndef DEVICE_HXX #ifndef DEVICE_HXX
@ -30,7 +30,7 @@ class Deserializer;
based system. based system.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Device.hxx,v 1.5 2007-01-01 18:04:50 stephena Exp $ @version $Id: Device.hxx,v 1.6 2007-01-14 16:17:57 stephena Exp $
*/ */
class Device class Device
{ {
@ -109,5 +109,5 @@ class Device
/// Pointer to the system the device is installed in or the null pointer /// Pointer to the system the device is installed in or the null pointer
System* mySystem; System* mySystem;
}; };
#endif #endif

View File

@ -25,6 +25,7 @@ MODULE_OBJS := \
src/emucore/CartMB.o \ src/emucore/CartMB.o \
src/emucore/CartMC.o \ src/emucore/CartMC.o \
src/emucore/CartUA.o \ src/emucore/CartUA.o \
src/emucore/Cart0840.o \
src/emucore/Console.o \ src/emucore/Console.o \
src/emucore/Control.o \ src/emucore/Control.o \
src/emucore/Deserializer.o \ src/emucore/Deserializer.o \

View File

@ -1572,10 +1572,10 @@
"Cartridge.Manufacturer" "Atari" "Cartridge.Manufacturer" "Atari"
"Cartridge.ModelNo" "CX26104" "Cartridge.ModelNo" "CX26104"
"Cartridge.Name" "Big Bird's Egg Catch (1983) (Atari)" "Cartridge.Name" "Big Bird's Egg Catch (1983) (Atari)"
"Cartridge.Note" "Uses Kids/Keypad Controllers (left only)" "Cartridge.Note" "Uses Kids/Keypad Controllers"
"Cartridge.Rarity" "Rare" "Cartridge.Rarity" "Rare"
"Controller.Left" "KEYBOARD" "Controller.Left" "KEYBOARD"
"Controller.Right" "NONE" "Controller.Right" "KEYBOARD"
"" ""
"Cartridge.MD5" "180c234496f31a8671226277e0afbf2f" "Cartridge.MD5" "180c234496f31a8671226277e0afbf2f"
@ -1589,6 +1589,8 @@
"Cartridge.MD5" "715dd9e0240638d441a3add49316c018" "Cartridge.MD5" "715dd9e0240638d441a3add49316c018"
"Cartridge.Name" "128-in-1 Junior Console (Chip 2) (PAL) [!]" "Cartridge.Name" "128-in-1 Junior Console (Chip 2) (PAL) [!]"
"Controller.Left" "DRIVING"
"Controller.Right" "DRIVING"
"" ""
"Cartridge.MD5" "5b9c2e0012fbfd29efd3306359bbfc4a" "Cartridge.MD5" "5b9c2e0012fbfd29efd3306359bbfc4a"
@ -4500,6 +4502,16 @@
"Display.Height" "220" "Display.Height" "220"
"" ""
"Cartridge.MD5" "47911752bf113a2496dbb66c70c9e70c"
"Cartridge.Manufacturer" "Atari"
"Cartridge.ModelNo" "CX26101"
"Cartridge.Name" "Oscar's Trash Race (1983) (Atari) (PAL) [!]"
"Cartridge.Note" "Uses Kids/Keypad Controllers"
"Cartridge.Rarity" "Rare"
"Controller.Left" "KEYBOARD"
"Controller.Right" "KEYBOARD"
""
"Cartridge.MD5" "47aef18509051bab493589cb2619170b" "Cartridge.MD5" "47aef18509051bab493589cb2619170b"
"Cartridge.Name" "Stell-A-Sketch (Bob Colbert) (PD)" "Cartridge.Name" "Stell-A-Sketch (Bob Colbert) (PD)"
"Cartridge.Note" "Uses Driving, Joystick, or Amiga/Atari ST mouse Controllers" "Cartridge.Note" "Uses Driving, Joystick, or Amiga/Atari ST mouse Controllers"
@ -4630,6 +4642,16 @@
"Cartridge.Rarity" "Common" "Cartridge.Rarity" "Common"
"" ""
"Cartridge.MD5" "4ac9f40ddfcf194bd8732a75b3f2f214"
"Cartridge.Manufacturer" "Atari"
"Cartridge.ModelNo" "CX26106"
"Cartridge.Name" "Grover's Music Maker (Atari) (Prototype)"
"Cartridge.Note" "Uses Kids/Keypad Controllers"
"Cartridge.Rarity" "Prototype"
"Controller.Left" "KEYBOARD"
"Controller.Right" "KEYBOARD"
""
"Cartridge.MD5" "4999b45be0ab5a85bac1b7c0e551542b" "Cartridge.MD5" "4999b45be0ab5a85bac1b7c0e551542b"
"Cartridge.Manufacturer" "CCE" "Cartridge.Manufacturer" "CCE"
"Cartridge.Name" "Double Dragon (CCE)" "Cartridge.Name" "Double Dragon (CCE)"
@ -4685,15 +4707,6 @@
"Cartridge.Rarity" "Rare" "Cartridge.Rarity" "Rare"
"" ""
"Cartridge.MD5" "4ac9f40ddfcf194bd8732a75b3f2f214"
"Cartridge.Manufacturer" "Atari"
"Cartridge.ModelNo" "CX26106"
"Cartridge.Name" "Grover's Music Maker (Atari) (Prototype)"
"Cartridge.Note" "Uses Kids/Keypad Controllers (left only)"
"Cartridge.Rarity" "Prototype"
"Controller.Left" "KEYBOARD"
""
"Cartridge.MD5" "4abb4c87a4c5f5d0c14ead2bb36251be" "Cartridge.MD5" "4abb4c87a4c5f5d0c14ead2bb36251be"
"Cartridge.Manufacturer" "Atari" "Cartridge.Manufacturer" "Atari"
"Cartridge.ModelNo" "CX26135" "Cartridge.ModelNo" "CX26135"
@ -7572,6 +7585,7 @@
"Cartridge.Name" "Cookie Monster Munch (1983) (Atari) (PAL) [a1][!]" "Cartridge.Name" "Cookie Monster Munch (1983) (Atari) (PAL) [a1][!]"
"Cartridge.Note" "Uses Kids/Keypad Controllers" "Cartridge.Note" "Uses Kids/Keypad Controllers"
"Controller.Left" "KEYBOARD" "Controller.Left" "KEYBOARD"
"Controller.Right" "KEYBOARD"
"" ""
"Cartridge.MD5" "7972e5101fa548b952d852db24ad6060" "Cartridge.MD5" "7972e5101fa548b952d852db24ad6060"
@ -9676,6 +9690,21 @@
"Display.Phosphor" "YES" "Display.Phosphor" "YES"
"" ""
"Cartridge.MD5" "9f59eddf9ba91a7d93bce7ee4b7693bc"
"Cartridge.Name" "Montezuma's Revenge - Starring Panama Joe (PAL by Thomas Jentzsch).a26"
"Display.Format" "PAL60"
""
"Cartridge.MD5" "9e01f7f95cb8596765e03b9a36e8e33c"
"Cartridge.Manufacturer" "Atari"
"Cartridge.ModelNo" "CX26103"
"Cartridge.Name" "Alpha Beam with Ernie (1983) (Atari)"
"Cartridge.Note" "Uses Kids/Keypad Controllers"
"Cartridge.Rarity" "Rare"
"Controller.Left" "KEYBOARD"
"Controller.Right" "KEYBOARD"
""
"Cartridge.MD5" "9e792a59f8795664cbaaff1ba152d731" "Cartridge.MD5" "9e792a59f8795664cbaaff1ba152d731"
"Cartridge.Name" "Bullet Demo (20-12-2002) (CT)" "Cartridge.Name" "Bullet Demo (20-12-2002) (CT)"
"" ""
@ -13955,6 +13984,16 @@
"Cartridge.Note" "Uses Keypad Controllers" "Cartridge.Note" "Uses Keypad Controllers"
"Cartridge.Rarity" "Prototype" "Cartridge.Rarity" "Prototype"
"Controller.Left" "KEYBOARD" "Controller.Left" "KEYBOARD"
"Controller.Right" "KEYBOARD"
""
"Cartridge.MD5" "fa1b060fd8e0bca0c2a097dcffce93d3"
"Cartridge.ModelNo" "CX26101"
"Cartridge.Name" "Oscar's Trash Race (1983) (Atari) (Prototype) (PAL)"
"Cartridge.Note" "Uses Kids/Keypad Controllers"
"Cartridge.Rarity" "Prototype"
"Controller.Left" "KEYBOARD"
"Controller.Right" "KEYBOARD"
"" ""
"Cartridge.MD5" "e3ed4ba3361756970f076e46e9cad1d2" "Cartridge.MD5" "e3ed4ba3361756970f076e46e9cad1d2"
@ -14831,10 +14870,10 @@
"Cartridge.Manufacturer" "Atari" "Cartridge.Manufacturer" "Atari"
"Cartridge.ModelNo" "CX26104" "Cartridge.ModelNo" "CX26104"
"Cartridge.Name" "Big Bird's Egg Catch (1983) (Atari) (PAL) [!]" "Cartridge.Name" "Big Bird's Egg Catch (1983) (Atari) (PAL) [!]"
"Cartridge.Note" "Uses Kids/Keypad Controllers (left only)" "Cartridge.Note" "Uses Kids/Keypad Controllers"
"Cartridge.Rarity" "Rare" "Cartridge.Rarity" "Rare"
"Controller.Left" "KEYBOARD" "Controller.Left" "KEYBOARD"
"Controller.Right" "NONE" "Controller.Right" "KEYBOARD"
"" ""
"Cartridge.MD5" "f280976d69d6e27a48506bd6bad11dcd" "Cartridge.MD5" "f280976d69d6e27a48506bd6bad11dcd"
@ -15789,4 +15828,3 @@
"Cartridge.Name" "Spitfire Attack (1983) (Milton Bradley) [h1]" "Cartridge.Name" "Spitfire Attack (1983) (Milton Bradley) [h1]"
"Display.YStart" "28" "Display.YStart" "28"
"" ""