diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index 10746ea23..bdeca3e1c 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -208,10 +208,6 @@ void Debugger::setConsole(Console* console) // FIXME - these will probably be removed // loadListFile(); - - // Make sure cart RAM is added before this is called, - // otherwise the debugger state won't know about it - saveOldState(false); // don't add the state to the rewind list } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -668,6 +664,9 @@ void Debugger::setStartState() // Start a new rewind list myRewindManager->clear(); + + // Save initial state, but don't add it to the rewind list + saveOldState(false); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index 7c7902b2d..2db7fb96c 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -286,8 +286,7 @@ void Cartridge::registerRamArea(uInt16 start, uInt16 size, void Cartridge::triggerReadFromWritePort(uInt16 address) { #ifdef DEBUGGER_SUPPORT - if(&Debugger::debugger().cartDebug()) - Debugger::debugger().cartDebug().triggerReadFromWritePort(address); + Debugger::debugger().cartDebug().triggerReadFromWritePort(address); #endif } diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 2ff2f2843..9151cbbb4 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -111,6 +111,12 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props) mySystem->attach(myTIA); mySystem->attach(myCart); +#ifdef DEBUGGER_SUPPORT + // The debugger must be added before we run the console for the first time + myOSystem->debugger().setConsole(this); + myOSystem->debugger().initialize(); +#endif + // Auto-detect NTSC/PAL mode if it's requested string autodetected = ""; myDisplayFormat = myProperties.get(Display_Format); diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 115ea4d38..ae5dd1d56 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -511,10 +511,6 @@ bool OSystem::createConsole(const string& romfile, const string& md5sum) return false; } if(!audiofirst) myConsole->initializeAudio(); - #ifdef DEBUGGER_SUPPORT - myDebugger->setConsole(myConsole); - myDebugger->initialize(); - #endif if(showmessage) myFrameBuffer->showMessage("New console created"); diff --git a/src/emucore/System.cxx b/src/emucore/System.cxx index f576dcbcf..0ed72ad42 100644 --- a/src/emucore/System.cxx +++ b/src/emucore/System.cxx @@ -56,6 +56,7 @@ System::System(uInt16 n, uInt16 m) for(int page = 0; page < myNumberOfPages; ++page) { setPageAccess(page, access); + myPageIsDirtyTable[page] = false; } // Bus starts out unlocked (in other words, peek() changes myDataBusState) @@ -99,6 +100,9 @@ void System::reset() { myM6502->reset(); } + + // There are no dirty pages upon startup + clearDirtyPages(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -157,7 +161,7 @@ void System::resetCycles() void System::setPageAccess(uInt16 page, const PageAccess& access) { // Make sure the page is within range - assert(page <= myNumberOfPages); + assert(page < myNumberOfPages); // Make sure the access methods make sense assert(access.device != 0); @@ -169,7 +173,7 @@ void System::setPageAccess(uInt16 page, const PageAccess& access) const System::PageAccess& System::getPageAccess(uInt16 page) const { // Make sure the page is within range - assert(page <= myNumberOfPages); + assert(page < myNumberOfPages); return myPageAccessTable[page]; } @@ -253,8 +257,8 @@ void System::poke(uInt16 addr, uInt8 value) if(access.directPokeBase != 0) { // Since we have direct access to this poke, we can dirty its page - myPageIsDirtyTable[page] = true; *(access.directPokeBase + (addr & myPageMask)) = value; + myPageIsDirtyTable[page] = true; } else { diff --git a/src/emucore/System.hxx b/src/emucore/System.hxx index ca4bd8353..8e1381ba7 100644 --- a/src/emucore/System.hxx +++ b/src/emucore/System.hxx @@ -41,12 +41,6 @@ class NullDevice; In general the addressing space will be 8192 (2^13) bytes for a 6507 based system and 65536 (2^16) bytes for a 6502 based system. - TODO: To allow for dynamic code generation we probably need to - add a tag to each page that indicates if it is read only - memory. We also need to notify the processor anytime a - page access method is changed so that it can clear the - dynamic code for that page of memory. - @author Bradford W. Mott @version $Id$ */ @@ -378,7 +372,7 @@ class System : public Serializable @return The name of the object */ - virtual string name() const { return "System"; } + string name() const { return "System"; } private: // Mask to apply to an address before accessing memory