Fixed potential bug in Cartridge API; renamed bank() to getBank(),

since there are issues with mixing overloading and virtual functions.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2963 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-07-28 13:40:37 +00:00
parent 82ef198585
commit 9f172cbb42
65 changed files with 75 additions and 76 deletions

View File

@ -54,7 +54,7 @@ bool BankRomCheat::enable()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool BankRomCheat::disable()
{
int oldBank = myOSystem->console().cartridge().bank();
int oldBank = myOSystem->console().cartridge().getBank();
myOSystem->console().cartridge().bank(bank);
for(int i = 0; i < count; ++i)
@ -70,7 +70,7 @@ void BankRomCheat::evaluate()
{
if(!myEnabled)
{
int oldBank = myOSystem->console().cartridge().bank();
int oldBank = myOSystem->console().cartridge().getBank();
myOSystem->console().cartridge().bank(bank);
for(int i = 0; i < count; ++i)

View File

@ -527,7 +527,7 @@ bool CartDebug::addDirective(CartDebug::DisasmType type,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartDebug::getBank()
{
return myConsole.cartridge().bank();
return myConsole.cartridge().getBank();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -69,7 +69,7 @@ void CartridgeCTYWidget::saveOldState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCTYWidget::loadConfig()
{
myBank->setSelectedIndex(myCart.bank()-1);
myBank->setSelectedIndex(myCart.getBank()-1);
CartDebugWidget::loadConfig();
}
@ -95,7 +95,7 @@ string CartridgeCTYWidget::bankState()
static const char* spot[] = {
"", "$FF5", "$FF6", "$FF7", "$FF8", "$FF9", "$FFA", "$FFB"
};
uInt16 bank = myCart.bank();
uInt16 bank = myCart.getBank();
buf << "Bank = " << dec << bank << ", hotspot = " << spot[bank];
return buf.str();

View File

@ -46,8 +46,8 @@ string CartridgeFEWidget::bankState()
ostringstream& buf = buffer();
static const char* range[] = { "$F000", "$D000" };
buf << "Bank = " << dec << myCart.bank()
<< ", address range = " << range[myCart.bank()];
buf << "Bank = " << dec << myCart.getBank()
<< ", address range = " << range[myCart.getBank()];
return buf.str();
}

View File

@ -137,7 +137,7 @@ class Cartridge : public Device
Get the current bank. Carts which have only one bank (either real
or virtual) always report that bank as zero.
*/
virtual uInt16 bank() const { return 0; }
virtual uInt16 getBank() const { return 0; }
/**
Query the number of 'banks' supported by the cartridge. Note that

View File

@ -166,7 +166,7 @@ bool Cartridge0840::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge0840::bank() const
uInt16 Cartridge0840::getBank() const
{
return myCurrentBank;
}

View File

@ -76,7 +76,7 @@ class Cartridge0840 : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -222,7 +222,7 @@ bool Cartridge3E::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge3E::bank() const
uInt16 Cartridge3E::getBank() const
{
return myCurrentBank;
}

View File

@ -107,7 +107,7 @@ class Cartridge3E : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -155,7 +155,7 @@ bool Cartridge3F::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge3F::bank() const
uInt16 Cartridge3F::getBank() const
{
return myCurrentBank;
}

View File

@ -84,7 +84,7 @@ class Cartridge3F : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -439,7 +439,7 @@ bool CartridgeAR::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeAR::bank() const
uInt16 CartridgeAR::getBank() const
{
return myCurrentBank;
}

View File

@ -91,7 +91,7 @@ class CartridgeAR : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -115,7 +115,7 @@ bool CartridgeBF::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeBF::bank() const
uInt16 CartridgeBF::getBank() const
{
return myCurrentBank;
}

View File

@ -79,7 +79,7 @@ class CartridgeBF : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -163,7 +163,7 @@ bool CartridgeBFSC::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeBFSC::bank() const
uInt16 CartridgeBFSC::getBank() const
{
return myCurrentBank;
}

View File

@ -78,7 +78,7 @@ class CartridgeBFSC : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -159,7 +159,7 @@ bool CartridgeCM::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeCM::bank() const
uInt16 CartridgeCM::getBank() const
{
return myCurrentBank;
}

View File

@ -149,7 +149,7 @@ class CartridgeCM : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -265,7 +265,7 @@ bool CartridgeCTY::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeCTY::bank() const
uInt16 CartridgeCTY::getBank() const
{
return myCurrentBank >> 12;
}
@ -307,7 +307,7 @@ bool CartridgeCTY::save(Serializer& out) const
try
{
out.putString(name());
out.putShort(bank());
out.putShort(getBank());
out.putByteArray(myRAM, 64);
out.putByte(myOperationType);

View File

@ -160,7 +160,7 @@ class CartridgeCTY : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -106,7 +106,7 @@ uInt8 CartridgeDASH::peek(uInt16 address) {
uInt8 value = 0;
uInt32 bank = (address >> (ROM_BANK_TO_POWER - 1)) & 7; // convert to 512 byte bank index (0-7)
Int16 imageBank = bankInUse[bank]; // the ROM/RAM bank that's here
uInt16 imageBank = bankInUse[bank]; // the ROM/RAM bank that's here
if (imageBank == BANK_UNDEFINED) { // an uninitialised bank?
@ -261,7 +261,7 @@ void CartridgeDASH::initializeBankState() {
for (uInt32 b = 0; b < 8; b++) {
if (bankInUse[b] == BANK_UNDEFINED) {
// Setup the page access methods for the current bank
// All accesses point to peek/poke above
System::PageAccess access(this, System::PA_READ);
uInt32 start = 0x1000 + (b << RAM_BANK_TO_POWER);
uInt32 end = start + RAM_BANK_SIZE - 1;
@ -323,7 +323,7 @@ bool CartridgeDASH::save(Serializer& out) const {
try {
out.putString(name());
out.putShortArray((uInt16*)bankInUse, 8);
out.putShortArray(bankInUse, 8);
out.putByteArray(myRAM, RAM_TOTAL_SIZE);
} catch (...) {
cerr << "ERROR: CartridgeDASH::save" << endl;
@ -338,7 +338,7 @@ bool CartridgeDASH::load(Serializer& in) {
try {
if (in.getString() != name())
return false;
in.getShortArray((uInt16*)bankInUse, 8);
in.getShortArray(bankInUse, 8);
in.getByteArray(myRAM, RAM_TOTAL_SIZE);
} catch (...) {
cerr << "ERROR: CartridgeDASH::load" << endl;

View File

@ -243,10 +243,11 @@ private:
// two as well, one 512 byte for read and one for write. The RAM locations are +0x800 apart, and the ROM
// are consecutive. This allows us to determine on a read/write exactly where the data is.
Int16 bankInUse[8]; // bank being used for ROM/RAM (eight 512 byte areas) (-1 = undefined)
static const uInt16 BANK_UNDEFINED = 0x8000; // bank is undefined and inaccessible
uInt16 bankInUse[8]; // bank being used for ROM/RAM (eight 512 byte areas)
static const uInt16 BANK_SWITCH_HOTSPOT_RAM = 0x3E; // writes to this address cause bankswitching
static const uInt16 BANK_SWITCH_HOTSPOT_ROM = 0x3F; // writes to this address cause bankswitching
static const uInt16 BANK_SWITCH_HOTSPOT_RAM = 0x3E; // writes to this address cause bankswitching
static const uInt16 BANK_SWITCH_HOTSPOT_ROM = 0x3F; // writes to this address cause bankswitching
static const uInt8 BANK_BITS = 6; // # bits for bank
static const uInt8 BIT_BANK_MASK = (1 << BANK_BITS) - 1; // mask for those bits
@ -267,8 +268,6 @@ private:
static const uInt16 RAM_WRITE_OFFSET = 0x800;
static const Int16 BANK_UNDEFINED = -1; // bank is undefined and inaccessible
uInt32 mySize; // Size of the ROM image
uInt8* myImage; // Pointer to a dynamically allocated ROM image of the cartridge
uInt8 myRAM[RAM_TOTAL_SIZE];

View File

@ -115,7 +115,7 @@ bool CartridgeDF::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeDF::bank() const
uInt16 CartridgeDF::getBank() const
{
return myCurrentBank;
}

View File

@ -79,7 +79,7 @@ class CartridgeDF : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -163,7 +163,7 @@ bool CartridgeDFSC::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeDFSC::bank() const
uInt16 CartridgeDFSC::getBank() const
{
return myCurrentBank;
}

View File

@ -78,7 +78,7 @@ class CartridgeDFSC : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -439,7 +439,7 @@ bool CartridgeDPC::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeDPC::bank() const
uInt16 CartridgeDPC::getBank() const
{
return myCurrentBank;
}

View File

@ -90,7 +90,7 @@ class CartridgeDPC : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -622,7 +622,7 @@ bool CartridgeDPCPlus::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeDPCPlus::bank() const
uInt16 CartridgeDPCPlus::getBank() const
{
return myCurrentBank;
}

View File

@ -94,7 +94,7 @@ class CartridgeDPCPlus : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -240,7 +240,7 @@ bool CartridgeE7::bank(uInt16 slice)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeE7::bank() const
uInt16 CartridgeE7::getBank() const
{
return myCurrentSlice[0];
}

View File

@ -104,7 +104,7 @@ class CartridgeE7 : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -115,7 +115,7 @@ bool CartridgeEF::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeEF::bank() const
uInt16 CartridgeEF::getBank() const
{
return myCurrentBank;
}

View File

@ -82,7 +82,7 @@ class CartridgeEF : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -163,7 +163,7 @@ bool CartridgeEFSC::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeEFSC::bank() const
uInt16 CartridgeEFSC::getBank() const
{
return myCurrentBank;
}

View File

@ -82,7 +82,7 @@ class CartridgeEFSC : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -129,7 +129,7 @@ bool CartridgeF0::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeF0::bank() const
uInt16 CartridgeF0::getBank() const
{
return myCurrentBank;
}

View File

@ -79,7 +79,7 @@ class CartridgeF0 : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -120,7 +120,7 @@ bool CartridgeF4::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeF4::bank() const
uInt16 CartridgeF4::getBank() const
{
return myCurrentBank;
}

View File

@ -78,7 +78,7 @@ class CartridgeF4 : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -166,7 +166,7 @@ bool CartridgeF4SC::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeF4SC::bank() const
uInt16 CartridgeF4SC::getBank() const
{
return myCurrentBank;
}

View File

@ -78,7 +78,7 @@ class CartridgeF4SC : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -160,7 +160,7 @@ bool CartridgeF6::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeF6::bank() const
uInt16 CartridgeF6::getBank() const
{
return myCurrentBank;
}

View File

@ -78,7 +78,7 @@ class CartridgeF6 : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -209,7 +209,7 @@ bool CartridgeF6SC::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeF6SC::bank() const
uInt16 CartridgeF6SC::getBank() const
{
return myCurrentBank;
}

View File

@ -78,7 +78,7 @@ class CartridgeF6SC : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -148,7 +148,7 @@ bool CartridgeF8::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeF8::bank() const
uInt16 CartridgeF8::getBank() const
{
return myCurrentBank;
}

View File

@ -80,7 +80,7 @@ class CartridgeF8 : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -189,7 +189,7 @@ bool CartridgeF8SC::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeF8SC::bank() const
uInt16 CartridgeF8SC::getBank() const
{
return myCurrentBank;
}

View File

@ -78,7 +78,7 @@ class CartridgeF8SC : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -199,7 +199,7 @@ bool CartridgeFA::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeFA::bank() const
uInt16 CartridgeFA::getBank() const
{
return myCurrentBank;
}

View File

@ -78,7 +78,7 @@ class CartridgeFA : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -269,7 +269,7 @@ bool CartridgeFA2::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeFA2::bank() const
uInt16 CartridgeFA2::getBank() const
{
return myCurrentBank;
}

View File

@ -86,7 +86,7 @@ class CartridgeFA2 : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -104,7 +104,7 @@ void CartridgeFE::setAccessFlags(uInt16 address, uInt8 flags)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeFE::bank() const
uInt16 CartridgeFE::getBank() const
{
// The current bank depends on the last address accessed
return ((myLastAddress1 & 0x2000) == 0) ? 1 : 0;

View File

@ -86,7 +86,7 @@ class CartridgeFE : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -210,7 +210,7 @@ bool CartridgeMC::poke(uInt16 address, uInt8 value)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeMC::bank() const
uInt16 CartridgeMC::getBank() const
{
// TODO - add support for debugger
return 0;

View File

@ -177,7 +177,7 @@ class CartridgeMC : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -147,7 +147,7 @@ bool CartridgeSB::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeSB::bank() const
uInt16 CartridgeSB::getBank() const
{
return myCurrentBank;
}

View File

@ -78,7 +78,7 @@ class CartridgeSB : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -155,7 +155,7 @@ bool CartridgeUA::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeUA::bank() const
uInt16 CartridgeUA::getBank() const
{
return myCurrentBank;
}

View File

@ -78,7 +78,7 @@ class CartridgeUA : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.

View File

@ -139,7 +139,7 @@ bool CartridgeX07::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeX07::bank() const
uInt16 CartridgeX07::getBank() const
{
return myCurrentBank;
}

View File

@ -88,7 +88,7 @@ class CartridgeX07 : public Cartridge
/**
Get the current bank.
*/
uInt16 bank() const;
uInt16 getBank() const;
/**
Query the number of banks supported by the cartridge.