From f02995b4854a0aa7a9e38114e8df54df05c4a313 Mon Sep 17 00:00:00 2001 From: stephena Date: Tue, 20 Aug 2013 14:00:25 +0000 Subject: [PATCH] CPU register 'source' addresses in the debugger now show labels, when applicable. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2802 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/debugger/CartDebug.cxx | 13 ++++++++++--- src/debugger/CartDebug.hxx | 1 + src/debugger/DebuggerParser.cxx | 1 + src/debugger/gui/CpuWidget.cxx | 14 +++++++++----- src/debugger/gui/DebuggerDialog.cxx | 2 -- src/emucore/M6502.cxx | 26 +++++++++++++------------- src/emucore/M6502.hxx | 16 ++++++++-------- src/emucore/M6502.ins | 2 +- src/emucore/M6502.m4 | 2 +- src/gui/EditTextWidget.cxx | 2 ++ 10 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 5218eab99..5cb3e2b26 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -691,10 +691,17 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead, int places) con } } - if(places > -1) + switch(places) { - buf << "$" << setw(places) << hex << addr; - return true; + case 2: + buf << "$" << Base::HEX2 << addr; + return true; + case 4: + buf << "$" << Base::HEX4 << addr; + return true; + case 8: + buf << "$" << Base::HEX8 << addr; + return true; } return false; diff --git a/src/debugger/CartDebug.hxx b/src/debugger/CartDebug.hxx index ed4529107..672dc9957 100644 --- a/src/debugger/CartDebug.hxx +++ b/src/debugger/CartDebug.hxx @@ -29,6 +29,7 @@ class CartDebugWidget; #include "bspf.hxx" #include "Array.hxx" +#include "Base.hxx" #include "Cart.hxx" #include "DebuggerSystem.hxx" #include "System.hxx" diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index bddae36f7..3d41e09c3 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -1540,6 +1540,7 @@ void DebuggerParser::executeUHex() Base::setHexUppercase(enable); settings.setValue("dbg.uhex", enable); + debugger.rom().invalidate(); commandResult << "uppercase HEX " << (enable ? "enabled" : "disabled"); } diff --git a/src/debugger/gui/CpuWidget.cxx b/src/debugger/gui/CpuWidget.cxx index a5a7b8f2a..944bf794e 100644 --- a/src/debugger/gui/CpuWidget.cxx +++ b/src/debugger/gui/CpuWidget.cxx @@ -246,6 +246,7 @@ void CpuWidget::loadConfig() // We push the enumerated items as addresses, and deal with the real // address in the callback (handleCommand) Debugger& dbg = instance().debugger(); + CartDebug& cart = dbg.cartDebug(); CpuDebug& cpu = dbg.cpuDebug(); const CpuState& state = (CpuState&) cpu.getState(); const CpuState& oldstate = (CpuState&) cpu.getOldState(); @@ -282,14 +283,17 @@ void CpuWidget::loadConfig() myCpuGridBinValue->setList(alist, vlist, changed); // Update the data sources for the SP/A/X/Y registers - // TODO - change this to use actual labels - myCpuDataSrc[0]->setText(Common::Base::toString(state.srcS), + const string& srcS = state.srcS < 0 ? "IMM" : cart.getLabel(state.srcS, true); + myCpuDataSrc[0]->setText((srcS != EmptyString ? srcS : Common::Base::toString(state.srcS)), state.srcS != oldstate.srcS); - myCpuDataSrc[1]->setText(Common::Base::toString(state.srcA), + const string& srcA = state.srcA < 0 ? "IMM" : cart.getLabel(state.srcA, true); + myCpuDataSrc[1]->setText((srcA != EmptyString ? srcA : Common::Base::toString(state.srcA)), state.srcA != oldstate.srcA); - myCpuDataSrc[2]->setText(Common::Base::toString(state.srcX), + const string& srcX = state.srcX < 0 ? "IMM" : cart.getLabel(state.srcX, true); + myCpuDataSrc[2]->setText((srcX != EmptyString ? srcX : Common::Base::toString(state.srcX)), state.srcX != oldstate.srcX); - myCpuDataSrc[3]->setText(Common::Base::toString(state.srcY), + const string& srcY = state.srcY < 0 ? "IMM" : cart.getLabel(state.srcY, true); + myCpuDataSrc[3]->setText((srcY != EmptyString ? srcY : Common::Base::toString(state.srcY)), state.srcY != oldstate.srcY); // Update the PS register booleans diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index 556d27a62..d681e4d9c 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -351,8 +351,6 @@ void DebuggerDialog::addRomArea() myRam = new RamWidget(this, *myFont, xpos, ypos); addToFocusList(myRam->getFocusList()); - - // Add the DataGridOpsWidget to any widgets which contain a // DataGridWidget which we want controlled myCpu->setOpsWidget(ops); diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index 327dee550..17c722753 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -58,10 +58,10 @@ M6502::M6502(uInt32 systemCyclesPerProcessorCycle, const Settings& settings) myLastAddress(0), myLastPeekAddress(0), myLastPokeAddress(0), - myLastSrcAddressS(0), - myLastSrcAddressA(0), - myLastSrcAddressX(0), - myLastSrcAddressY(0), + myLastSrcAddressS(-1), + myLastSrcAddressA(-1), + myLastSrcAddressX(-1), + myLastSrcAddressY(-1), myDataAddressForPoke(0) { #ifdef DEBUGGER_SUPPORT @@ -134,7 +134,7 @@ void M6502::reset() myLastAddress = myLastPeekAddress = myLastPokeAddress = 0; myLastSrcAddressS = myLastSrcAddressA = - myLastSrcAddressX = myLastSrcAddressY = 0; + myLastSrcAddressX = myLastSrcAddressY = -1; myDataAddressForPoke = 0; } @@ -362,11 +362,11 @@ bool M6502::save(Serializer& out) const out.putShort(myLastAddress); out.putShort(myLastPeekAddress); out.putShort(myLastPokeAddress); - out.putShort(myLastSrcAddressS); - out.putShort(myLastSrcAddressA); - out.putShort(myLastSrcAddressX); - out.putShort(myLastSrcAddressY); out.putShort(myDataAddressForPoke); + out.putInt(myLastSrcAddressS); + out.putInt(myLastSrcAddressA); + out.putInt(myLastSrcAddressX); + out.putInt(myLastSrcAddressY); } catch(...) { @@ -410,11 +410,11 @@ bool M6502::load(Serializer& in) myLastAddress = in.getShort(); myLastPeekAddress = in.getShort(); myLastPokeAddress = in.getShort(); - myLastSrcAddressS = in.getShort(); - myLastSrcAddressA = in.getShort(); - myLastSrcAddressX = in.getShort(); - myLastSrcAddressY = in.getShort(); myDataAddressForPoke = in.getShort(); + myLastSrcAddressS = in.getInt(); + myLastSrcAddressA = in.getInt(); + myLastSrcAddressX = in.getInt(); + myLastSrcAddressY = in.getInt(); } catch(...) { diff --git a/src/emucore/M6502.hxx b/src/emucore/M6502.hxx index c26478381..098821727 100644 --- a/src/emucore/M6502.hxx +++ b/src/emucore/M6502.hxx @@ -160,14 +160,14 @@ class M6502 : public Serializable /** Return the last data address used as part of a peek operation for the S/A/X/Y registers. Note that if an address wasn't used (as in - immediate mode), then the address is zero. + immediate mode), then the address is -1. - @return The address of the data used in the last peek, else 0 + @return The address of the data used in the last peek, else -1 */ - uInt16 lastSrcAddressS() const { return myLastSrcAddressS; } - uInt16 lastSrcAddressA() const { return myLastSrcAddressA; } - uInt16 lastSrcAddressX() const { return myLastSrcAddressX; } - uInt16 lastSrcAddressY() const { return myLastSrcAddressY; } + Int32 lastSrcAddressS() const { return myLastSrcAddressS; } + Int32 lastSrcAddressA() const { return myLastSrcAddressA; } + Int32 lastSrcAddressX() const { return myLastSrcAddressX; } + Int32 lastSrcAddressY() const { return myLastSrcAddressY; } /** Get the total number of instructions executed so far. @@ -348,8 +348,8 @@ class M6502 : public Serializable /// Indicates the last address used to access data by a peek command /// for the CPU registers (S/A/X/Y) - uInt16 myLastSrcAddressS, myLastSrcAddressA, - myLastSrcAddressX, myLastSrcAddressY; + Int32 myLastSrcAddressS, myLastSrcAddressA, + myLastSrcAddressX, myLastSrcAddressY; /// Indicates the data address used by the last command that performed /// a poke (currently, the last address used by STx) diff --git a/src/emucore/M6502.ins b/src/emucore/M6502.ins index 1f00d9fb1..94d9d8f04 100644 --- a/src/emucore/M6502.ins +++ b/src/emucore/M6502.ins @@ -38,7 +38,7 @@ #ifndef CLEAR_LAST_PEEK #ifdef DEBUGGER_SUPPORT - #define CLEAR_LAST_PEEK(_addr) _addr = 0; + #define CLEAR_LAST_PEEK(_addr) _addr = -1; #else #define CLEAR_LAST_PEEK(_addr) #endif diff --git a/src/emucore/M6502.m4 b/src/emucore/M6502.m4 index 14ac023d5..56b8f811c 100644 --- a/src/emucore/M6502.m4 +++ b/src/emucore/M6502.m4 @@ -38,7 +38,7 @@ #ifndef CLEAR_LAST_PEEK #ifdef DEBUGGER_SUPPORT - #define CLEAR_LAST_PEEK(_addr) _addr = 0; + #define CLEAR_LAST_PEEK(_addr) _addr = -1; #else #define CLEAR_LAST_PEEK(_addr) #endif diff --git a/src/gui/EditTextWidget.cxx b/src/gui/EditTextWidget.cxx index 83906377d..7cb797214 100644 --- a/src/gui/EditTextWidget.cxx +++ b/src/gui/EditTextWidget.cxx @@ -43,6 +43,8 @@ void EditTextWidget::setText(const string& str, bool changed) EditableWidget::setText(str, changed); _backupString = str; _changed = changed; + + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -