From 39bb749f5dd51bdd3dc26183b4f5e1d81d222376 Mon Sep 17 00:00:00 2001 From: Fritz Mahnke Date: Mon, 17 Apr 2023 11:25:46 -0700 Subject: [PATCH] Don't always scroll to PC when updating debug window assembly view. Change ConsoleDebugger::updateWindowData and updateAllDebuggerWindows to support two different types of updates: UPDATE_ALL and UPDATE_NO_SCROLL. The new "no scroll" type lets callers request the assembly view be updated without scrolling the view to the PC line. Change the hex editor and trace logger calls to updateAllDebuggerWindows to use the no scroll update. The user may use these functions with the current disassembly position in mind and not want to lose it. --- src/drivers/Qt/ConsoleDebugger.cpp | 44 ++++++++++++++++-------------- src/drivers/Qt/ConsoleDebugger.h | 11 +++++--- src/drivers/Qt/HexEditor.cpp | 5 ++-- src/drivers/Qt/TraceLogger.cpp | 5 ++-- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/drivers/Qt/ConsoleDebugger.cpp b/src/drivers/Qt/ConsoleDebugger.cpp index 20c06510..a97c790b 100644 --- a/src/drivers/Qt/ConsoleDebugger.cpp +++ b/src/drivers/Qt/ConsoleDebugger.cpp @@ -172,7 +172,7 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent) loadDisplayViews(); - windowUpdateReq = true; + windowUpdateReq = QAsmView::UPDATE_ALL; dbgWin = this; @@ -373,7 +373,7 @@ void ConsoleDebugger::ld65ImportDebug(void) debugSymbolTable.ld65LoadDebugFile( filename.toStdString().c_str() ); - queueUpdate(); + queueUpdate(QAsmView::UPDATE_ALL); return; } @@ -2985,7 +2985,7 @@ void ConsoleDebugger::debugStepBackCB(void) { FCEU_WRAPPER_LOCK(); FCEUD_TraceLoggerBackUpInstruction(); - updateWindowData(); + updateWindowData(QAsmView::UPDATE_ALL); hexEditorUpdateMemoryValues(true); hexEditorRequestUpdateAll(); lastBpIdx = BREAK_TYPE_STEP; @@ -3180,8 +3180,7 @@ void ConsoleDebugger::seekPCCB (void) setRegsFromEntry(); //updateAllDebugWindows(); } - windowUpdateReq = true; - //asmView->scrollToPC(); + windowUpdateReq = QAsmView::UPDATE_ALL; } //---------------------------------------------------------------------------- void ConsoleDebugger::openChangePcDialog(void) @@ -3235,7 +3234,7 @@ void ConsoleDebugger::openChangePcDialog(void) { X.PC = sbox->value(); - windowUpdateReq = true; + windowUpdateReq = QAsmView::UPDATE_ALL; } } //---------------------------------------------------------------------------- @@ -4229,20 +4228,25 @@ void ConsoleDebugger::updateRegisterView(void) ppuScrollY->setText( tr(stmp) ); } //---------------------------------------------------------------------------- -void ConsoleDebugger::updateWindowData(void) +void ConsoleDebugger::updateWindowData(enum QAsmView::UpdateType type) { - asmView->updateAssemblyView(); - - asmView->scrollToPC(); + if (type == QAsmView::UPDATE_ALL) + { + asmView->updateAssemblyView(); + asmView->scrollToPC(); + updateRegisterView(); + } else if (type == QAsmView::UPDATE_NO_SCROLL) + { + asmView->updateAssemblyView(); + updateRegisterView(); + } - updateRegisterView(); - - windowUpdateReq = false; + windowUpdateReq = QAsmView::UPDATE_NONE; } //---------------------------------------------------------------------------- -void ConsoleDebugger::queueUpdate(void) +void ConsoleDebugger::queueUpdate(enum QAsmView::UpdateType type) { - windowUpdateReq = true; + windowUpdateReq = type; } //---------------------------------------------------------------------------- void ConsoleDebugger::updatePeriodic(void) @@ -4260,10 +4264,10 @@ void ConsoleDebugger::updatePeriodic(void) bpNotifyReq = false; } - if ( windowUpdateReq ) + if ( windowUpdateReq != QAsmView::UPDATE_NONE ) { FCEU_WRAPPER_LOCK(); - updateWindowData(); + updateWindowData(windowUpdateReq); FCEU_WRAPPER_UNLOCK(); } asmView->update(); @@ -4433,7 +4437,7 @@ void ConsoleDebugger::breakPointNotify( int bpNum ) } } - windowUpdateReq = true; + windowUpdateReq = QAsmView::UPDATE_ALL; } //---------------------------------------------------------------------------- void ConsoleDebugger::hbarChanged(int value) @@ -4556,11 +4560,11 @@ bool debuggerWaitingAtBreakpoint(void) return waitingAtBp; } //---------------------------------------------------------------------------- -void updateAllDebuggerWindows( void ) +void updateAllDebuggerWindows( enum QAsmView::UpdateType type ) { if ( dbgWin ) { - dbgWin->queueUpdate(); + dbgWin->queueUpdate(type); } } //---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/ConsoleDebugger.h b/src/drivers/Qt/ConsoleDebugger.h index 5d55003f..c26c92e3 100644 --- a/src/drivers/Qt/ConsoleDebugger.h +++ b/src/drivers/Qt/ConsoleDebugger.h @@ -167,6 +167,8 @@ class QAsmView : public QWidget QFont getFont(void){ return font; }; + enum UpdateType { UPDATE_NONE, UPDATE_ALL, UPDATE_NO_SCROLL }; + protected: bool event(QEvent *event) override; void paintEvent(QPaintEvent *event) override; @@ -471,7 +473,7 @@ class ConsoleDebugger : public QDialog ConsoleDebugger(QWidget *parent = 0); ~ConsoleDebugger(void); - void updateWindowData(void); + void updateWindowData(enum QAsmView::UpdateType type); void updateRegisterView(void); void updateTabVisibility(void); void breakPointNotify(int bpNum); @@ -480,7 +482,7 @@ class ConsoleDebugger : public QDialog void setBookmarkSelectedAddress( int addr ); int getBookmarkSelectedAddress(void){ return selBmAddrVal; }; void edit_BM_name( int addr ); - void queueUpdate(void); + void queueUpdate(enum QAsmView::UpdateType type); QLabel *asmLineSelLbl; @@ -573,7 +575,8 @@ class ConsoleDebugger : public QDialog ColorMenuItem *pcColorAct; int selBmAddrVal; - bool windowUpdateReq; + enum QAsmView::UpdateType windowUpdateReq; + bool startedTraceLogger; private: @@ -668,6 +671,6 @@ void saveGameDebugBreakpoints( bool force = false ); void loadGameDebugBreakpoints(void); void debuggerClearAllBreakpoints(void); void debuggerClearAllBookmarks(void); -void updateAllDebuggerWindows(void); +void updateAllDebuggerWindows(enum QAsmView::UpdateType type); extern debuggerBookmarkManager_t dbgBmMgr; diff --git a/src/drivers/Qt/HexEditor.cpp b/src/drivers/Qt/HexEditor.cpp index decf6ba2..51a6139e 100644 --- a/src/drivers/Qt/HexEditor.cpp +++ b/src/drivers/Qt/HexEditor.cpp @@ -399,7 +399,7 @@ static int writeMem( int mode, unsigned int addr, int value ) { if (debuggerWindowIsOpen()) { - updateAllDebuggerWindows(); + updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL); } } @@ -1853,7 +1853,7 @@ void HexEditorDialog_t::openDebugSymbolEditWindow( int addr ) if ( ret == QDialog::Accepted ) { - updateAllDebuggerWindows(); + updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL); } } //---------------------------------------------------------------------------- @@ -2830,6 +2830,7 @@ void QHexEdit::keyPressEvent(QKeyEvent *event) } else { // Edit Area is Hex + key = int(event->text()[0].toUpper().toLatin1()); if ( ::isxdigit( key ) ) diff --git a/src/drivers/Qt/TraceLogger.cpp b/src/drivers/Qt/TraceLogger.cpp index 55459615..d23de1b8 100644 --- a/src/drivers/Qt/TraceLogger.cpp +++ b/src/drivers/Qt/TraceLogger.cpp @@ -57,6 +57,7 @@ #include "common/os_utils.h" +#include "Qt/ConsoleDebugger.h" #include "Qt/ConsoleWindow.h" #include "Qt/ConsoleUtilities.h" #include "Qt/TraceLogger.h" @@ -2187,7 +2188,7 @@ void QTraceLogView::openBpEditWindow(int editIdx, watchpointinfo *wp, traceRecor numWPs++; } - updateAllDebuggerWindows(); + updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL); } } } @@ -2232,7 +2233,7 @@ void QTraceLogView::openDebugSymbolEditWindow(int addr, int bank) if (ret == QDialog::Accepted) { - updateAllDebuggerWindows(); + updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL); } } //----------------------------------------------------------------------------