diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 5b54563f5..5d2654764 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -156,6 +156,18 @@ void CartDebug::saveOldState() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int CartDebug::lastReadAddress() +{ + return mySystem.m6502().lastReadAddress(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int CartDebug::lastWriteAddress() +{ + return mySystem.m6502().lastWriteAddress(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int CartDebug::lastReadBaseAddress() { diff --git a/src/debugger/CartDebug.hxx b/src/debugger/CartDebug.hxx index 57a9e1319..3561b3d3e 100644 --- a/src/debugger/CartDebug.hxx +++ b/src/debugger/CartDebug.hxx @@ -104,6 +104,12 @@ class CartDebug : public DebuggerSystem CartDebugWidget* getDebugWidget() const { return myDebugWidget; } void setDebugWidget(CartDebugWidget* w) { myDebugWidget = w; } + + // Return the address of the last CPU read + int lastReadAddress(); + // Return the address of the last CPU write + int lastWriteAddress(); + // Return the base (= non-mirrored) address of the last CPU read int lastReadBaseAddress(); // Return the base (= non-mirrored) address of the last CPU write diff --git a/src/debugger/CpuDebug.cxx b/src/debugger/CpuDebug.cxx index 549d512e3..b7d26c3b5 100644 --- a/src/debugger/CpuDebug.cxx +++ b/src/debugger/CpuDebug.cxx @@ -46,6 +46,7 @@ const DebuggerState& CpuDebug::getState() myState.srcA = my6502.lastSrcAddressA(); myState.srcX = my6502.lastSrcAddressX(); myState.srcY = my6502.lastSrcAddressY(); + myState.dest = my6502.lastWriteAddress(); Debugger::set_bits(myState.PS, myState.PSbits); @@ -66,6 +67,7 @@ void CpuDebug::saveOldState() myOldState.srcA = my6502.lastSrcAddressA(); myOldState.srcX = my6502.lastSrcAddressX(); myOldState.srcY = my6502.lastSrcAddressY(); + myOldState.dest = my6502.lastWriteAddress(); Debugger::set_bits(myOldState.PS, myOldState.PSbits); } diff --git a/src/debugger/CpuDebug.hxx b/src/debugger/CpuDebug.hxx index a9d9bc99c..dd016fe88 100644 --- a/src/debugger/CpuDebug.hxx +++ b/src/debugger/CpuDebug.hxx @@ -31,7 +31,7 @@ class CpuState : public DebuggerState { public: int PC{0}, SP{0}, PS{0}, A{0}, X{0}, Y{0}; - int srcS{0}, srcA{0}, srcX{0}, srcY{0}; + int srcS{0}, srcA{0}, srcX{0}, srcY{0}, dest{0}; BoolArray PSbits; }; diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index 1ccf5e3f1..8cdd525de 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -887,6 +887,8 @@ std::array Debugger::ourPseudoRegisters = { { { "_vblank", "Whether vertical blank is enabled (1 or 0)" }, { "_vsync", "Whether vertical sync is enabled (1 or 0)" } // CPU address access functions: - /*{ "__lastread", "last CPU read address" }, - { "__lastwrite", "last CPU write address" },*/ + /*{ "_lastread", "last CPU read address" }, + { "_lastwrite", "last CPU write address" }, + { "__lastbaseread", "last CPU read base address" }, + { "__lastbasewrite", "last CPU write base address" }*/ } }; diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 50ff2daae..f3dfde946 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -2054,18 +2054,18 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command, if(read) { if(beginRead != endRead) - conditionBuf << "__lastread>=" << Base::toString(beginRead) << "&&__lastread<=" << Base::toString(endRead); + conditionBuf << "__lastbaseread>=" << Base::toString(beginRead) << "&&__lastbaseread<=" << Base::toString(endRead); else - conditionBuf << "__lastread==" << Base::toString(beginRead); + conditionBuf << "__lastbaseread==" << Base::toString(beginRead); } if(read && write) conditionBuf << "||"; if(write) { if(beginWrite != endWrite) - conditionBuf << "__lastwrite>=" << Base::toString(beginWrite) << "&&__lastwrite<=" << Base::toString(endWrite); + conditionBuf << "__lastbasewrite>=" << Base::toString(beginWrite) << "&&__lastbasewrite<=" << Base::toString(endWrite); else - conditionBuf << "__lastwrite==" << Base::toString(beginWrite); + conditionBuf << "__lastbasewrite==" << Base::toString(beginWrite); } // parenthesize provided condition (end) if(hasCond) diff --git a/src/debugger/gui/CpuWidget.cxx b/src/debugger/gui/CpuWidget.cxx index cd6b87640..87aba7d34 100644 --- a/src/debugger/gui/CpuWidget.cxx +++ b/src/debugger/gui/CpuWidget.cxx @@ -93,10 +93,11 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n myCpuDataSrc[i]->setEditable(false, true); src_y += fontHeight+2; } - int swidth = lfont.getStringWidth("Source Address"); - new StaticTextWidget(boss, lfont, xpos, src_y + 4, src_w, - fontHeight, swidth <= src_w ? "Source Address" : "Source Addr", - TextAlign::Center); + + // Last write destination address + new StaticTextWidget(boss, lfont, xpos - fontWidth * 4.5, src_y + 4, "Dest"); + myCpuDataDest = new EditTextWidget(boss, nfont, xpos, src_y + 2, src_w, fontHeight+1); + myCpuDataDest->setEditable(false, true); // Add labels for other CPU registers xpos = x; @@ -325,6 +326,10 @@ void CpuWidget::loadConfig() myCpuDataSrc[3]->setText((srcY != EmptyString ? srcY : Common::Base::toString(state.srcY)), state.srcY != oldstate.srcY); + const string& dest = state.dest < 0 ? "" : cart.getLabel(state.dest, false); + myCpuDataDest->setText((srcY != EmptyString ? dest : Common::Base::toString(state.dest)), + state.dest != oldstate.dest); + // Update the PS register booleans changed.clear(); for(uInt32 i = 0; i < state.PSbits.size(); ++i) diff --git a/src/debugger/gui/CpuWidget.hxx b/src/debugger/gui/CpuWidget.hxx index 5008002f5..5992970f3 100644 --- a/src/debugger/gui/CpuWidget.hxx +++ b/src/debugger/gui/CpuWidget.hxx @@ -76,6 +76,7 @@ class CpuWidget : public Widget, public CommandSender ToggleBitWidget* myPSRegister{nullptr}; EditTextWidget* myPCLabel{nullptr}; std::array myCpuDataSrc{nullptr}; + EditTextWidget* myCpuDataDest{nullptr}; private: // Following constructors and assignment operators not supported diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index a69213b69..29863c306 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -300,8 +300,8 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) mySystem->cart().clearAllRAMAccesses(); #endif // DEBUGGER_SUPPORT - // Reset the peek/poke address pointers - myLastPeekAddress = myLastPokeAddress = myDataAddressForPoke = 0; + // Reset the data poke address pointer + myDataAddressForPoke = 0; try { uInt16 operandAddress = 0, intermediateAddress = 0; diff --git a/src/emucore/M6502.hxx b/src/emucore/M6502.hxx index d4769e0e7..c05fbc522 100644 --- a/src/emucore/M6502.hxx +++ b/src/emucore/M6502.hxx @@ -156,13 +156,27 @@ class M6502 : public Serializable @return The address of the last read */ - uInt16 lastReadBaseAddress() const { return myLastPeekBaseAddress; } + uInt16 lastReadAddress() const { return myLastPeekAddress; } /** Return the last address that was part of a write/poke. @return The address of the last write */ + uInt16 lastWriteAddress() const { return myLastPokeAddress; } + + /** + Return the last (non-mirrored) address that was part of a read/peek. + + @return The address of the last read + */ + uInt16 lastReadBaseAddress() const { return myLastPeekBaseAddress; } + + /** + Return the last (non-mirrored) address that was part of a write/poke. + + @return The address of the last write + */ uInt16 lastWriteBaseAddress() const { return myLastPokeBaseAddress; } /** diff --git a/src/yacc/YaccParser.cxx b/src/yacc/YaccParser.cxx index 696987b38..82163c433 100644 --- a/src/yacc/YaccParser.cxx +++ b/src/yacc/YaccParser.cxx @@ -181,10 +181,15 @@ CartMethod getCartSpecial(char* ch) { if(BSPF::equalsIgnoreCase(ch, "_bank")) return &CartDebug::getPCBank; - else if(BSPF::equalsIgnoreCase(ch, "__lastread")) + + else if(BSPF::equalsIgnoreCase(ch, "__lastbaseread")) return &CartDebug::lastReadBaseAddress; - else if(BSPF::equalsIgnoreCase(ch, "__lastwrite")) + else if(BSPF::equalsIgnoreCase(ch, "__lastbasewrite")) return &CartDebug::lastWriteBaseAddress; + else if(BSPF::equalsIgnoreCase(ch, "__lastread")) + return &CartDebug::lastReadAddress; + else if(BSPF::equalsIgnoreCase(ch, "__lastwrite")) + return &CartDebug::lastWriteAddress; else return nullptr; }