From 97784ec09bcce3a6dc9211572c125759939006f0 Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Sun, 20 Sep 2020 21:40:31 -0400 Subject: [PATCH] Added quick breakpoint add via hex editor context menu. --- src/drivers/Qt/HexEditor.cpp | 150 +++++++++++++++++++++++++++++++++-- src/drivers/Qt/HexEditor.h | 5 ++ 2 files changed, 149 insertions(+), 6 deletions(-) diff --git a/src/drivers/Qt/HexEditor.cpp b/src/drivers/Qt/HexEditor.cpp index 8a20818a..76cd17de 100644 --- a/src/drivers/Qt/HexEditor.cpp +++ b/src/drivers/Qt/HexEditor.cpp @@ -1578,17 +1578,20 @@ void QHexEdit::contextMenuEvent(QContextMenuEvent *event) act = new QAction(tr("TODO Add Symbolic Debug Name"), this); menu.addAction(act); - sprintf( stmp, "TODO Add Read Breakpoint for Address $%04X", addr ); + sprintf( stmp, "Add Read Breakpoint for Address $%04X", addr ); act = new QAction(tr(stmp), this); - menu.addAction(act); + menu.addAction(act); + connect( act, SIGNAL(triggered(void)), this, SLOT(addRamReadBP(void)) ); - sprintf( stmp, "TODO Add Write Breakpoint for Address $%04X", addr ); + sprintf( stmp, "Add Write Breakpoint for Address $%04X", addr ); act = new QAction(tr(stmp), this); - menu.addAction(act); + menu.addAction(act); + connect( act, SIGNAL(triggered(void)), this, SLOT(addRamWriteBP(void)) ); - sprintf( stmp, "TODO Add Execute Breakpoint for Address $%04X", addr ); + sprintf( stmp, "Add Execute Breakpoint for Address $%04X", addr ); act = new QAction(tr(stmp), this); - menu.addAction(act); + menu.addAction(act); + connect( act, SIGNAL(triggered(void)), this, SLOT(addRamExecuteBP(void)) ); if ( addr > 0x6000 ) { @@ -1611,6 +1614,16 @@ void QHexEdit::contextMenuEvent(QContextMenuEvent *event) break; case MODE_NES_PPU: { + sprintf( stmp, "Add Read Breakpoint for Address $%04X", addr ); + act = new QAction(tr(stmp), this); + menu.addAction(act); + connect( act, SIGNAL(triggered(void)), this, SLOT(addPpuReadBP(void)) ); + + sprintf( stmp, "Add Write Breakpoint for Address $%04X", addr ); + act = new QAction(tr(stmp), this); + menu.addAction(act); + connect( act, SIGNAL(triggered(void)), this, SLOT(addPpuWriteBP(void)) ); + act = new QAction(tr("Add Bookmark"), this); menu.addAction(act); connect( act, SIGNAL(triggered(void)), this, SLOT(addBookMarkCB(void)) ); @@ -1674,6 +1687,131 @@ void QHexEdit::addBookMarkCB(void) } } //---------------------------------------------------------------------------- +void QHexEdit::addRamReadBP(void) +{ + int retval, type; + char cond[64], name[64]; + + type = BT_C | WP_R; + + cond[0] = 0; + name[0] = 0; + + if ( ctxAddr >= 0x8000 ) + { + sprintf(cond, "K==#%02X", getBank(ctxAddr)); + } + + retval = NewBreak( name, ctxAddr, -1, type, cond, numWPs, true); + + if ( (retval == 1) || (retval == 2) ) + { + printf("Breakpoint Add Failed\n"); + } + else + { + numWPs++; + } +} +//---------------------------------------------------------------------------- +void QHexEdit::addRamWriteBP(void) +{ + int retval, type; + char cond[64], name[64]; + + type = BT_C | WP_W; + + cond[0] = 0; + name[0] = 0; + + if ( ctxAddr >= 0x8000 ) + { + sprintf(cond, "K==#%02X", getBank(ctxAddr)); + } + + retval = NewBreak( name, ctxAddr, -1, type, cond, numWPs, true); + + if ( (retval == 1) || (retval == 2) ) + { + printf("Breakpoint Add Failed\n"); + } + else + { + numWPs++; + } +} +//---------------------------------------------------------------------------- +void QHexEdit::addRamExecuteBP(void) +{ + int retval, type; + char cond[64], name[64]; + + type = BT_C | WP_X; + + cond[0] = 0; + name[0] = 0; + + if ( ctxAddr >= 0x8000 ) + { + sprintf(cond, "K==#%02X", getBank(ctxAddr)); + } + + retval = NewBreak( name, ctxAddr, -1, type, cond, numWPs, true); + + if ( (retval == 1) || (retval == 2) ) + { + printf("Breakpoint Add Failed\n"); + } + else + { + numWPs++; + } +} +//---------------------------------------------------------------------------- +void QHexEdit::addPpuReadBP(void) +{ + int retval, type; + char cond[64], name[64]; + + type = BT_P | WP_R; + + cond[0] = 0; + name[0] = 0; + + retval = NewBreak( name, ctxAddr, -1, type, cond, numWPs, true); + + if ( (retval == 1) || (retval == 2) ) + { + printf("Breakpoint Add Failed\n"); + } + else + { + numWPs++; + } +} +//---------------------------------------------------------------------------- +void QHexEdit::addPpuWriteBP(void) +{ + int retval, type; + char cond[64], name[64]; + + type = BT_P | WP_W; + + cond[0] = 0; + name[0] = 0; + + retval = NewBreak( name, ctxAddr, -1, type, cond, numWPs, true); + + if ( (retval == 1) || (retval == 2) ) + { + printf("Breakpoint Add Failed\n"); + } + else + { + numWPs++; + } +} +//---------------------------------------------------------------------------- void QHexEdit::jumpToROM(void) { setMode( MODE_NES_ROM ); diff --git a/src/drivers/Qt/HexEditor.h b/src/drivers/Qt/HexEditor.h index 61262b96..8fe6a67a 100644 --- a/src/drivers/Qt/HexEditor.h +++ b/src/drivers/Qt/HexEditor.h @@ -184,6 +184,11 @@ class QHexEdit : public QWidget private slots: void jumpToROM(void); void addBookMarkCB(void); + void addRamReadBP(void); + void addRamWriteBP(void); + void addRamExecuteBP(void); + void addPpuReadBP(void); + void addPpuWriteBP(void); };