Peek/poke refactoring for next batch of bankswitch schemes.

This commit is contained in:
Stephen Anthony 2017-08-30 20:44:18 -02:30
parent a5d9550f2f
commit 68f80f04d9
20 changed files with 108 additions and 130 deletions

View File

@ -134,7 +134,7 @@ void CartridgeBFSCWidget::saveOldState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBFSCWidget::loadConfig()
{
myBank->setSelectedIndex(myCart.myCurrentBank);
myBank->setSelectedIndex(myCart.getBank());
CartDebugWidget::loadConfig();
}
@ -167,8 +167,8 @@ string CartridgeBFSCWidget::bankState()
"$FFB0", "$FFB1", "$FFB2", "$FFB3", "$FFB4", "$FFB5", "$FFB6", "$FFB7",
"$FFB8", "$FFB9", "$FFBA", "$FFBB", "$FFBC", "$FFBD", "$FFBE", "$FFBF"
};
buf << "Bank = " << std::dec << myCart.myCurrentBank
<< ", hotspot = " << spot[myCart.myCurrentBank];
buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()];
return buf.str();
}

View File

@ -121,7 +121,7 @@ CartridgeBFWidget::CartridgeBFWidget(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBFWidget::loadConfig()
{
myBank->setSelectedIndex(myCart.myCurrentBank);
myBank->setSelectedIndex(myCart.getBank());
CartDebugWidget::loadConfig();
}
@ -154,8 +154,8 @@ string CartridgeBFWidget::bankState()
"$FFB0", "$FFB1", "$FFB2", "$FFB3", "$FFB4", "$FFB5", "$FFB6", "$FFB7",
"$FFB8", "$FFB9", "$FFBA", "$FFBB", "$FFBC", "$FFBD", "$FFBE", "$FFBF"
};
buf << "Bank = " << std::dec << myCart.myCurrentBank
<< ", hotspot = " << spot[myCart.myCurrentBank];
buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()];
return buf.str();
}

View File

@ -252,7 +252,7 @@ void CartridgeBUSWidget::saveOldState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBUSWidget::loadConfig()
{
myBank->setSelectedIndex(myCart.myCurrentBank);
myBank->setSelectedIndex(myCart.getBank());
// Get registers, using change tracking
IntArray alist;
@ -397,8 +397,8 @@ string CartridgeBUSWidget::bankState()
static const char* const spot[] = {
"$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
};
buf << "Bank = " << std::dec << myCart.myCurrentBank
<< ", hotspot = " << spot[myCart.myCurrentBank];
buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()];
return buf.str();
}

View File

@ -230,7 +230,7 @@ void CartridgeCDFWidget::saveOldState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCDFWidget::loadConfig()
{
myBank->setSelectedIndex(myCart.myCurrentBank);
myBank->setSelectedIndex(myCart.getBank());
// Get registers, using change tracking
IntArray alist;
@ -360,8 +360,8 @@ string CartridgeCDFWidget::bankState()
static const char* const spot[] = {
"$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
};
buf << "Bank = " << std::dec << myCart.myCurrentBank
<< ", hotspot = " << spot[myCart.myCurrentBank];
buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()];
return buf.str();
}

View File

