diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index ff3f24bf7..f55308007 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -2187,12 +2187,12 @@ void EventHandler::setEventState(EventHandlerState state) myEvent.clear(); break; -#ifdef DEBUGGER_SUPPORT case EventHandlerState::DEBUGGER: + #ifdef DEBUGGER_SUPPORT myOverlay = &myOSystem.debugger(); enableTextEvents(true); + #endif break; -#endif case EventHandlerState::NONE: myOverlay = nullptr; diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 231656b9c..ca7b17d04 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -339,13 +339,13 @@ void FrameBuffer::update() break; // EventHandlerState::LAUNCHER } -#ifdef DEBUGGER_SUPPORT case EventHandlerState::DEBUGGER: { + #ifdef DEBUGGER_SUPPORT myOSystem.debugger().draw(true); + #endif break; // EventHandlerState::DEBUGGER } -#endif case EventHandlerState::NONE: return; diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index 367c80845..be39a27e6 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -69,12 +69,12 @@ M6502::M6502(const Settings& settings) myDataAddressForPoke(0), myOnHaltCallback(nullptr), myHaltRequested(false), + myGhostReadsTrap(true), myStepStateByInstruction(false) { #ifdef DEBUGGER_SUPPORT myDebugger = nullptr; myJustHitReadTrapFlag = myJustHitWriteTrapFlag = false; - myGhostReadsTrap = true; #endif } @@ -210,7 +210,10 @@ inline void M6502::handleHalt() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void M6502::updateStepStateByInstruction() { + // Currently only used in debugger mode +#ifdef DEBUGGER_SUPPORT myStepStateByInstruction = myCondBreaks.size() || myCondSaveStates.size() || myTrapConds.size(); +#endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -218,6 +221,7 @@ bool M6502::execute(uInt32 number) { const bool status = _execute(number); +#ifdef DEBUGGER_SUPPORT // Debugger hack: this ensures that stepping a "STA WSYNC" will actually end at the // beginning of the next line (otherwise, the next instruction would be stepped in order for // the halt to take effect). This is safe because as we know that the next cycle will be a read @@ -228,6 +232,7 @@ bool M6502::execute(uInt32 number) // to maintain a consistent state for the debugger after stepping. mySystem->tia().updateEmulation(); mySystem->m6532().updateEmulation(); +#endif return status; } @@ -248,7 +253,7 @@ inline bool M6502::_execute(uInt32 number) { for(; !myExecutionStatus && (number != 0); --number) { -#ifdef DEBUGGER_SUPPORT + #ifdef DEBUGGER_SUPPORT if(myJustHitReadTrapFlag || myJustHitWriteTrapFlag) { bool read = myJustHitReadTrapFlag; @@ -279,7 +284,7 @@ inline bool M6502::_execute(uInt32 number) msg << "conditional savestate [" << Common::Base::HEX2 << cond << "]"; myDebugger->addState(msg.str()); } -#endif // DEBUGGER_SUPPORT + #endif // DEBUGGER_SUPPORT uInt16 operandAddress = 0, intermediateAddress = 0; uInt8 operand = 0; @@ -301,17 +306,17 @@ inline bool M6502::_execute(uInt32 number) // Oops, illegal instruction executed so set fatal error flag myExecutionStatus |= FatalErrorBit; } - //cycles = mySystem->cycles() - c0; -#ifdef DEBUGGER_SUPPORT - if (myStepStateByInstruction) { + #ifdef DEBUGGER_SUPPORT + if(myStepStateByInstruction) + { // Check out M6502::execute for an explanation. handleHalt(); tia.updateEmulation(); riot.updateEmulation(); } -#endif + #endif } // See if we need to handle an interrupt diff --git a/src/emucore/M6502.hxx b/src/emucore/M6502.hxx index c0b114664..3c88674ac 100644 --- a/src/emucore/M6502.hxx +++ b/src/emucore/M6502.hxx @@ -445,8 +445,6 @@ class M6502 : public Serializable int address; }; HitTrapInfo myHitTrapInfo; - // trap on ghost reads - bool myGhostReadsTrap; vector> myCondBreaks; StringList myCondBreakNames; @@ -454,11 +452,13 @@ class M6502 : public Serializable StringList myCondSaveStateNames; vector> myTrapConds; StringList myTrapCondNames; - - bool myStepStateByInstruction; - #endif // DEBUGGER_SUPPORT + // These are both used only by the debugger, but since they're included + // in save states, they cannot be conditionally compiled + bool myGhostReadsTrap; // trap on ghost reads + bool myStepStateByInstruction; + private: // Following constructors and assignment operators not supported M6502() = delete; diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 4c5110a1b..95175dc67 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -264,12 +264,12 @@ FBInitStatus OSystem::createFrameBuffer() return fbstatus; break; -#ifdef DEBUGGER_SUPPORT case EventHandlerState::DEBUGGER: + #ifdef DEBUGGER_SUPPORT if((fbstatus = myDebugger->initializeVideo()) != FBInitStatus::Success) return fbstatus; + #endif break; -#endif case EventHandlerState::NONE: // Should never happen logMessage("ERROR: Unknown emulation state in createFrameBuffer()", 0); diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index a2805d9d2..f7ebf2910 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -1709,14 +1709,10 @@ void TIA::toggleCollBLPF() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIA::createAccessBase() { -#ifdef DEBUGGER_SUPPORT myAccessBase = make_unique(TIA_SIZE); memset(myAccessBase.get(), CartDebug::NONE, TIA_SIZE); myAccessDelay = make_unique(TIA_SIZE); memset(myAccessDelay.get(), TIA_DELAY, TIA_SIZE); -#else - myAccessBase = nullptr; -#endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index 0fb54caee..84e2b8a06 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -776,13 +776,14 @@ class TIA : public Device bool myEnableJitter; uInt8 myJitterFactor; -#ifdef DEBUGGER_SUPPORT + #ifdef DEBUGGER_SUPPORT // The arrays containing information about every byte of TIA // indicating whether and how (RW) it is used. BytePtr myAccessBase; + // The array used to skip the first two TIA access trackings BytePtr myAccessDelay; -#endif // DEBUGGER_SUPPORT + #endif // DEBUGGER_SUPPORT static constexpr uInt16 TIA_SIZE = 0x40, TIA_MASK = TIA_SIZE - 1, TIA_READ_MASK = 0x0f, TIA_BIT = 0x080, TIA_DELAY = 2; diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index b68010369..b19a7ebcb 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -44,7 +44,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DeveloperDialog::DeveloperDialog(OSystem& osystem, DialogContainer& parent, - const GUI::Font& font, int max_w, int max_h) + const GUI::Font& font, int max_w, int max_h) : Dialog(osystem, parent) { const int VGAP = 4; @@ -375,13 +375,13 @@ void DeveloperDialog::addTimeMachineTab(const GUI::Font& font) void DeveloperDialog::addDebuggerTab(const GUI::Font& font) { int tabID = myTab->addTab("Debugger"); + WidgetArray wid; #ifdef DEBUGGER_SUPPORT const int HBORDER = 10; const int VBORDER = 8; const int VGAP = 4; - WidgetArray wid; VariantList items; int fontWidth = font.getMaxCharWidth(), fontHeight = font.getFontHeight(), @@ -473,7 +473,7 @@ void DeveloperDialog::addDebuggerTab(const GUI::Font& font) // Add items for tab 1 addToFocusList(wid, myTab, tabID); #else - new StaticTextWidget(myTab, font, 0, 20, _w - 20, fontHeight, + new StaticTextWidget(myTab, font, 0, 20, _w - 20, font.getFontHeight(), "Debugger support not included", TextAlign::Center); #endif @@ -1199,6 +1199,7 @@ void DeveloperDialog::handleDebugColours(const string& colors) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::handleFontSize() { +#ifdef DEBUGGER_SUPPORT uInt32 minW, minH; int fontSize = myDebuggerFontSize->getSelected(); @@ -1233,4 +1234,5 @@ void DeveloperDialog::handleFontSize() myDebuggerHeightSlider->setValue(minH); myDebuggerHeightLabel->setValue(minH); } +#endif } diff --git a/src/gui/DeveloperDialog.hxx b/src/gui/DeveloperDialog.hxx index 113b34b2b..27577b89f 100644 --- a/src/gui/DeveloperDialog.hxx +++ b/src/gui/DeveloperDialog.hxx @@ -183,9 +183,7 @@ class DeveloperDialog : public Dialog void handleUncompressed(); void handleInterval(); void handleHorizon(); -#ifdef DEBUGGER_SUPPORT void handleFontSize(); -#endif // Following constructors and assignment operators not supported DeveloperDialog() = delete;