Added logic to allow for ROM offsets to be selected in the assembly view window.

This commit is contained in:
mjbudd77 2021-08-03 22:11:37 -04:00
parent d04d08d2e9
commit 63c4a18e46
2 changed files with 70 additions and 15 deletions

View File

@ -1811,7 +1811,7 @@ void ConsoleDebugger::openBpEditWindow( int editIdx, watchpointinfo *wp, bool fo
ebp->setChecked(true); ebp->setChecked(true);
// If new breakpoint, suggest condition if in ROM Mapping area of memory. // If new breakpoint, suggest condition if in ROM Mapping area of memory.
if ( wp->address >= 0x8000 ) if ( cpu_radio->isChecked() && (wp->address >= 0x8000) )
{ {
int romAddr = GetNesFileAddress(wp->address); int romAddr = GetNesFileAddress(wp->address);
@ -3021,6 +3021,11 @@ void ConsoleDebugger::asmViewCtxMenuAddBP(void)
wp.condText = 0; wp.condText = 0;
wp.desc = NULL; wp.desc = NULL;
if ( asmView->getCtxMenuAddrType() )
{
wp.flags |= BT_R;
}
bpNum = asmView->isBreakpointAtAddr( wp.address, GetNesFileAddress(wp.address) ); bpNum = asmView->isBreakpointAtAddr( wp.address, GetNesFileAddress(wp.address) );
if ( bpNum >= 0 ) if ( bpNum >= 0 )
@ -3037,7 +3042,7 @@ void ConsoleDebugger::asmViewCtxMenuAddBP(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::asmViewCtxMenuAddBM(void) void ConsoleDebugger::asmViewCtxMenuAddBM(void)
{ {
int addr = asmView->getCtxMenuAddr(); int addr = asmView->getAsmAddrFromLine( asmView->getCtxMenuLine() );
dbgBmMgr.addBookmark( addr ); dbgBmMgr.addBookmark( addr );
@ -3051,9 +3056,16 @@ void ConsoleDebugger::asmViewCtxMenuOpenHexEdit(void)
int romAddr = -1; int romAddr = -1;
int addr = asmView->getCtxMenuAddr(); int addr = asmView->getCtxMenuAddr();
if (addr >= 0x8000) if ( asmView->getCtxMenuAddrType() )
{ {
romAddr = GetNesFileAddress(addr); romAddr = addr;
}
else
{
if (addr >= 0x8000)
{
romAddr = GetNesFileAddress(addr);
}
} }
if ( romAddr >= 0 ) if ( romAddr >= 0 )
@ -3079,7 +3091,9 @@ void ConsoleDebugger::setBookmarkSelectedAddress( int addr )
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::asmViewCtxMenuAddSym(void) void ConsoleDebugger::asmViewCtxMenuAddSym(void)
{ {
openDebugSymbolEditWindow( asmView->getCtxMenuAddr() ); int addr = asmView->getAsmAddrFromLine( asmView->getCtxMenuLine() );
openDebugSymbolEditWindow( addr );
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void QAsmView::setPC_placement( int mode, int ofs ) void QAsmView::setPC_placement( int mode, int ofs )
@ -4658,6 +4672,8 @@ QAsmView::QAsmView(QWidget *parent)
lineOffset = 0; lineOffset = 0;
maxLineOffset = 0; maxLineOffset = 0;
ctxMenuAddr = -1; ctxMenuAddr = -1;
ctxMenuAddrType = 0;
ctxMenuLine = 0;
cursorPosX = 0; cursorPosX = 0;
cursorPosY = 0; cursorPosY = 0;
@ -4679,6 +4695,7 @@ QAsmView::QAsmView(QWidget *parent)
selAddrChar = 0; selAddrChar = 0;
selAddrWidth = 0; selAddrWidth = 0;
selAddrValue = -1; selAddrValue = -1;
selAddrType = 0;
memset( selAddrText, 0, sizeof(selAddrText) ); memset( selAddrText, 0, sizeof(selAddrText) );
cursorLineAddr = -1; cursorLineAddr = -1;
@ -4900,6 +4917,7 @@ void QAsmView::setSelAddrToLine( int line )
selAddrChar = pcLocLinePos + 3; selAddrChar = pcLocLinePos + 3;
selAddrWidth = 4; selAddrWidth = 4;
selAddrValue = addr; selAddrValue = addr;
selAddrType = 0;
sprintf( selAddrText, "%04X", addr ); sprintf( selAddrText, "%04X", addr );
@ -5254,6 +5272,8 @@ void QAsmView::keyPressEvent(QKeyEvent *event)
else if ( selAddrValue >= 0 ) else if ( selAddrValue >= 0 )
{ {
ctxMenuAddr = selAddrValue; ctxMenuAddr = selAddrValue;
ctxMenuAddrType = selAddrType;
ctxMenuLine = selAddrLine;
if ( event->key() == Qt::Key_B ) if ( event->key() == Qt::Key_B )
{ {
@ -5549,7 +5569,7 @@ void QAsmView::mouseDoubleClickEvent(QMouseEvent * event)
{ {
//printf("Double Click\n"); //printf("Double Click\n");
if ( selAddrValue >= 0 ) if ( (selAddrType == 0) && (selAddrValue >= 0) )
{ {
gotoAddr( selAddrValue ); gotoAddr( selAddrValue );
@ -5593,6 +5613,7 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
selAddrChar = 0; selAddrChar = 0;
selAddrWidth = 0; selAddrWidth = 0;
selAddrValue = -1; selAddrValue = -1;
selAddrType = 0;
selAddrText[0] = 0; selAddrText[0] = 0;
if ( line < asmEntry.size() ) if ( line < asmEntry.size() )
@ -5628,6 +5649,7 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
selAddrChar = symTextStart; selAddrChar = symTextStart;
selAddrWidth = symTextEnd - symTextStart; selAddrWidth = symTextEnd - symTextStart;
selAddrValue = addr = asmEntry[line]->sym.ofs; selAddrValue = addr = asmEntry[line]->sym.ofs;
selAddrType = 0;
if ( selAddrWidth >= (int)sizeof(selAddrText) ) if ( selAddrWidth >= (int)sizeof(selAddrText) )
{ {
@ -5646,7 +5668,7 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
addrTextLoc = i; addrTextLoc = i;
i--; i--;
} }
if ( asmEntry[line]->text[i] == '$' || asmEntry[line]->text[i] == ':' ) if ( asmEntry[line]->text[i] == '$' || asmEntry[line]->text[i] == ':' || asmEntry[line]->text[i] == ' ' )
{ {
i--; i--;
} }
@ -5676,6 +5698,7 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
selAddrChar = addrTextLoc; selAddrChar = addrTextLoc;
selAddrWidth = j; selAddrWidth = j;
selAddrValue = addr; selAddrValue = addr;
selAddrType = displayROMoffsets && (addrTextLoc < byteCodeLinePos) && (asmEntry[line]->rom >= 0);
strcpy( selAddrText, stmp ); strcpy( selAddrText, stmp );
} }
} }
@ -5705,11 +5728,31 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
if ( addr < 0 ) if ( addr < 0 )
{ {
addr = asmEntry[line]->addr; addr = asmEntry[line]->addr;
selAddrType = 0;
if ( displayROMoffsets )
{
if ( asmEntry[line]->rom >= 0 )
{
addr = asmEntry[line]->rom;
selAddrType = 1;
}
}
if ( selAddrType )
{
sprintf( selAddrText, "%06X", addr );
selAddrWidth = 6;
selAddrChar = pcLocLinePos+1;
}
else
{
sprintf( selAddrText, "%04X", addr );
selAddrWidth = 4;
selAddrChar = pcLocLinePos+3;
}
selAddrLine = line; selAddrLine = line;
selAddrChar = pcLocLinePos+3;
selAddrWidth = 4;
selAddrValue = addr; selAddrValue = addr;
sprintf( selAddrText, "%04X", addr );
} }
//printf("Line: '%s'\n", asmEntry[line]->text.c_str() ); //printf("Line: '%s'\n", asmEntry[line]->text.c_str() );
@ -5800,12 +5843,16 @@ void QAsmView::contextMenuEvent(QContextMenuEvent *event)
if ( selAddrValue < 0 ) if ( selAddrValue < 0 )
{ {
ctxMenuAddr = addr = asmEntry[line]->addr; ctxMenuAddr = addr = asmEntry[line]->addr;
ctxMenuAddrType = 0;
ctxMenuLine = line;;
enableRunToCursor = true; enableRunToCursor = true;
} }
else else
{ {
ctxMenuAddr = addr = selAddrValue; ctxMenuAddr = addr = selAddrValue;
ctxMenuAddrType = selAddrType;
ctxMenuLine = selAddrLine;
enableRunToCursor = (selAddrValue == asmEntry[line]->addr); enableRunToCursor = (selAddrValue == asmEntry[line]->addr);
} }
@ -5819,11 +5866,14 @@ 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 ); if ( ctxMenuAddrType == 0 )
act = new QAction(tr(stmp), &menu); {
menu.addAction(act); sprintf( stmp, "Go to $%04X\tDouble+Click", ctxMenuAddr );
//act->setShortcut( QKeySequence(tr("Ctrl+F10"))); act = new QAction(tr(stmp), &menu);
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuGoTo(void)) ); menu.addAction(act);
//act->setShortcut( QKeySequence(tr("Ctrl+F10")));
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuGoTo(void)) );
}
if ( isBreakpointAtAddr( addr, romAddr ) >= 0 ) if ( isBreakpointAtAddr( addr, romAddr ) >= 0 )
{ {

View File

@ -142,7 +142,9 @@ class QAsmView : public QWidget
void setSymbolDebugEnable( bool value ); void setSymbolDebugEnable( bool value );
void setRegisterNameEnable( bool value ); void setRegisterNameEnable( bool value );
void setDisplayByteCodes( bool value ); void setDisplayByteCodes( bool value );
int getCtxMenuLine(void){ return ctxMenuLine; };
int getCtxMenuAddr(void){ return ctxMenuAddr; }; int getCtxMenuAddr(void){ return ctxMenuAddr; };
int getCtxMenuAddrType(void){ return ctxMenuAddrType; };
int getCursorAddr(void){ return cursorLineAddr; }; int getCursorAddr(void){ return cursorLineAddr; };
void setPC_placement( int mode, int ofs = 0 ); void setPC_placement( int mode, int ofs = 0 );
void setBreakpointAtSelectedLine(void); void setBreakpointAtSelectedLine(void);
@ -201,7 +203,9 @@ class QAsmView : public QWidget
std::vector <dbg_nav_entry_t> navFwdHist; std::vector <dbg_nav_entry_t> navFwdHist;
dbg_nav_entry_t curNavLoc; dbg_nav_entry_t curNavLoc;
int ctxMenuLine;
int ctxMenuAddr; int ctxMenuAddr;
int ctxMenuAddrType;
int maxLineLen; int maxLineLen;
int pxCharWidth; int pxCharWidth;
int pxCharHeight; int pxCharHeight;
@ -230,6 +234,7 @@ class QAsmView : public QWidget
int selAddrWidth; int selAddrWidth;
int selAddrValue; int selAddrValue;
char selAddrText[128]; char selAddrText[128];
char selAddrType;
int txtHlgtAnchorChar; int txtHlgtAnchorChar;
int txtHlgtAnchorLine; int txtHlgtAnchorLine;