Cleaned up the Cartridge::bankXXX API. Carts which are non-bankswitched

or those which implement their own unique scheme no longer have to
implement bank and bankCount; this base class versions will be used
instead.

Removed the debugger 'bank' command, since it didn't work for all cart
types, and is obsolete now that the UI allows to change banks for
all cart types.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2960 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-07-24 17:15:28 +00:00
parent ef183beab7
commit 2f4a3e7966
26 changed files with 26 additions and 398 deletions

View File

@ -14,6 +14,10 @@
4.0 to 4.1: (xxx xx, 2014) 4.0 to 4.1: (xxx xx, 2014)
* Removed the 'bank' command from the debugger prompt, as it only worked
with certain bankswitch types. The bankswitch UI should now be used
to query/set bank state.
* The UNIX configure script now supports newer versions of Hurd. * The UNIX configure script now supports newer versions of Hurd.
Special thanks to Stephen Kitt for the patch. Special thanks to Stephen Kitt for the patch.

View File

@ -42,8 +42,14 @@ CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem)
myRWPortAddress(0), myRWPortAddress(0),
myLabelLength(8) // longest pre-defined label myLabelLength(8) // longest pre-defined label
{ {
// Zero-page RAM is always present // Add Zero-page RAM addresses
addRamArea(0x80, 128, 0, 0); for(uInt32 i = 0x80; i <= 0xFF; ++i)
{
myState.rport.push_back(i);
myState.wport.push_back(i);
myOldState.rport.push_back(i);
myOldState.wport.push_back(i);
}
// Create bank information for each potential bank, and an extra one for ZP RAM // Create bank information for each potential bank, and an extra one for ZP RAM
// Banksizes greater than 4096 indicate multi-bank ROMs, but we handle only // Banksizes greater than 4096 indicate multi-bank ROMs, but we handle only
@ -122,27 +128,6 @@ CartDebug::~CartDebug()
myBankInfo.clear(); myBankInfo.clear();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartDebug::addRamArea(uInt16 start, uInt16 size,
uInt16 roffset, uInt16 woffset)
{
// First make sure this area isn't already present
for(uInt32 i = 0; i < myState.rport.size(); ++i)
if(myState.rport[i] == start + roffset ||
myState.wport[i] == start + woffset)
return;
// Otherwise, add a new area
for(uInt32 i = 0; i < size; ++i)
{
myState.rport.push_back(i + start + roffset);
myState.wport.push_back(i + start + woffset);
myOldState.rport.push_back(i + start + roffset);
myOldState.wport.push_back(i + start + woffset);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const DebuggerState& CartDebug::getState() const DebuggerState& CartDebug::getState()
{ {

View File

@ -121,16 +121,6 @@ class CartDebug : public DebuggerSystem
// write port area. // write port area.
int readFromWritePort(); int readFromWritePort();
/**
Let the Cart debugger subsystem treat this area as addressable memory.
@param start The beginning of the RAM area (0x0000 - 0x2000)
@param size Total number of bytes of area
@param roffset Offset to use when reading from RAM (read port)
@param woffset Offset to use when writing to RAM (write port)
*/
void addRamArea(uInt16 start, uInt16 size, uInt16 roffset, uInt16 woffset);
// The following two methods are meant to be used together // The following two methods are meant to be used together
// First, a call is made to disassemble(), which updates the disassembly // First, a call is made to disassemble(), which updates the disassembly
// list; it will figure out when an actual complete disassembly is // list; it will figure out when an actual complete disassembly is

View File

@ -497,19 +497,6 @@ string Debugger::showWatches()
return myParser->showWatches(); return myParser->showWatches();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::setBank(int bank)
{
if(myConsole.cartridge().bankCount() > 1)
{
myConsole.cartridge().unlockBank();
bool status = myConsole.cartridge().bank(bank);
myConsole.cartridge().lockBank();
return status;
}
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::patchROM(int addr, int value) bool Debugger::patchROM(int addr, int value)
{ {

View File

@ -238,7 +238,6 @@ class Debugger : public DialogContainer
void setBreakPoint(int bp, bool set); void setBreakPoint(int bp, bool set);
bool setBank(int bank);
bool patchROM(int addr, int value); bool patchROM(int addr, int value);
/** /**

View File

@ -643,36 +643,6 @@ void DebuggerParser::executeA()
debugger.cpuDebug().setA((uInt8)args[0]); debugger.cpuDebug().setA((uInt8)args[0]);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "bank"
void DebuggerParser::executeBank()
{
int banks = debugger.cartDebug().bankCount();
if(argCount == 0)
{
commandResult << debugger.cartDebug().getCartType() << ": ";
if(banks < 2)
commandResult << red("bankswitching not supported by this cartridge");
else
{
commandResult << "current = " << debugger.cartDebug().getBank()
<< " out of " << banks << " banks";
}
}
else
{
if(banks == 1)
commandResult << red("bankswitching not supported by this cartridge");
else if(args[0] >= banks)
commandResult << red("invalid bank number (must be 0 to ")
<< (banks - 1) << ")";
else if(debugger.setBank(args[0]))
commandResult << "switched bank OK";
else
commandResult << red("error switching banks (bankswitching may not be supported)");
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "base" // "base"
void DebuggerParser::executeBase() void DebuggerParser::executeBase()
@ -1621,15 +1591,6 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
&DebuggerParser::executeA &DebuggerParser::executeA
}, },
{
"bank",
"Show # of banks, or switch to bank xx",
false,
true,
{ kARG_WORD, kARG_END_ARGS },
&DebuggerParser::executeBank
},
{ {
"base", "base",
"Set default base (hex, dec, or bin)", "Set default base (hex, dec, or bin)",

View File

@ -72,7 +72,7 @@ class DebuggerParser
private: private:
enum { enum {
kNumCommands = 71, kNumCommands = 70,
kMAX_ARG_TYPES = 10 kMAX_ARG_TYPES = 10
}; };
@ -126,7 +126,6 @@ class DebuggerParser
// List of available command methods // List of available command methods
void executeA(); void executeA();
void executeBank();
void executeBase(); void executeBase();
void executeBreak(); void executeBreak();
void executeBreakif(); void executeBreakif();

View File

@ -35,11 +35,6 @@ class GuiObject;
#include "Settings.hxx" #include "Settings.hxx"
#include "Font.hxx" #include "Font.hxx"
struct RamArea {
uInt16 start; uInt16 size; uInt16 roffset; uInt16 woffset;
};
typedef Common::Array<RamArea> RamAreaList;
/** /**
A cartridge is a device which contains the machine code for a A cartridge is a device which contains the machine code for a
game and handles any bankswitching performed by the cartridge. game and handles any bankswitching performed by the cartridge.
@ -125,18 +120,24 @@ class Cartridge : public Device
public: public:
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// The following methods are cart-specific and must be implemented // The following methods are cart-specific and will usually be
// in derived classes. // implemented in derived classes. Carts which don't support
// bankswitching (for any reason) do not have to provide an
// implementation for bankswitch-related methods.
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
/** /**
Set the specified bank. Set the specified bank. This is used only when the bankswitching
scheme defines banks in a standard format (ie, 0 for first bank,
1 for second, etc). Carts which will handle their own bankswitching
completely or non-bankswitched carts can ignore this method.
*/ */
virtual bool bank(uInt16 bank) = 0; virtual bool bank(uInt16) { return false; }
/** /**
Get the current bank. Get the current bank. Carts which have only one bank (either real
or virtual) always report that bank as zero.
*/ */
virtual uInt16 bank() const = 0; virtual uInt16 bank() const { return 0; }
/** /**
Query the number of 'banks' supported by the cartridge. Note that Query the number of 'banks' supported by the cartridge. Note that
@ -151,7 +152,7 @@ class Cartridge : public Device
RAM slices at multiple access points) is so complicated that the RAM slices at multiple access points) is so complicated that the
cart will report having only one 'virtual' bank. cart will report having only one 'virtual' bank.
*/ */
virtual uInt16 bankCount() const = 0; virtual uInt16 bankCount() const { return 1; }
/** /**
Patch the cartridge ROM. Patch the cartridge ROM.

View File

@ -100,26 +100,6 @@ bool Cartridge2K::poke(uInt16, uInt8)
return false; return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge2K::bank(uInt16 bank)
{
// Doesn't support bankswitching
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge2K::bank() const
{
// Doesn't support bankswitching
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge2K::bankCount() const
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge2K::patch(uInt16 address, uInt8 value) bool Cartridge2K::patch(uInt16 address, uInt8 value)
{ {

View File

@ -69,23 +69,6 @@ class Cartridge2K : public Cartridge
*/ */
void install(System& system); void install(System& system);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
bool bank(uInt16 bank);
/**
Get the current bank.
*/
uInt16 bank() const;
/**
Query the number of banks supported by the cartridge.
*/
uInt16 bankCount() const;
/** /**
Patch the cartridge ROM. Patch the cartridge ROM.

View File

@ -336,28 +336,6 @@ void Cartridge4A50::checkBankSwitch(uInt16 address, uInt8 value)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::bank(uInt16)
{
// Doesn't support bankswitching in the normal sense
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge4A50::bank() const
{
// Doesn't support bankswitching in the normal sense
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge4A50::bankCount() const
{
// Doesn't support bankswitching in the normal sense
// There is one 'virtual' bank that can change in many different ways
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::patch(uInt16 address, uInt8 value) bool Cartridge4A50::patch(uInt16 address, uInt8 value)
{ {

View File

@ -82,23 +82,6 @@ class Cartridge4A50 : public Cartridge
*/ */
void install(System& system); void install(System& system);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
bool bank(uInt16 bank);
/**
Get the current bank.
*/
uInt16 bank() const;
/**
Query the number of banks supported by the cartridge.
*/
uInt16 bankCount() const;
/** /**
Patch the cartridge ROM. Patch the cartridge ROM.

View File

@ -77,26 +77,6 @@ bool Cartridge4K::poke(uInt16, uInt8)
return false; return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::bank(uInt16)
{
// Doesn't support bankswitching
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge4K::bank() const
{
// Doesn't support bankswitching
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge4K::bankCount() const
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::patch(uInt16 address, uInt8 value) bool Cartridge4K::patch(uInt16 address, uInt8 value)
{ {

View File

@ -68,23 +68,6 @@ class Cartridge4K : public Cartridge
*/ */
void install(System& system); void install(System& system);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
bool bank(uInt16 bank);
/**
Get the current bank.
*/
uInt16 bank() const;
/**
Query the number of banks supported by the cartridge.
*/
uInt16 bankCount() const;
/** /**
Patch the cartridge ROM. Patch the cartridge ROM.

View File

@ -121,25 +121,6 @@ bool Cartridge4KSC::poke(uInt16 address, uInt8)
return false; return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4KSC::bank(uInt16 bank)
{
// Doesn't support bankswitching
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge4KSC::bank() const
{
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge4KSC::bankCount() const
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4KSC::patch(uInt16 address, uInt8 value) bool Cartridge4KSC::patch(uInt16 address, uInt8 value)
{ {

View File

@ -66,23 +66,6 @@ class Cartridge4KSC : public Cartridge
*/ */
void install(System& system); void install(System& system);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
bool bank(uInt16 bank);
/**
Get the current bank.
*/
uInt16 bank() const;
/**
Query the number of banks supported by the cartridge.
*/
uInt16 bankCount() const;
/** /**
Patch the cartridge ROM. Patch the cartridge ROM.

View File

@ -149,26 +149,6 @@ bool CartridgeCV::poke(uInt16, uInt8)
return false; return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeCV::bank(uInt16 bank)
{
// Doesn't support bankswitching
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeCV::bank() const
{
// Doesn't support bankswitching
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeCV::bankCount() const
{
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeCV::patch(uInt16 address, uInt8 value) bool CartridgeCV::patch(uInt16 address, uInt8 value)
{ {

View File

@ -71,23 +71,6 @@ class CartridgeCV : public Cartridge
*/ */
void install(System& system); void install(System& system);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
bool bank(uInt16 bank);
/**
Get the current bank.
*/
uInt16 bank() const;
/**
Query the number of banks supported by the cartridge.
*/
uInt16 bankCount() const;
/** /**
Patch the cartridge ROM. Patch the cartridge ROM.

View File

@ -38,13 +38,6 @@ CartridgeDASH::CartridgeDASH(const uInt8* image, uInt32 size, const Settings& se
// This cart can address 4 banks of RAM, each 512 bytes @ 1000, 1200, 1400, 1600 // This cart can address 4 banks of RAM, each 512 bytes @ 1000, 1200, 1400, 1600
// However, it may not be addressable all the time (it may be swapped out) // However, it may not be addressable all the time (it may be swapped out)
#if 0
registerRamArea(0x1000, RAM_BANK_SIZE, 0x00, RAM_WRITE_OFFSET); // 512 bytes RAM @ 0x1000
registerRamArea(0x1200, RAM_BANK_SIZE, 0x00, RAM_WRITE_OFFSET); // 512 bytes RAM @ 0x1200
registerRamArea(0x1400, RAM_BANK_SIZE, 0x00, RAM_WRITE_OFFSET); // 512 bytes RAM @ 0x1400
registerRamArea(0x1600, RAM_BANK_SIZE, 0x00, RAM_WRITE_OFFSET); // 512 bytes RAM @ 0x1600
#endif
// Remember startup bank (0 per spec, rather than last per 3E scheme). // Remember startup bank (0 per spec, rather than last per 3E scheme).
// Set this to go to 3rd 1K Bank. // Set this to go to 3rd 1K Bank.
myStartBank = 0; //(3 << BANK_BITS) | 0; myStartBank = 0; //(3 << BANK_BITS) | 0;
@ -243,27 +236,6 @@ bool CartridgeDASH::bankROM(uInt8 bank) {
return changed; return changed;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeDASH::bank(uInt16 bank) {
// Doesn't support bankswitching in the normal sense
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeDASH::bank() const {
// Doesn't support bankswitching in the normal sense
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeDASH::bankCount() const {
// Doesn't support bankswitching in the normal sense
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeDASH::patch(uInt16 address, uInt8 value) { bool CartridgeDASH::patch(uInt16 address, uInt8 value) {

View File

@ -155,23 +155,6 @@ public:
*/ */
void install(System& system); void install(System& system);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
bool bank(uInt16 bank);
/**
Get the current bank.
*/
uInt16 bank() const;
/**
Query the number of banks supported by the cartridge.
*/
uInt16 bankCount() const;
/** /**
Patch the cartridge ROM. Patch the cartridge ROM.

View File

@ -192,28 +192,6 @@ void CartridgeE0::segmentTwo(uInt16 slice)
myBankChanged = true; myBankChanged = true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE0::bank(uInt16)
{
// Doesn't support bankswitching in the normal sense
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeE0::bank() const
{
// Doesn't support bankswitching in the normal sense
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeE0::bankCount() const
{
// Doesn't support bankswitching in the normal sense
// There is one 'virtual' bank that can change in many different ways
return 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeE0::patch(uInt16 address, uInt8 value) bool CartridgeE0::patch(uInt16 address, uInt8 value)
{ {

View File

@ -77,23 +77,6 @@ class CartridgeE0 : public Cartridge
*/ */
void install(System& system); void install(System& system);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
bool bank(uInt16 bank);
/**
Get the current bank.
*/
uInt16 bank() const;
/**
Query the number of banks supported by the cartridge.
*/
uInt16 bankCount() const;
/** /**
Patch the cartridge ROM. Patch the cartridge ROM.

View File

@ -103,13 +103,6 @@ void CartridgeFE::setAccessFlags(uInt16 address, uInt8 flags)
(((address & 0x2000) == 0) ? 4096 : 0)] |= flags; (((address & 0x2000) == 0) ? 4096 : 0)] |= flags;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFE::bank(uInt16)
{
// Doesn't support bankswitching in the normal sense
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeFE::bank() const uInt16 CartridgeFE::bank() const
{ {

View File

@ -83,13 +83,6 @@ class CartridgeFE : public Cartridge
*/ */
void install(System& system); void install(System& system);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
bool bank(uInt16 bank);
/** /**
Get the current bank. Get the current bank.
*/ */

View File

@ -209,13 +209,6 @@ bool CartridgeMC::poke(uInt16 address, uInt8 value)
return false; return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeMC::bank(uInt16 b)
{
// Doesn't support bankswitching in the normal sense
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeMC::bank() const uInt16 CartridgeMC::bank() const
{ {

View File

@ -174,13 +174,6 @@ class CartridgeMC : public Cartridge
*/ */
void install(System& system); void install(System& system);
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
bool bank(uInt16 bank);
/** /**
Get the current bank. Get the current bank.
*/ */