From 2cc0d609408e1fc8ac529fb9d85465f81fbbfd69 Mon Sep 17 00:00:00 2001 From: stephena Date: Sat, 6 Mar 2010 18:56:36 +0000 Subject: [PATCH] First pass at adding 'hints' to each Cart class that its bank has changed. This is very useful for conditional re-disassembly, since many bankswitch schemes consist of ROM only, and once disassembled, cannot possibly have a different disassembly at some later point. This is mostly done for such static schemes (2K, 4K, etc), but more work is required for carts with extended RAM. Basically, the cart knows best how its been accessed, so it makes sense to have the hints there. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1965 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/debugger/CartDebug.cxx | 7 ++----- src/debugger/DiStella.cxx | 6 +----- src/debugger/gui/RomWidget.cxx | 2 +- src/emucore/Cart.cxx | 9 +++++++++ src/emucore/Cart.hxx | 23 ++++++++++++++++++----- src/emucore/Cart0840.cxx | 8 ++++---- src/emucore/Cart2K.cxx | 5 +++-- src/emucore/Cart3E.cxx | 9 +++++---- src/emucore/Cart3F.cxx | 13 +++++++------ src/emucore/Cart4A50.cxx | 9 +++++---- src/emucore/Cart4K.cxx | 5 +++-- src/emucore/CartAR.cxx | 3 ++- src/emucore/CartCV.cxx | 7 +++++-- src/emucore/CartDPC.cxx | 3 ++- src/emucore/CartE0.cxx | 7 ++++--- src/emucore/CartE7.cxx | 9 +++++---- src/emucore/CartEF.cxx | 7 ++++--- src/emucore/CartEFSC.cxx | 9 +++++---- src/emucore/CartF0.cxx | 9 +++++---- src/emucore/CartF4.cxx | 7 ++++--- src/emucore/CartF4SC.cxx | 9 +++++---- src/emucore/CartF6.cxx | 7 ++++--- src/emucore/CartF6SC.cxx | 9 +++++---- src/emucore/CartF8.cxx | 7 ++++--- src/emucore/CartF8SC.cxx | 9 +++++---- src/emucore/CartFA.cxx | 9 +++++---- src/emucore/CartFE.cxx | 1 + src/emucore/CartMC.cxx | 3 ++- src/emucore/CartSB.cxx | 7 ++++--- src/emucore/CartUA.cxx | 7 ++++--- src/emucore/CartX07.cxx | 7 ++++--- src/emucore/Props.cxx | 4 ++-- 32 files changed, 139 insertions(+), 97 deletions(-) diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index f53eea131..314cfec13 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -186,11 +186,9 @@ string CartDebug::toString() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartDebug::disassemble(bool autocode) { - bool changed = false; // Test current disassembly; don't re-disassemble if it hasn't changed // ... - changed = true; // FIXME - + bool changed = myConsole.cartridge().bankChanged(); if(changed) { myDisassembly.clear(); @@ -255,14 +253,13 @@ string CartDebug::disassemble(uInt16 start, uInt16 lines) const // Fill the string with disassembled data start &= 0xFFF; ostringstream buffer; - for(uInt32 i = 0; i < list.size() && lines > 0; ++i) + for(uInt32 i = 0; i < list.size() && lines > 0; ++i, --lines) { const CartDebug::DisassemblyTag& tag = list[i]; if((tag.address & 0xfff) >= start) { buffer << uppercase << hex << setw(4) << setfill('0') << tag.address << ": " << tag.disasm << " " << tag.bytes << endl; - --lines; } } diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index ff4c6b686..6c1db376c 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -208,7 +208,6 @@ void DiStella::disasm(uInt32 distart, int pass) else if (pass == 3) { nextline << ourLookup[op].mnemonic; -// sprintf(linebuff,"%02X ",op); nextlinebytes << HEX2 << (int)op << " "; } @@ -282,10 +281,7 @@ void DiStella::disasm(uInt32 distart, int pass) { if (op == 0x40 || op == 0x60) if (pass == 3) - { - sprintf(linebuff,"\n"); - strcat(_nextline,linebuff); - } + nextline << "\n"; break; } #endif diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index a2e17e213..0f0ad6d27 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -187,7 +187,7 @@ void RomWidget::loadConfig() myRomList->setList(list, state); // Restore the old bank, in case we inadvertently switched while reading. - dbg.setBank(myCurrentBank); +// dbg.setBank(myCurrentBank); // TODO - why is this here? myListIsDirty = false; } diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index e004c22ec..3db33607a 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -223,6 +223,7 @@ string Cartridge::createFromMultiCart(const uInt8*& image, uInt32& size, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cartridge::Cartridge() : myStartBank(0), + myBankChanged(true), myBankLocked(false) { } @@ -256,6 +257,14 @@ uInt16 Cartridge::startBank() return myStartBank; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge::bankChanged() +{ + bool changed = myBankChanged; + myBankChanged = false; + return changed; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge::registerRamArea(uInt16 start, uInt16 size, uInt16 roffset, uInt16 woffset) diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index bbf493b8f..900923581 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -91,8 +91,9 @@ class Cartridge : public Device the banks before querying the cart state, otherwise reading values could inadvertantly cause a bankswitch to occur. */ - void lockBank() { myBankLocked = true; } - void unlockBank() { myBankLocked = false; } + inline void lockBank() { myBankLocked = true; } + inline void unlockBank() { myBankLocked = false; } + inline bool bankLocked() { return myBankLocked; } /** Get the default startup bank for a cart. This is the bank where @@ -103,6 +104,14 @@ class Cartridge : public Device */ uInt16 startBank(); + /** + Answer whether the bank has changed since the last time this + method was called. + + @return Whether the bank was changed + */ + bool bankChanged(); + #ifdef DEBUGGER_SUPPORT const RamAreaList& ramAreas() { return myRamAreaList; } #endif @@ -301,15 +310,19 @@ class Cartridge : public Device // The startup bank to use (where to look for the reset vector address) uInt16 myStartBank; - // If myBankLocked is true, ignore attempts at bankswitching. This is used - // by the debugger, when disassembling/dumping ROM. - bool myBankLocked; + // Indicates if the bank has changed somehow (a bankswitch has occurred) + bool myBankChanged; private: #ifdef DEBUGGER_SUPPORT // Contains RamArea entries for those carts with accessible RAM. RamAreaList myRamAreaList; #endif + + // If myBankLocked is true, ignore attempts at bankswitching. This is used + // by the debugger, when disassembling/dumping ROM. + bool myBankLocked; + // Contains info about this cartridge in string format static string myAboutString; diff --git a/src/emucore/Cart0840.cxx b/src/emucore/Cart0840.cxx index ab457893a..7d226be1a 100644 --- a/src/emucore/Cart0840.cxx +++ b/src/emucore/Cart0840.cxx @@ -146,7 +146,7 @@ void Cartridge0840::poke(uInt16 address, uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge0840::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -164,7 +164,7 @@ void Cartridge0840::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } - + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -183,14 +183,14 @@ int Cartridge0840::bankCount() bool Cartridge0840::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0fff)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* Cartridge0840::getImage(int& size) { size = 8192; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Cart2K.cxx b/src/emucore/Cart2K.cxx index 20d4e35d9..0c7c42d42 100644 --- a/src/emucore/Cart2K.cxx +++ b/src/emucore/Cart2K.cxx @@ -60,6 +60,7 @@ Cartridge2K::~Cartridge2K() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge2K::reset() { + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -118,14 +119,14 @@ int Cartridge2K::bankCount() bool Cartridge2K::patch(uInt16 address, uInt8 value) { myImage[address & myMask] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* Cartridge2K::getImage(int& size) { size = mySize; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Cart3E.cxx b/src/emucore/Cart3E.cxx index b42ec08c0..d4fc63f59 100644 --- a/src/emucore/Cart3E.cxx +++ b/src/emucore/Cart3E.cxx @@ -114,7 +114,7 @@ uInt8 Cartridge3E::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) + if(bankLocked()) return value; else { @@ -156,7 +156,7 @@ void Cartridge3E::poke(uInt16 address, uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge3E::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; if(bank < 256) { @@ -218,6 +218,7 @@ void Cartridge3E::bank(uInt16 bank) mySystem->setPageAccess(address >> shift, access); } } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -247,14 +248,14 @@ bool Cartridge3E::patch(uInt16 address, uInt8 value) else myImage[(address & 0x07FF) + mySize - 2048] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* Cartridge3E::getImage(int& size) { size = mySize; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Cart3F.cxx b/src/emucore/Cart3F.cxx index 083c0cc2e..1c8a70358 100644 --- a/src/emucore/Cart3F.cxx +++ b/src/emucore/Cart3F.cxx @@ -47,7 +47,7 @@ Cartridge3F::~Cartridge3F() void Cartridge3F::reset() { // We'll map the startup bank into the first segment upon reset - bank(0); + bank(myStartBank); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -82,8 +82,8 @@ void Cartridge3F::install(System& system) mySystem->setPageAccess(j >> shift, access); } - // Install pages for bank 0 into the first segment - bank(0); + // Install pages for startup bank into the first segment + bank(myStartBank); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -122,7 +122,7 @@ void Cartridge3F::poke(uInt16 address, uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge3F::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Make sure the bank they're asking for is reasonable if(((uInt32)bank << 11) < mySize) @@ -150,6 +150,7 @@ void Cartridge3F::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x07FF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -174,14 +175,14 @@ bool Cartridge3F::patch(uInt16 address, uInt8 value) else myImage[(address & 0x07FF) + mySize - 2048] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* Cartridge3F::getImage(int& size) { size = mySize; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Cart4A50.cxx b/src/emucore/Cart4A50.cxx index bd9edfcc9..87ce6718e 100644 --- a/src/emucore/Cart4A50.cxx +++ b/src/emucore/Cart4A50.cxx @@ -27,6 +27,7 @@ // TODO - properly handle read from write port functionality // Note: do r/w port restrictions even exist for this scheme?? // Port to new CartDebug/disassembler scheme +// Add bankchanged code // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cartridge4A50::Cartridge4A50(const uInt8* image, uInt32 size) @@ -122,7 +123,7 @@ uInt8 Cartridge4A50::peek(uInt16 address) else if((address & 0x1f00) == 0x1f00) // 256B region from 0x1f00 - 0x1fff { value = myImage[(address & 0xff) + 0x1ff00]; - if(!myBankLocked && ((myLastData & 0xe0) == 0x60) && + if(!bankLocked() && ((myLastData & 0xe0) == 0x60) && ((myLastAddress >= 0x1000) || (myLastAddress < 0x200))) mySliceHigh = (mySliceHigh & 0xf0ff) | ((address & 0x8) << 8) | ((address & 0x70) << 4); @@ -168,7 +169,7 @@ void Cartridge4A50::poke(uInt16 address, uInt8 value) } else if((address & 0x1f00) == 0x1f00) // 256B region at 0x1f00 - 0x1fff { - if(!myBankLocked && ((myLastData & 0xe0) == 0x60) && + if(!bankLocked() && ((myLastData & 0xe0) == 0x60) && ((myLastAddress >= 0x1000) || (myLastAddress < 0x200))) mySliceHigh = (mySliceHigh & 0xf0ff) | ((address & 0x8) << 8) | ((address & 0x70) << 4); @@ -181,7 +182,7 @@ void Cartridge4A50::poke(uInt16 address, uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge4A50::checkBankSwitch(uInt16 address, uInt8 value) { - if(myBankLocked) return; + if(bankLocked()) return; // This scheme contains so many hotspots that it's easier to just check // all of them @@ -316,7 +317,7 @@ bool Cartridge4A50::patch(uInt16 address, uInt8 value) uInt8* Cartridge4A50::getImage(int& size) { size = 131072; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Cart4K.cxx b/src/emucore/Cart4K.cxx index 5ff399d1a..6029c82ba 100644 --- a/src/emucore/Cart4K.cxx +++ b/src/emucore/Cart4K.cxx @@ -37,6 +37,7 @@ Cartridge4K::~Cartridge4K() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge4K::reset() { + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -96,14 +97,14 @@ int Cartridge4K::bankCount() bool Cartridge4K::patch(uInt16 address, uInt8 value) { myImage[address & 0x0FFF] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* Cartridge4K::getImage(int& size) { size = 4096; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index eab8705b8..cc1cc6f9a 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -26,6 +26,7 @@ // TODO - properly handle read from write port functionality // Note: do r/w port restrictions even exist for this scheme?? // Port to new CartDebug/disassembler scheme +// Add bankchanged code // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeAR::CartridgeAR(const uInt8* image, uInt32 size, @@ -392,7 +393,7 @@ void CartridgeAR::loadIntoRAM(uInt8 load) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeAR::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; bankConfiguration(bank); } diff --git a/src/emucore/CartCV.cxx b/src/emucore/CartCV.cxx index 6b94f0161..cbb440806 100644 --- a/src/emucore/CartCV.cxx +++ b/src/emucore/CartCV.cxx @@ -22,6 +22,9 @@ #include "System.hxx" #include "CartCV.hxx" +// TODO - Port to new CartDebug/disassembler scheme +// Add bankchanged code + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeCV::CartridgeCV(const uInt8* image, uInt32 size) : myROM(0), @@ -113,7 +116,7 @@ uInt8 CartridgeCV::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) + if(bankLocked()) return value; else { @@ -163,7 +166,7 @@ bool CartridgeCV::patch(uInt16 address, uInt8 value) uInt8* CartridgeCV::getImage(int& size) { size = 2048; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index d53da3cfc..f24e0ac45 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -26,6 +26,7 @@ // TODO - properly handle read from write port functionality // Note: do r/w port restrictions even exist for this scheme?? // Port to new CartDebug/disassembler scheme +// Add bankchanged code // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeDPC::CartridgeDPC(const uInt8* image, uInt32 size) @@ -420,7 +421,7 @@ void CartridgeDPC::poke(uInt16 address, uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeDPC::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; diff --git a/src/emucore/CartE0.cxx b/src/emucore/CartE0.cxx index 7bad17a8f..a3bb7c2c0 100644 --- a/src/emucore/CartE0.cxx +++ b/src/emucore/CartE0.cxx @@ -23,6 +23,7 @@ #include "CartE0.hxx" // TODO - Port to new CartDebug/disassembler scheme +// Add bankchanged code // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeE0::CartridgeE0(const uInt8* image) @@ -127,7 +128,7 @@ void CartridgeE0::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeE0::segmentZero(uInt16 slice) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember the new slice myCurrentSlice[0] = slice; @@ -149,7 +150,7 @@ void CartridgeE0::segmentZero(uInt16 slice) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeE0::segmentOne(uInt16 slice) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember the new slice myCurrentSlice[1] = slice; @@ -171,7 +172,7 @@ void CartridgeE0::segmentOne(uInt16 slice) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeE0::segmentTwo(uInt16 slice) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember the new slice myCurrentSlice[2] = slice; diff --git a/src/emucore/CartE7.cxx b/src/emucore/CartE7.cxx index 817805639..c23d959cc 100644 --- a/src/emucore/CartE7.cxx +++ b/src/emucore/CartE7.cxx @@ -24,6 +24,7 @@ // TODO - Port to new CartDebug/disassembler scheme // I'm not sure patch is working, since it doesn't consider RAM areas +// Add bankchanged code // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeE7::CartridgeE7(const uInt8* image) @@ -116,7 +117,7 @@ uInt8 CartridgeE7::peek(uInt16 address) // Reading from the 1K write port @ $1000 triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) + if(bankLocked()) return value; else { @@ -129,7 +130,7 @@ uInt8 CartridgeE7::peek(uInt16 address) // Reading from the 256B write port @ $1800 triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) + if(bankLocked()) return value; else { @@ -164,7 +165,7 @@ void CartridgeE7::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeE7::bankRAM(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentRAM = bank; @@ -197,7 +198,7 @@ void CartridgeE7::bankRAM(uInt16 bank) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeE7::bank(uInt16 slice) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentSlice[0] = slice; diff --git a/src/emucore/CartEF.cxx b/src/emucore/CartEF.cxx index ef970634c..a390f4be7 100644 --- a/src/emucore/CartEF.cxx +++ b/src/emucore/CartEF.cxx @@ -93,7 +93,7 @@ void CartridgeEF::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeEF::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -113,6 +113,7 @@ void CartridgeEF::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -131,14 +132,14 @@ int CartridgeEF::bankCount() bool CartridgeEF::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeEF::getImage(int& size) { size = 65536; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartEFSC.cxx b/src/emucore/CartEFSC.cxx index bf4c2af81..744821024 100644 --- a/src/emucore/CartEFSC.cxx +++ b/src/emucore/CartEFSC.cxx @@ -108,7 +108,7 @@ uInt8 CartridgeEFSC::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) + if(bankLocked()) return value; else { @@ -137,7 +137,7 @@ void CartridgeEFSC::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeEFSC::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -157,6 +157,7 @@ void CartridgeEFSC::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -175,14 +176,14 @@ int CartridgeEFSC::bankCount() bool CartridgeEFSC::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeEFSC::getImage(int& size) { size = 65536; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartF0.cxx b/src/emucore/CartF0.cxx index 02b0890f2..7e76a03a4 100644 --- a/src/emucore/CartF0.cxx +++ b/src/emucore/CartF0.cxx @@ -95,7 +95,7 @@ void CartridgeF0::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeF0::incbank() { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank++; @@ -116,12 +116,13 @@ void CartridgeF0::incbank() access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeF0::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; myCurrentBank = bank - 1; incbank(); @@ -143,14 +144,14 @@ int CartridgeF0::bankCount() bool CartridgeF0::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeF0::getImage(int& size) { size = 65536; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartF4.cxx b/src/emucore/CartF4.cxx index 74424fdc6..b18590547 100644 --- a/src/emucore/CartF4.cxx +++ b/src/emucore/CartF4.cxx @@ -98,7 +98,7 @@ void CartridgeF4::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeF4::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -118,6 +118,7 @@ void CartridgeF4::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -136,14 +137,14 @@ int CartridgeF4::bankCount() bool CartridgeF4::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeF4::getImage(int& size) { size = 32768; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartF4SC.cxx b/src/emucore/CartF4SC.cxx index be0c58537..fcb1c93ef 100644 --- a/src/emucore/CartF4SC.cxx +++ b/src/emucore/CartF4SC.cxx @@ -108,7 +108,7 @@ uInt8 CartridgeF4SC::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) + if(bankLocked()) return value; else { @@ -140,7 +140,7 @@ void CartridgeF4SC::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeF4SC::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -160,6 +160,7 @@ void CartridgeF4SC::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -178,14 +179,14 @@ int CartridgeF4SC::bankCount() bool CartridgeF4SC::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeF4SC::getImage(int& size) { size = 32768; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartF6.cxx b/src/emucore/CartF6.cxx index 3f577bcc1..0ca513d34 100644 --- a/src/emucore/CartF6.cxx +++ b/src/emucore/CartF6.cxx @@ -139,7 +139,7 @@ void CartridgeF6::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeF6::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -159,6 +159,7 @@ void CartridgeF6::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -177,14 +178,14 @@ int CartridgeF6::bankCount() bool CartridgeF6::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeF6::getImage(int& size) { size = 16384; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartF6SC.cxx b/src/emucore/CartF6SC.cxx index ae531c925..85d6ed27c 100644 --- a/src/emucore/CartF6SC.cxx +++ b/src/emucore/CartF6SC.cxx @@ -131,7 +131,7 @@ uInt8 CartridgeF6SC::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) + if(bankLocked()) return value; else { @@ -183,7 +183,7 @@ void CartridgeF6SC::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeF6SC::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -203,6 +203,7 @@ void CartridgeF6SC::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -221,14 +222,14 @@ int CartridgeF6SC::bankCount() bool CartridgeF6SC::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeF6SC::getImage(int& size) { size = 16384; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartF8.cxx b/src/emucore/CartF8.cxx index 45c2505c3..0616ad98a 100644 --- a/src/emucore/CartF8.cxx +++ b/src/emucore/CartF8.cxx @@ -120,7 +120,7 @@ void CartridgeF8::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeF8::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -140,6 +140,7 @@ void CartridgeF8::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -158,14 +159,14 @@ int CartridgeF8::bankCount() bool CartridgeF8::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeF8::getImage(int& size) { size = 8192; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartF8SC.cxx b/src/emucore/CartF8SC.cxx index 561f9254f..d5d454c4d 100644 --- a/src/emucore/CartF8SC.cxx +++ b/src/emucore/CartF8SC.cxx @@ -121,7 +121,7 @@ uInt8 CartridgeF8SC::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) + if(bankLocked()) return value; else { @@ -163,7 +163,7 @@ void CartridgeF8SC::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeF8SC::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -183,6 +183,7 @@ void CartridgeF8SC::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -201,14 +202,14 @@ int CartridgeF8SC::bankCount() bool CartridgeF8SC::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeF8SC::getImage(int& size) { size = 8192; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartFA.cxx b/src/emucore/CartFA.cxx index 12b8a0c80..a51965400 100644 --- a/src/emucore/CartFA.cxx +++ b/src/emucore/CartFA.cxx @@ -126,7 +126,7 @@ uInt8 CartridgeFA::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) + if(bankLocked()) return value; else { @@ -173,7 +173,7 @@ void CartridgeFA::poke(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeFA::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -193,6 +193,7 @@ void CartridgeFA::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -211,14 +212,14 @@ int CartridgeFA::bankCount() bool CartridgeFA::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeFA::getImage(int& size) { size = 12288; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartFE.cxx b/src/emucore/CartFE.cxx index 93dddbf99..7e0ad4094 100644 --- a/src/emucore/CartFE.cxx +++ b/src/emucore/CartFE.cxx @@ -23,6 +23,7 @@ #include "CartFE.hxx" // TODO - Port to new CartDebug/disassembler scheme +// Add bankchanged code // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeFE::CartridgeFE(const uInt8* image) diff --git a/src/emucore/CartMC.cxx b/src/emucore/CartMC.cxx index 3edb3b607..36d4b44fc 100644 --- a/src/emucore/CartMC.cxx +++ b/src/emucore/CartMC.cxx @@ -26,6 +26,7 @@ // No test ROMs exist as of 2009-11-08, so we can't be sure how // accurate the emulation is // Port to new CartDebug/disassembler scheme +// Add bankchanged code // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeMC::CartridgeMC(const uInt8* image, uInt32 size) @@ -147,7 +148,7 @@ uInt8 CartridgeMC::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) return value; + if(bankLocked()) return value; else return myRAM[(uInt32)((block & 0x3F) << 9) + (address & 0x01FF)] = value; } } diff --git a/src/emucore/CartSB.cxx b/src/emucore/CartSB.cxx index 2e9c9964a..2042ed30b 100644 --- a/src/emucore/CartSB.cxx +++ b/src/emucore/CartSB.cxx @@ -125,7 +125,7 @@ void CartridgeSB::poke(uInt16 address, uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeSB::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -143,6 +143,7 @@ void CartridgeSB::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -161,14 +162,14 @@ int CartridgeSB::bankCount() bool CartridgeSB::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeSB::getImage(int& size) { size = mySize; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartUA.cxx b/src/emucore/CartUA.cxx index e95227585..6314ffb49 100644 --- a/src/emucore/CartUA.cxx +++ b/src/emucore/CartUA.cxx @@ -133,7 +133,7 @@ void CartridgeUA::poke(uInt16 address, uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeUA::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = bank; @@ -151,6 +151,7 @@ void CartridgeUA::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -169,14 +170,14 @@ int CartridgeUA::bankCount() bool CartridgeUA::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeUA::getImage(int& size) { size = 8192; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartX07.cxx b/src/emucore/CartX07.cxx index d46f3072f..06f1a3d15 100644 --- a/src/emucore/CartX07.cxx +++ b/src/emucore/CartX07.cxx @@ -119,7 +119,7 @@ void CartridgeX07::poke(uInt16 address, uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeX07::bank(uInt16 bank) { - if(myBankLocked) return; + if(bankLocked()) return; // Remember what bank we're in myCurrentBank = (bank & 0x0f); @@ -137,6 +137,7 @@ void CartridgeX07::bank(uInt16 bank) access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; mySystem->setPageAccess(address >> shift, access); } + myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -155,14 +156,14 @@ int CartridgeX07::bankCount() bool CartridgeX07::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; - return true; + return myBankChanged = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8* CartridgeX07::getImage(int& size) { size = 65536; - return &myImage[0]; + return myImage; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Props.cxx b/src/emucore/Props.cxx index 7ea559df3..733781942 100644 --- a/src/emucore/Props.cxx +++ b/src/emucore/Props.cxx @@ -229,9 +229,9 @@ void Properties::copy(const Properties& properties) void Properties::print() const { cout << get(Cartridge_MD5) << "|" + << get(Cartridge_Name) << "|" << get(Cartridge_Manufacturer) << "|" << get(Cartridge_ModelNo) << "|" - << get(Cartridge_Name) << "|" << get(Cartridge_Note) << "|" << get(Cartridge_Rarity) << "|" << get(Cartridge_Sound) << "|" @@ -273,9 +273,9 @@ PropertyType Properties::getPropertyType(const string& name) void Properties::printHeader() { cout << "Cartridge_MD5|" + << "Cartridge_Name|" << "Cartridge_Manufacturer|" << "Cartridge_ModelNo|" - << "Cartridge_Name|" << "Cartridge_Note|" << "Cartridge_Rarity|" << "Cartridge_Sound|"