Added go to assembly address on double click and context menu option.

This commit is contained in:
mjbudd77 2021-07-11 19:05:29 -04:00
parent 4ffcafd138
commit 086163e062
2 changed files with 131 additions and 46 deletions

View File

@ -2702,6 +2702,20 @@ void ConsoleDebugger::asmViewCtxMenuRunToCursor(void)
fceuWrapperUnLock(); fceuWrapperUnLock();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::asmViewCtxMenuGoTo(void)
{
int line;
line = asmView->getAsmLineFromAddr( asmView->getCtxMenuAddr() );
asmView->scrollToLine( line );
if ( asmView->getAsmAddrFromLine(line) == asmView->getCtxMenuAddr() )
{
asmView->setSelAddrToLine(line);
}
}
//----------------------------------------------------------------------------
void ConsoleDebugger::asmViewCtxMenuAddBP(void) void ConsoleDebugger::asmViewCtxMenuAddBP(void)
{ {
int bpNum; int bpNum;
@ -2888,6 +2902,15 @@ void QAsmView::setBreakpointAtSelectedLine(void)
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int QAsmView::getAsmAddrFromLine(int line)
{
if ( (line >= 0) && (line < asmEntry.size()) )
{
return asmEntry[line]->addr;
}
return -1;
}
//----------------------------------------------------------------------------
int QAsmView::getAsmLineFromAddr(int addr) int QAsmView::getAsmLineFromAddr(int addr)
{ {
int line = -1; int line = -1;
@ -4266,53 +4289,72 @@ void QAsmView::scrollToPC(void)
{ {
if ( asmPC != NULL ) if ( asmPC != NULL )
{ {
int ofs = 0; scrollToLine( asmPC->line );
int maxOfs = (viewLines-3); }
}
//----------------------------------------------------------------------------
void QAsmView::scrollToLine( int line )
{
int ofs = 0;
int maxOfs = (viewLines-3);
if ( maxOfs < 0 ) if ( maxOfs < 0 )
{ {
maxOfs = 0; maxOfs = 0;
} }
switch ( pcLinePlacement ) switch ( pcLinePlacement )
{ {
default: default:
case 0: case 0:
ofs = 0;
break;
case 1:
ofs = (viewLines / 4);
break;
case 2:
ofs = (viewLines / 2);
break;
case 3:
ofs = (viewLines*3) / 4;
break;
case 4:
ofs = maxOfs;
break;
case 5:
ofs = pcLineOffset;
if ( ofs < 0 )
{
ofs = 0; ofs = 0;
break; }
case 1: else if ( ofs > maxOfs )
ofs = (viewLines / 4); {
break; ofs = maxOfs;
case 2: }
ofs = (viewLines / 2); break;
break; }
case 3:
ofs = (viewLines*3) / 4;
break;
case 4:
ofs = maxOfs;
break;
case 5:
ofs = pcLineOffset;
if ( ofs < 0 ) lineOffset = line - ofs;
{
ofs = 0;
}
else if ( ofs > maxOfs )
{
ofs = maxOfs;
}
break;
}
lineOffset = asmPC->line - ofs; if ( lineOffset < 0 )
{
if ( lineOffset < 0 ) lineOffset = 0;
{ }
lineOffset = 0; vbar->setValue( lineOffset );
} }
vbar->setValue( lineOffset ); //----------------------------------------------------------------------------
void QAsmView::setSelAddrToLine( int line )
{
if ( (line >= 0) && (line < asmEntry.size()) )
{
int addr = asmEntry[line]->addr;
selAddrLine = line;
selAddrChar = pcLocLinePos + 3;
selAddrWidth = 4;
selAddrValue = addr;
sprintf( selAddrText, "%04X", addr );
printf("Set Select ADDR:%04X\n", addr);
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -4897,10 +4939,41 @@ void QAsmView::mouseReleaseEvent(QMouseEvent * event)
if ( event->button() == Qt::LeftButton ) if ( event->button() == Qt::LeftButton )
{ {
//printf("Left Button Release: (%i,%i)\n", c.x(), c.y() ); //printf("Left Button Release: (%i,%i)\n", c.x(), c.y() );
mouseLeftBtnDown = false;
setHighlightEndCoord( c.x(), line );
loadHighlightToClipboard(); if ( mouseLeftBtnDown )
{
mouseLeftBtnDown = false;
setHighlightEndCoord( c.x(), line );
loadHighlightToClipboard();
}
}
}
//----------------------------------------------------------------------------
void QAsmView::mouseDoubleClickEvent(QMouseEvent * event)
{
//printf("Double Click\n");
if ( selAddrValue >= 0 )
{
int line;
line = getAsmLineFromAddr(selAddrValue);
scrollToLine( line );
if ( getAsmAddrFromLine(line) == selAddrValue )
{
setSelAddrToLine(line);
}
mouseLeftBtnDown = false;
txtHlgtAnchorLine = -1;
txtHlgtAnchorChar = -1;
txtHlgtStartChar = -1;
txtHlgtStartLine = -1;
txtHlgtEndChar = -1;
txtHlgtEndLine = -1;
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -5047,7 +5120,7 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
{ {
addr = asmEntry[line]->addr; addr = asmEntry[line]->addr;
selAddrLine = line; selAddrLine = line;
selAddrChar = 4; selAddrChar = pcLocLinePos+3;
selAddrWidth = 4; selAddrWidth = 4;
selAddrValue = addr; selAddrValue = addr;
sprintf( selAddrText, "%04X", addr ); sprintf( selAddrText, "%04X", addr );
@ -5121,6 +5194,7 @@ void QAsmView::contextMenuEvent(QContextMenuEvent *event)
QMenu menu(this); QMenu menu(this);
QPoint c = convPixToCursor( event->pos() ); QPoint c = convPixToCursor( event->pos() );
bool enableRunToCursor = false; bool enableRunToCursor = false;
char stmp[128];
line = lineOffset + c.y(); line = lineOffset + c.y();
@ -5151,6 +5225,12 @@ void QAsmView::contextMenuEvent(QContextMenuEvent *event)
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuRunToCursor(void)) ); connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuRunToCursor(void)) );
} }
sprintf( stmp, "Go to $%04X\tDouble+Click", ctxMenuAddr );
act = new QAction(tr(stmp), &menu);
menu.addAction(act);
//act->setShortcut( QKeySequence(tr("Ctrl+F10")));
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuGoTo(void)) );
if ( isBreakpointAtAddr( addr ) >= 0 ) if ( isBreakpointAtAddr( addr ) >= 0 )
{ {
act = new QAction(tr("Edit &Breakpoint"), &menu); act = new QAction(tr("Edit &Breakpoint"), &menu);

View File

@ -110,9 +110,12 @@ class QAsmView : public QWidget
void updateAssemblyView(void); void updateAssemblyView(void);
void asmClear(void); void asmClear(void);
int getAsmLineFromAddr(int addr); int getAsmLineFromAddr(int addr);
int getAsmAddrFromLine(int line);
void setLine(int lineNum); void setLine(int lineNum);
void setXScroll(int value); void setXScroll(int value);
void scrollToPC(void); void scrollToPC(void);
void scrollToLine( int line );
void setSelAddrToLine( int line );
void setDisplayROMoffsets( bool value ); void setDisplayROMoffsets( bool value );
void setSymbolDebugEnable( bool value ); void setSymbolDebugEnable( bool value );
void setRegisterNameEnable( bool value ); void setRegisterNameEnable( bool value );
@ -141,6 +144,7 @@ class QAsmView : public QWidget
void mousePressEvent(QMouseEvent * event); void mousePressEvent(QMouseEvent * event);
void mouseReleaseEvent(QMouseEvent * event); void mouseReleaseEvent(QMouseEvent * event);
void mouseMoveEvent(QMouseEvent * event); void mouseMoveEvent(QMouseEvent * event);
void mouseDoubleClickEvent(QMouseEvent * event);
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
void wheelEvent(QWheelEvent *event); void wheelEvent(QWheelEvent *event);
void contextMenuEvent(QContextMenuEvent *event); void contextMenuEvent(QContextMenuEvent *event);
@ -375,6 +379,7 @@ class ConsoleDebugger : public QDialog
public slots: public slots:
void closeWindow(void); void closeWindow(void);
void asmViewCtxMenuGoTo(void);
void asmViewCtxMenuAddBP(void); void asmViewCtxMenuAddBP(void);
void asmViewCtxMenuAddBM(void); void asmViewCtxMenuAddBM(void);
void asmViewCtxMenuAddSym(void); void asmViewCtxMenuAddSym(void);