@ -158,7 +158,7 @@ void CartridgeCMWidget::saveOldState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCMWidget::loadConfig()
{
myBank->setSelectedIndex(myCart.myCurrentBank);
myBank->setSelectedIndex(myCart.getBank());
RiotDebug& riot = Debugger::debugger().riotDebug();
const RiotState& state = static_cast<const RiotState&>(riot.getState());
@ -219,7 +219,7 @@ string CartridgeCMWidget::bankState()
{
ostringstream& buf = buffer();
buf << "Bank = " << std::dec << myCart.myCurrentBank
buf << "Bank = " << std::dec << myCart.getBank()
<< ", RAM is" << (myCart.mySWCHA & 0x10 ? " Inactive" :
myCart.mySWCHA & 0x20 ? " Read-only" : " Write-only");

View File

@ -22,7 +22,7 @@
CartridgeBF::CartridgeBF(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings),
myCurrentBank(0)
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(262144u, size));
@ -51,18 +51,22 @@ void CartridgeBF::install(System& system)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeBF::peek(uInt16 address)
{
// Due to the way addressing is set up, we will only get here if the
// address is in the hotspot range ($1F80 - $1FFF)
address &= 0x0FFF;
// Switch banks if necessary
if((address >= 0x0F80) && (address <= 0x0FBF))
bank(address - 0x0F80);
return myImage[(myCurrentBank << 12) + address];
return myImage[myBankOffset + address];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeBF::poke(uInt16 address, uInt8)
{
// Due to the way addressing is set up, we will only get here if the
// address is in the hotspot range ($1F80 - $1FFF)
address &= 0x0FFF;
// Switch banks if necessary
@ -78,8 +82,7 @@ bool CartridgeBF::bank(uInt16 bank)
if(bankLocked()) return false;
// Remember what bank we're in
myCurrentBank = bank;
uInt32 offset = myCurrentBank << 12;
myBankOffset = bank << 12;
System::PageAccess access(this, System::PA_READ);
@ -87,7 +90,7 @@ bool CartridgeBF::bank(uInt16 bank)
for(uInt32 i = (0x1F80 & ~System::PAGE_MASK); i < 0x2000;
i += (1 << System::PAGE_SHIFT))
{
access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[myBankOffset + (i & 0x0FFF)];
mySystem->setPageAccess(i >> System::PAGE_SHIFT, access);
}
@ -95,8 +98,8 @@ bool CartridgeBF::bank(uInt16 bank)
for(uInt32 address = 0x1000; address < (0x1F80U & ~System::PAGE_MASK);
address += (1 << System::PAGE_SHIFT))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)];
access.directPeekBase = &myImage[myBankOffset + (address & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[myBankOffset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> System::PAGE_SHIFT, access);
}
return myBankChanged = true;
@ -105,7 +108,7 @@ bool CartridgeBF::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeBF::getBank() const
{
return myCurrentBank;
return myBankOffset >> 12;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -117,14 +120,14 @@ uInt16 CartridgeBF::bankCount() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeBF::patch(uInt16 address, uInt8 value)
{
myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value;
myImage[myBankOffset + (address & 0x0FFF)] = value;
return myBankChanged = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeBF::getImage(int& size) const
{
size = 262144;
size = 64 * 4096;
return myImage;
}
@ -134,7 +137,7 @@ bool CartridgeBF::save(Serializer& out) const
try
{
out.putString(name());
out.putShort(myCurrentBank);
out.putInt(myBankOffset);
}
catch(...)
{
@ -153,7 +156,7 @@ bool CartridgeBF::load(Serializer& in)
if(in.getString() != name())
return false;
myCurrentBank = in.getShort();
myBankOffset = in.getInt();
}
catch(...)
{
@ -162,7 +165,7 @@ bool CartridgeBF::load(Serializer& in)
}
// Remember what bank we were in
bank(myCurrentBank);
bank(myBankOffset >> 12);
return true;
}

View File

@ -152,8 +152,8 @@ class CartridgeBF : public Cartridge
// The 256K ROM image of the cartridge
uInt8 myImage[64 * 4096];
// Indicates which bank is currently active
uInt16 myCurrentBank;
// Indicates the offset into the ROM image (aligns to current bank)
uInt32 myBankOffset;
private:
// Following constructors and assignment operators not supported

View File

@ -22,7 +22,7 @@
CartridgeBFSC::CartridgeBFSC(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings),
myCurrentBank(0)
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(262144u, size));
@ -95,7 +95,7 @@ uInt8 CartridgeBFSC::peek(uInt16 address)
}
}
else
return myImage[(myCurrentBank << 12) + address];
return myImage[myBankOffset + address];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -107,7 +107,7 @@ bool CartridgeBFSC::poke(uInt16 address, uInt8)
if((address >= 0x0F80) && (address <= 0x0FBF))
bank(address - 0x0F80);
// NOTE: This does not handle accessing RAM, however, this function
// NOTE: This does not handle accessing RAM, however, this method
// should never be called for RAM because of the way page accessing
// has been setup
return false;
@ -119,8 +119,7 @@ bool CartridgeBFSC::bank(uInt16 bank)
if(bankLocked()) return false;
// Remember what bank we're in
myCurrentBank = bank;
uInt32 offset = myCurrentBank << 12;
myBankOffset = bank << 12;
System::PageAccess access(this, System::PA_READ);
@ -128,7 +127,7 @@ bool CartridgeBFSC::bank(uInt16 bank)
for(uInt32 i = (0x1F80 & ~System::PAGE_MASK); i < 0x2000;
i += (1 << System::PAGE_SHIFT))
{
access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[myBankOffset + (i & 0x0FFF)];
mySystem->setPageAccess(i >> System::PAGE_SHIFT, access);
}
@ -136,8 +135,8 @@ bool CartridgeBFSC::bank(uInt16 bank)
for(uInt32 address = 0x1100; address < (0x1F80U & ~System::PAGE_MASK);
address += (1 << System::PAGE_SHIFT))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)];
access.directPeekBase = &myImage[myBankOffset + (address & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[myBankOffset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> System::PAGE_SHIFT, access);
}
return myBankChanged = true;
@ -146,7 +145,7 @@ bool CartridgeBFSC::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeBFSC::getBank() const
{
return myCurrentBank;
return myBankOffset >> 12;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -168,7 +167,7 @@ bool CartridgeBFSC::patch(uInt16 address, uInt8 value)
myRAM[address & 0x007F] = value;
}
else
myImage[(myCurrentBank << 12) + address] = value;
myImage[myBankOffset + address] = value;
return myBankChanged = true;
}
@ -176,7 +175,7 @@ bool CartridgeBFSC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeBFSC::getImage(int& size) const
{
size = 256*1024;
size = 64 * 4096;
return myImage;
}
@ -186,7 +185,7 @@ bool CartridgeBFSC::save(Serializer& out) const
try
{
out.putString(name());
out.putShort(myCurrentBank);
out.putInt(myBankOffset);
out.putByteArray(myRAM, 128);
}
catch(...)
@ -206,7 +205,7 @@ bool CartridgeBFSC::load(Serializer& in)
if(in.getString() != name())
return false;
myCurrentBank = in.getShort();
myBankOffset = in.getInt();
in.getByteArray(myRAM, 128);
}
catch(...)
@ -216,7 +215,7 @@ bool CartridgeBFSC::load(Serializer& in)
}
// Remember what bank we were in
bank(myCurrentBank);
bank(myBankOffset >> 12);
return true;
}

