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.
This commit is contained in:
Fritz Mahnke 2023-04-17 11:25:46 -07:00
parent 46054d190c
commit 39bb749f5d
4 changed files with 37 additions and 28 deletions

View File

@ -172,7 +172,7 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent)
loadDisplayViews(); loadDisplayViews();
windowUpdateReq = true; windowUpdateReq = QAsmView::UPDATE_ALL;
dbgWin = this; dbgWin = this;
@ -373,7 +373,7 @@ void ConsoleDebugger::ld65ImportDebug(void)
debugSymbolTable.ld65LoadDebugFile( filename.toStdString().c_str() ); debugSymbolTable.ld65LoadDebugFile( filename.toStdString().c_str() );
queueUpdate(); queueUpdate(QAsmView::UPDATE_ALL);
return; return;
} }
@ -2985,7 +2985,7 @@ void ConsoleDebugger::debugStepBackCB(void)
{ {
FCEU_WRAPPER_LOCK(); FCEU_WRAPPER_LOCK();
FCEUD_TraceLoggerBackUpInstruction(); FCEUD_TraceLoggerBackUpInstruction();
updateWindowData(); updateWindowData(QAsmView::UPDATE_ALL);
hexEditorUpdateMemoryValues(true); hexEditorUpdateMemoryValues(true);
hexEditorRequestUpdateAll(); hexEditorRequestUpdateAll();
lastBpIdx = BREAK_TYPE_STEP; lastBpIdx = BREAK_TYPE_STEP;
@ -3180,8 +3180,7 @@ void ConsoleDebugger::seekPCCB (void)
setRegsFromEntry(); setRegsFromEntry();
//updateAllDebugWindows(); //updateAllDebugWindows();
} }
windowUpdateReq = true; windowUpdateReq = QAsmView::UPDATE_ALL;
//asmView->scrollToPC();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::openChangePcDialog(void) void ConsoleDebugger::openChangePcDialog(void)
@ -3235,7 +3234,7 @@ void ConsoleDebugger::openChangePcDialog(void)
{ {
X.PC = sbox->value(); X.PC = sbox->value();
windowUpdateReq = true; windowUpdateReq = QAsmView::UPDATE_ALL;
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -4229,20 +4228,25 @@ void ConsoleDebugger::updateRegisterView(void)
ppuScrollY->setText( tr(stmp) ); ppuScrollY->setText( tr(stmp) );
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::updateWindowData(void) void ConsoleDebugger::updateWindowData(enum QAsmView::UpdateType type)
{ {
asmView->updateAssemblyView(); if (type == QAsmView::UPDATE_ALL)
{
asmView->scrollToPC(); asmView->updateAssemblyView();
asmView->scrollToPC();
updateRegisterView();
} else if (type == QAsmView::UPDATE_NO_SCROLL)
{
asmView->updateAssemblyView();
updateRegisterView();
}
updateRegisterView(); windowUpdateReq = QAsmView::UPDATE_NONE;
windowUpdateReq = false;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::queueUpdate(void) void ConsoleDebugger::queueUpdate(enum QAsmView::UpdateType type)
{ {
windowUpdateReq = true; windowUpdateReq = type;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::updatePeriodic(void) void ConsoleDebugger::updatePeriodic(void)
@ -4260,10 +4264,10 @@ void ConsoleDebugger::updatePeriodic(void)
bpNotifyReq = false; bpNotifyReq = false;
} }
if ( windowUpdateReq ) if ( windowUpdateReq != QAsmView::UPDATE_NONE )
{ {
FCEU_WRAPPER_LOCK(); FCEU_WRAPPER_LOCK();
updateWindowData(); updateWindowData(windowUpdateReq);
FCEU_WRAPPER_UNLOCK(); FCEU_WRAPPER_UNLOCK();
} }
asmView->update(); asmView->update();
@ -4433,7 +4437,7 @@ void ConsoleDebugger::breakPointNotify( int bpNum )
} }
} }
windowUpdateReq = true; windowUpdateReq = QAsmView::UPDATE_ALL;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::hbarChanged(int value) void ConsoleDebugger::hbarChanged(int value)
@ -4556,11 +4560,11 @@ bool debuggerWaitingAtBreakpoint(void)
return waitingAtBp; return waitingAtBp;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void updateAllDebuggerWindows( void ) void updateAllDebuggerWindows( enum QAsmView::UpdateType type )
{ {
if ( dbgWin ) if ( dbgWin )
{ {
dbgWin->queueUpdate(); dbgWin->queueUpdate(type);
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -167,6 +167,8 @@ class QAsmView : public QWidget
QFont getFont(void){ return font; }; QFont getFont(void){ return font; };
enum UpdateType { UPDATE_NONE, UPDATE_ALL, UPDATE_NO_SCROLL };
protected: protected:
bool event(QEvent *event) override; bool event(QEvent *event) override;
void paintEvent(QPaintEvent *event) override; void paintEvent(QPaintEvent *event) override;
@ -471,7 +473,7 @@ class ConsoleDebugger : public QDialog
ConsoleDebugger(QWidget *parent = 0); ConsoleDebugger(QWidget *parent = 0);
~ConsoleDebugger(void); ~ConsoleDebugger(void);
void updateWindowData(void); void updateWindowData(enum QAsmView::UpdateType type);
void updateRegisterView(void); void updateRegisterView(void);
void updateTabVisibility(void); void updateTabVisibility(void);
void breakPointNotify(int bpNum); void breakPointNotify(int bpNum);
@ -480,7 +482,7 @@ class ConsoleDebugger : public QDialog
void setBookmarkSelectedAddress( int addr ); void setBookmarkSelectedAddress( int addr );
int getBookmarkSelectedAddress(void){ return selBmAddrVal; }; int getBookmarkSelectedAddress(void){ return selBmAddrVal; };
void edit_BM_name( int addr ); void edit_BM_name( int addr );
void queueUpdate(void); void queueUpdate(enum QAsmView::UpdateType type);
QLabel *asmLineSelLbl; QLabel *asmLineSelLbl;
@ -573,7 +575,8 @@ class ConsoleDebugger : public QDialog
ColorMenuItem *pcColorAct; ColorMenuItem *pcColorAct;
int selBmAddrVal; int selBmAddrVal;
bool windowUpdateReq; enum QAsmView::UpdateType windowUpdateReq;
bool startedTraceLogger; bool startedTraceLogger;
private: private:
@ -668,6 +671,6 @@ void saveGameDebugBreakpoints( bool force = false );
void loadGameDebugBreakpoints(void); void loadGameDebugBreakpoints(void);
void debuggerClearAllBreakpoints(void); void debuggerClearAllBreakpoints(void);
void debuggerClearAllBookmarks(void); void debuggerClearAllBookmarks(void);
void updateAllDebuggerWindows(void); void updateAllDebuggerWindows(enum QAsmView::UpdateType type);
extern debuggerBookmarkManager_t dbgBmMgr; extern debuggerBookmarkManager_t dbgBmMgr;

View File

@ -399,7 +399,7 @@ static int writeMem( int mode, unsigned int addr, int value )
{ {
if (debuggerWindowIsOpen()) if (debuggerWindowIsOpen())
{ {
updateAllDebuggerWindows(); updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL);
} }
} }
@ -1853,7 +1853,7 @@ void HexEditorDialog_t::openDebugSymbolEditWindow( int addr )
if ( ret == QDialog::Accepted ) if ( ret == QDialog::Accepted )
{ {
updateAllDebuggerWindows(); updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL);
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2830,6 +2830,7 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
} }
else else
{ // Edit Area is Hex { // Edit Area is Hex
key = int(event->text()[0].toUpper().toLatin1()); key = int(event->text()[0].toUpper().toLatin1());
if ( ::isxdigit( key ) ) if ( ::isxdigit( key ) )

View File

@ -57,6 +57,7 @@
#include "common/os_utils.h" #include "common/os_utils.h"
#include "Qt/ConsoleDebugger.h"
#include "Qt/ConsoleWindow.h" #include "Qt/ConsoleWindow.h"
#include "Qt/ConsoleUtilities.h" #include "Qt/ConsoleUtilities.h"
#include "Qt/TraceLogger.h" #include "Qt/TraceLogger.h"
@ -2187,7 +2188,7 @@ void QTraceLogView::openBpEditWindow(int editIdx, watchpointinfo *wp, traceRecor
numWPs++; numWPs++;
} }
updateAllDebuggerWindows(); updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL);
} }
} }
} }
@ -2232,7 +2233,7 @@ void QTraceLogView::openDebugSymbolEditWindow(int addr, int bank)
if (ret == QDialog::Accepted) if (ret == QDialog::Accepted)
{ {
updateAllDebuggerWindows(); updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL);
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------