diff --git a/src/drivers/Qt/ConsoleDebugger.cpp b/src/drivers/Qt/ConsoleDebugger.cpp index 0feeead4..ed9cc4dd 100644 --- a/src/drivers/Qt/ConsoleDebugger.cpp +++ b/src/drivers/Qt/ConsoleDebugger.cpp @@ -48,7 +48,7 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent) { QHBoxLayout *mainLayout; QVBoxLayout *vbox, *vbox1, *vbox2, *vbox3; - QHBoxLayout *hbox, *hbox1, *hbox2; + QHBoxLayout *hbox, *hbox1, *hbox2, *hbox3; QGridLayout *grid; QPushButton *button; QFrame *frame; @@ -227,7 +227,7 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent) hbox->addWidget( bpTree ); - hbox = new QHBoxLayout(); + hbox = new QHBoxLayout(); button = new QPushButton( tr("Add") ); hbox->addWidget( button ); connect( button, SIGNAL(clicked(void)), this, SLOT(add_BP_CB(void)) ); @@ -339,6 +339,86 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent) brkInstrsExd->setChecked( break_on_instructions ); connect( brkInstrsExd, SIGNAL(stateChanged(int)), this, SLOT(breakOnInstructionsCB(int)) ); + hbox3 = new QHBoxLayout(); + hbox = new QHBoxLayout(); + vbox = new QVBoxLayout(); + bmFrame = new QGroupBox( tr("Address Bookmarks") ); + bmTree = new QTreeWidget(); + selBmAddr = new QLineEdit(); + + bmTree->setColumnCount(2); + + item = new QTreeWidgetItem(); + item->setFont( 0, font ); + item->setFont( 1, font ); + item->setText( 0, QString::fromStdString( "Addr" ) ); + item->setText( 1, QString::fromStdString( "Name" ) ); + item->setTextAlignment( 0, Qt::AlignCenter); + item->setTextAlignment( 1, Qt::AlignCenter); + + bmTree->setHeaderItem( item ); + + bmTree->header()->setSectionResizeMode( QHeaderView::ResizeToContents ); + + connect( bmTree, SIGNAL(itemClicked(QTreeWidgetItem*, int)), + this, SLOT(bmItemClicked( QTreeWidgetItem*, int)) ); + + vbox->addWidget( selBmAddr ); + + button = new QPushButton( tr("Add") ); + vbox->addWidget( button ); + + button = new QPushButton( tr("Delete") ); + vbox->addWidget( button ); + + button = new QPushButton( tr("Name") ); + vbox->addWidget( button ); + + hbox->addWidget( bmTree ); + hbox->addLayout( vbox ); + bmFrame->setLayout( hbox ); + hbox3->addWidget( bmFrame ); + vbox1->addLayout( hbox3 ); + + frame = new QFrame(); + vbox = new QVBoxLayout(); + button = new QPushButton( tr("Reset Counters") ); + connect( button, SIGNAL(clicked(void)), this, SLOT(resetCountersCB(void)) ); + vbox->addWidget( button ); + vbox->addWidget( frame ); + hbox3->addLayout( vbox ); + + vbox = new QVBoxLayout(); + romOfsChkBox = new QCheckBox( tr("ROM Offsets") ); + symDbgChkBox = new QCheckBox( tr("Symbolic Debug") ); + regNamChkBox = new QCheckBox( tr("Register Names") ); + vbox->addWidget( romOfsChkBox ); + vbox->addWidget( symDbgChkBox ); + vbox->addWidget( regNamChkBox ); + + connect( romOfsChkBox, SIGNAL(stateChanged(int)), this, SLOT(displayROMoffsetCB(int)) ); + + button = new QPushButton( tr("Reload Symbols") ); + vbox->addWidget( button ); + + button = new QPushButton( tr("ROM Patcher") ); + vbox->addWidget( button ); + + frame->setLayout( vbox ); + frame->setFrameShape( QFrame::Box ); + + hbox = new QHBoxLayout(); + vbox1->addLayout( hbox ); + + button = new QPushButton( tr("Default Window Size") ); + autoOpenChkBox = new QCheckBox( tr("Auto-Open") ); + debFileChkBox = new QCheckBox( tr("DEB Files") ); + idaFontChkBox = new QCheckBox( tr("IDA Font") ); + hbox->addWidget( button ); + hbox->addWidget( autoOpenChkBox ); + hbox->addWidget( debFileChkBox ); + hbox->addWidget( idaFontChkBox ); + setLayout( mainLayout ); windowUpdateReq = true; @@ -383,6 +463,14 @@ void ConsoleDebugger::bpItemClicked( QTreeWidgetItem *item, int column) printf("Row: %i Column: %i \n", row, column ); +} +//---------------------------------------------------------------------------- +void ConsoleDebugger::bmItemClicked( QTreeWidgetItem *item, int column) +{ + int row = bmTree->indexOfTopLevelItem(item); + + printf("Row: %i Column: %i \n", row, column ); + } //---------------------------------------------------------------------------- void ConsoleDebugger::openBpEditWindow( int editIdx, watchpointinfo *wp ) @@ -852,6 +940,11 @@ void ConsoleDebugger::instructionsThresChanged(const QString &txt) } } //---------------------------------------------------------------------------- +void ConsoleDebugger::displayROMoffsetCB( int value ) +{ + asmView->setDisplayROMoffsets(value != Qt::Unchecked); +} +//---------------------------------------------------------------------------- void ConsoleDebugger::debugRunCB(void) { if (FCEUI_EmulationPaused()) @@ -996,6 +1089,13 @@ void ConsoleDebugger::seekPCCB (void) //asmView->scrollToPC(); } //---------------------------------------------------------------------------- +void ConsoleDebugger::resetCountersCB (void) +{ + ResetDebugStatisticsCounters(); + + updateRegisterView(); +} +//---------------------------------------------------------------------------- int QAsmView::getAsmLineFromAddr(int addr) { int line = -1; @@ -1156,6 +1256,8 @@ void QAsmView::updateAssemblyView(void) start_address_lp = starting_address; } + maxLineLen = 0; + asmClear(); addr = starting_address; @@ -1275,6 +1377,11 @@ void QAsmView::updateAssemblyView(void) a->line = asmEntry.size(); + if ( maxLineLen < line.size() ) + { + maxLineLen = line.size(); + } + line.append("\n"); //asmText->insertPlainText( tr(line.c_str()) ); @@ -1282,6 +1389,8 @@ void QAsmView::updateAssemblyView(void) asmEntry.push_back(a); } + setMinimumWidth( maxLineLen * pxCharWidth ); + vbar->setMaximum( asmEntry.size() ); } //---------------------------------------------------------------------------- @@ -1563,8 +1672,11 @@ QAsmView::QAsmView(QWidget *parent) hbar = NULL; asmPC = NULL; displayROMoffsets = false; + maxLineLen = 0; lineOffset = 0; maxLineOffset = 0; + + //setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ); } //---------------------------------------------------------------------------- QAsmView::~QAsmView(void) @@ -1595,6 +1707,16 @@ void QAsmView::scrollToPC(void) } } //---------------------------------------------------------------------------- +void QAsmView::setDisplayROMoffsets( bool value ) +{ + if ( value != displayROMoffsets ) + { + displayROMoffsets = value; + + updateAssemblyView(); + } +} +//---------------------------------------------------------------------------- void QAsmView::calcFontData(void) { this->setFont(font); diff --git a/src/drivers/Qt/ConsoleDebugger.h b/src/drivers/Qt/ConsoleDebugger.h index 1fbf46ce..9abc2b2c 100644 --- a/src/drivers/Qt/ConsoleDebugger.h +++ b/src/drivers/Qt/ConsoleDebugger.h @@ -64,6 +64,7 @@ class QAsmView : public QWidget int getAsmLineFromAddr(int addr); void setLine(int lineNum); void scrollToPC(void); + void setDisplayROMoffsets( bool value ); protected: void paintEvent(QPaintEvent *event); void keyPressEvent(QKeyEvent *event); @@ -79,6 +80,7 @@ class QAsmView : public QWidget QScrollBar *vbar; QScrollBar *hbar; + int maxLineLen; int pxCharWidth; int pxCharHeight; int pxCursorHeight; @@ -128,10 +130,13 @@ class ConsoleDebugger : public QDialog QLineEdit *regYEntry; QLineEdit *cpuCycExdVal; QLineEdit *instrExdVal; + QLineEdit *selBmAddr; QGroupBox *stackFrame; QGroupBox *bpFrame; QGroupBox *sfFrame; - QTreeWidget * bpTree; + QGroupBox *bmFrame; + QTreeWidget *bpTree; + QTreeWidget *bmTree; QCheckBox *brkBadOpsCbox; QCheckBox *N_chkbox; QCheckBox *V_chkbox; @@ -143,6 +148,12 @@ class ConsoleDebugger : public QDialog QCheckBox *C_chkbox; QCheckBox *brkCpuCycExd; QCheckBox *brkInstrsExd; + QCheckBox *romOfsChkBox; + QCheckBox *symDbgChkBox; + QCheckBox *regNamChkBox; + QCheckBox *autoOpenChkBox; + QCheckBox *debFileChkBox; + QCheckBox *idaFontChkBox; QLabel *ppuLbl; QLabel *spriteLbl; QLabel *scanLineLbl; @@ -177,10 +188,13 @@ class ConsoleDebugger : public QDialog void add_BP_CB(void); void edit_BP_CB(void); void delete_BP_CB(void); + void resetCountersCB (void); + void displayROMoffsetCB(int value); void breakOnBadOpcodeCB(int value); void breakOnCyclesCB( int value ); void breakOnInstructionsCB( int value ); void bpItemClicked( QTreeWidgetItem *item, int column); + void bmItemClicked( QTreeWidgetItem *item, int column); void cpuCycleThresChanged(const QString &txt); void instructionsThresChanged(const QString &txt);