View File

@ -154,8 +154,8 @@ class CartridgeBFSC : public Cartridge
// The 128 bytes of RAM
uInt8 myRAM[128];
// Indicates which bank is currently active
uInt16 myCurrentBank;
// Indicates the offset into the ROM image (aligns to current bank)
uInt32 myBankOffset;
private:
// Following constructors and assignment operators not supported

View File

@ -206,7 +206,7 @@ uInt8 CartridgeBUS::peek(uInt16 address)
{
address &= 0x0FFF;
uInt8 peekvalue = myProgramImage[(myCurrentBank << 12) + address];
uInt8 peekvalue = myProgramImage[myBankOffset + address];
// In debugger/bank-locked mode, we ignore all hotspots and in general
// anything that can change the internal state of the cart
@ -234,8 +234,8 @@ uInt8 CartridgeBUS::peek(uInt16 address)
// test for JMP FASTJUMP where FASTJUMP = $0000
if (BUS_STUFF_ON
&& peekvalue == 0x4C
&& myProgramImage[(myCurrentBank << 12) + address+1] == 0
&& myProgramImage[(myCurrentBank << 12) + address+2] == 0)
&& myProgramImage[myBankOffset + address+1] == 0
&& myProgramImage[myBankOffset + address+2] == 0)
{
myFastJumpActive = 2; // return next two peeks from datastream 17
myJMPoperandAddress = address + 1;
@ -445,8 +445,7 @@ bool CartridgeBUS::bank(uInt16 bank)
if(bankLocked()) return false;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank << 12;
myBankOffset = bank << 12;
// Setup the page access methods for the current bank
System::PageAccess access(this, System::PA_READ);
@ -455,7 +454,7 @@ bool CartridgeBUS::bank(uInt16 bank)
for(uInt32 address = 0x1040; address < 0x2000;
address += (1 << System::PAGE_SHIFT))
{
access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[myBankOffset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> System::PAGE_SHIFT, access);
}
return myBankChanged = true;
@ -464,7 +463,7 @@ bool CartridgeBUS::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeBUS::getBank() const
{
return myCurrentBank;
return myBankOffset >> 12;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -481,7 +480,7 @@ bool CartridgeBUS::patch(uInt16 address, uInt8 value)
// For now, we ignore attempts to patch the BUS address space
if(address >= 0x0040)
{
myProgramImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value;
myProgramImage[myBankOffset + (address & 0x0FFF)] = value;
return myBankChanged = true;
}
else
@ -560,7 +559,7 @@ bool CartridgeBUS::save(Serializer& out) const
out.putString(name());
// Indicates which bank is currently active
out.putShort(myCurrentBank);
out.putShort(myBankOffset);
// Harmony RAM
out.putByteArray(myBUSRAM, 8192);
@ -604,7 +603,7 @@ bool CartridgeBUS::load(Serializer& in)
return false;
// Indicates which bank is currently active
myCurrentBank = in.getShort();
myBankOffset = in.getShort();
// Harmony RAM
in.getByteArray(myBUSRAM, 8192);
@ -637,7 +636,7 @@ bool CartridgeBUS::load(Serializer& in)
}
// Now, go to the current bank
bank(myCurrentBank);
bank(myBankOffset >> 12);
return true;
}

View File

@ -238,8 +238,8 @@ class CartridgeBUS : public Cartridge
unique_ptr<Thumbulator> myThumbEmulator;
#endif
// Indicates which bank is currently active
uInt16 myCurrentBank;
// Indicates the offset into the ROM image (aligns to current bank)
uInt16 myBankOffset;
// Address to override the bus for
uInt16 myBusOverdriveAddress;

View File

@ -197,7 +197,7 @@ uInt8 CartridgeCDF::peek(uInt16 address)
{
address &= 0x0FFF;
uInt8 peekvalue = myProgramImage[(myCurrentBank << 12) + address];
uInt8 peekvalue = myProgramImage[myBankOffset + address];
// In debugger/bank-locked mode, we ignore all hotspots and in general
// anything that can change the internal state of the cart
@ -225,8 +225,8 @@ uInt8 CartridgeCDF::peek(uInt16 address)
// test for JMP FASTJUMP where FASTJUMP = $0000
if (FAST_FETCH_ON
&& peekvalue == 0x4C
&& myProgramImage[(myCurrentBank << 12) + address+1] == 0
&& myProgramImage[(myCurrentBank << 12) + address+2] == 0)
&& myProgramImage[myBankOffset + address+1] == 0
&& myProgramImage[myBankOffset + address+2] == 0)
{
myFastJumpActive = 2; // return next two peeks from datastream 31
myJMPoperandAddress = address + 1;
@ -409,8 +409,7 @@ bool CartridgeCDF::bank(uInt16 bank)
if(bankLocked()) return false;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank << 12;
myBankOffset = bank << 12;
// Setup the page access methods for the current bank
System::PageAccess access(this, System::PA_READ);
@ -419,7 +418,7 @@ bool CartridgeCDF::bank(uInt16 bank)
for(uInt32 address = 0x1040; address < 0x2000;
address += (1 << System::PAGE_SHIFT))
{
access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[myBankOffset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> System::PAGE_SHIFT, access);
}
return myBankChanged = true;
@ -428,7 +427,7 @@ bool CartridgeCDF::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeCDF::getBank() const
{
return myCurrentBank;
return myBankOffset >> 12;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -445,7 +444,7 @@ bool CartridgeCDF::patch(uInt16 address, uInt8 value)
// For now, we ignore attempts to patch the CDF address space
if(address >= 0x0040)
{
myProgramImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value;
myProgramImage[myBankOffset + (address & 0x0FFF)] = value;
return myBankChanged = true;
}
else
@ -499,7 +498,7 @@ bool CartridgeCDF::save(Serializer& out) const
out.putString(name());
// Indicates which bank is currently active
out.putShort(myCurrentBank);
out.putShort(myBankOffset);
// Indicates current mode
out.putByte(myMode);
@ -542,7 +541,7 @@ bool CartridgeCDF::load(Serializer& in)
return false;
// Indicates which bank is currently active
myCurrentBank = in.getShort();
myBankOffset = in.getShort();
// Indicates current mode
myMode = in.getByte();
@ -574,7 +573,7 @@ bool CartridgeCDF::load(Serializer& in)
}
// Now, go to the current bank
bank(myCurrentBank);
bank(myBankOffset >> 12);
return true;
}

View File

@ -235,8 +235,8 @@ class CartridgeCDF : public Cartridge
unique_ptr<Thumbulator> myThumbEmulator;
#endif
// Indicates which bank is currently active
uInt16 myCurrentBank;
// Indicates the offset into the ROM image (aligns to current bank)
uInt16 myBankOffset;
// System cycle count from when the last update to music data fetchers occurred
Int32 myAudioCycles;

View File

@ -25,7 +25,7 @@ CartridgeCM::CartridgeCM(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings),
mySWCHA(0xFF), // portA is all 1's
myCurrentBank(0)
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(16384u, size));
@ -60,7 +60,7 @@ void CartridgeCM::install(System& system)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeCM::peek(uInt16 address)
{
// NOTE: This does not handle accessing cart ROM/RAM, however, this function
// NOTE: This does not handle accessing cart ROM/RAM, however, this method
// should never be called for ROM/RAM because of the way page accessing
// has been setup (it will only ever be called for RIOT reads)
return mySystem->m6532().peek(address);
@ -104,8 +104,7 @@ bool CartridgeCM::bank(uInt16 bank)
if(bankLocked()) return false;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank << 12;
myBankOffset = bank << 12;
// Although this scheme contains four 4K ROM banks and one 2K RAM bank,
// it's easier to think of things in terms of 2K slices, as follows:
@ -121,8 +120,8 @@ bool CartridgeCM::bank(uInt16 bank)
for(uInt32 address = 0x1000; address < 0x1800;
address += (1 << System::PAGE_SHIFT))
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)];
access.directPeekBase = &myImage[myBankOffset + (address & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[myBankOffset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> System::PAGE_SHIFT, access);
}
@ -134,13 +133,13 @@ bool CartridgeCM::bank(uInt16 bank)
if(mySWCHA & 0x10)
{
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)];
access.directPeekBase = &myImage[myBankOffset + (address & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[myBankOffset + (address & 0x0FFF)];
}
else
{
access.directPeekBase = &myRAM[address & 0x7FF];
access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x07FF)];
access.codeAccessBase = &myCodeAccessBase[myBankOffset + (address & 0x07FF)];
}
if((mySWCHA & 0x30) == 0x20)
@ -157,7 +156,7 @@ bool CartridgeCM::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeCM::getBank() const
{
return myCurrentBank;
return myBankOffset >> 12;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -176,7 +175,7 @@ bool CartridgeCM::patch(uInt16 address, uInt8 value)
if((mySWCHA & 0x30) == 0x20)
myRAM[address & 0x7FF] = value;
else
myImage[(myCurrentBank << 12) + address] = value;
myImage[myBankOffset + address] = value;
return myBankChanged = true;
}
@ -194,7 +193,7 @@ bool CartridgeCM::save(Serializer& out) const
try
{
out.putString(name());
out.putShort(myCurrentBank);
out.putShort(myBankOffset);
out.putByte(mySWCHA);
out.putByte(myCompuMate->column());
out.putByteArray(myRAM, 2048);
@ -216,7 +215,7 @@ bool CartridgeCM::load(Serializer& in)
if(in.getString() != name())
return false;
myCurrentBank = in.getShort();
myBankOffset = in.getShort();
mySWCHA = in.getByte();
myCompuMate->column() = in.getByte();
in.getByteArray(myRAM, 2048);
@ -228,7 +227,7 @@ bool CartridgeCM::load(Serializer& in)
}
// Remember what bank we were in
bank(myCurrentBank);
bank(myBankOffset >> 12);
return true;
}

View File

@ -244,8 +244,8 @@ class CartridgeCM : public Cartridge
// Current copy of SWCHA (controls ROM/RAM accesses)
uInt8 mySWCHA;
// Indicates which bank is currently active
uInt16 myCurrentBank;
// Indicates the offset into the ROM image (aligns to current bank)
uInt16 myBankOffset;
private:
// Following constructors and assignment operators not supported

View File

@ -33,7 +33,7 @@ CartridgeCTY::CartridgeCTY(const BytePtr& image, uInt32 size,
myRamAccessTimeout(0),
mySystemCycles(0),
myFractionalClocks(0.0),
myCurrentBank(0)
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(32768u, size));
@ -87,7 +87,7 @@ uInt8 CartridgeCTY::peek(uInt16 address)
{
uInt16 peekAddress = address;
address &= 0x0FFF;
uInt8 peekValue = myImage[myCurrentBank + address];
uInt8 peekValue = myImage[myBankOffset + address];
// In debugger/bank-locked mode, we ignore all hotspots and in general
// anything that can change the internal state of the cart
@ -233,14 +233,14 @@ bool CartridgeCTY::bank(uInt16 bank)
if(bankLocked()) return false;
// Remember what bank we're in
myCurrentBank = bank << 12;
myBankOffset = bank << 12;
// Setup the page access methods for the current bank
System::PageAccess access(this, System::PA_READ);
for(uInt32 address = 0x1080; address < 0x2000;
address += (1 << System::PAGE_SHIFT))
{
access.codeAccessBase = &myCodeAccessBase[myCurrentBank + (address & 0x0FFF)];
access.codeAccessBase = &myCodeAccessBase[myBankOffset + (address & 0x0FFF)];
mySystem->setPageAccess(address >> System::PAGE_SHIFT, access);
}
return myBankChanged = true;
@ -249,7 +249,7 @@ bool CartridgeCTY::bank(uInt16 bank)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeCTY::getBank() const
{
return myCurrentBank >> 12;
return myBankOffset >> 12;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -271,7 +271,7 @@ bool CartridgeCTY::patch(uInt16 address, uInt8 value)
myRAM[address & 0x003F] = value;
}
else
myImage[myCurrentBank + address] = value;
myImage[myBankOffset + address] = value;
return myBankChanged = true;
}
@ -403,7 +403,7 @@ uInt8 CartridgeCTY::ramReadWrite()
break;
}
// Bit 6 is 1, busy
return myImage[myCurrentBank + 0xFF4] | 0x40;
return myImage[myBankOffset + 0xFF4] | 0x40;
}
else
{
@ -414,11 +414,11 @@ uInt8 CartridgeCTY::ramReadWrite()
myRAM[0] = 0; // Successful operation
// Bit 6 is 0, ready/success
return myImage[myCurrentBank + 0xFF4] & ~0x40;
return myImage[myBankOffset + 0xFF4] & ~0x40;
}
else
// Bit 6 is 1, busy
return myImage[myCurrentBank + 0xFF4] | 0x40;
return myImage[myBankOffset + 0xFF4] | 0x40;
}
}

View File

@ -303,8 +303,8 @@ class CartridgeCTY : public Cartridge
// Fractional DPC music OSC clocks unused during the last update
double myFractionalClocks;
// Indicates which bank is currently active
uInt16 myCurrentBank;
// Indicates the offset into the ROM image (aligns to current bank)
uInt16 myBankOffset;
private:
// Following constructors and assignment operators not supported

View File

@ -98,30 +98,18 @@ void CartridgeCV::install(System& system)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeCV::peek(uInt16 address)
{
if((address & 0x0FFF) < 0x0800) // Write port is at 0xF400 - 0xF800 (1024 bytes)
{ // Read port is handled in ::install()
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
// The only way we can get to this method is if we attempt to read from
// the write port (0xF400 - 0xF800, 1024 bytes), in which case an
// unwanted write is triggered
uInt8 value = mySystem->getDataBusState(0xFF);
if(bankLocked())
return value;
else
{
triggerReadFromWritePort(address);
return myRAM[address & 0x03FF] = value;
}
}
if(bankLocked())
return value;
else
return myImage[address & 0x07FF];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeCV::poke(uInt16, uInt8)
{
// NOTE: This does not handle accessing RAM, however, this function
// should never be called for RAM because of the way page accessing
// has been setup
return false;
{
triggerReadFromWritePort(address);
return myRAM[address & 0x03FF] = value;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -124,15 +124,6 @@ class CartridgeCV : public Cartridge
*/
uInt8 peek(uInt16 address) override;
/**
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
@return True if the poke changed the device address space, else false
*/
bool poke(uInt16 address, uInt8 value) override;
private:
// Pointer to the initial RAM data from the cart
// This doesn't always exist, so we don't pre-allocate it

View File

@ -35,7 +35,7 @@ CartridgeFE::CartridgeFE(const BytePtr& image, uInt32 size,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeFE::reset()
{
myBankOffset = myStartBank << 12;
bank(myStartBank);
myLastAccessWasFE = false;
}