diff --git a/src/drivers/Qt/ConsoleDebugger.cpp b/src/drivers/Qt/ConsoleDebugger.cpp index 94cadf01..b21c1c14 100644 --- a/src/drivers/Qt/ConsoleDebugger.cpp +++ b/src/drivers/Qt/ConsoleDebugger.cpp @@ -61,14 +61,17 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent) mainLayout = new QHBoxLayout(); - asmText = new QTextEdit(this); + asmText = new QPlainTextEdit(this); vbox1 = new QVBoxLayout(); vbox2 = new QVBoxLayout(); hbox1 = new QHBoxLayout(); grid = new QGridLayout(); asmText->setFont(font); + asmText->setReadOnly(true); + asmText->setOverwriteMode(true); asmText->setMinimumWidth( 20 * fontCharWidth ); + asmText->setLineWrapMode( QPlainTextEdit::NoWrap ); vbox1->addLayout( hbox1 ); hbox1->addLayout( vbox2 ); @@ -152,7 +155,7 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent) vbox2->addLayout( hbox ); stackFrame = new QGroupBox(tr("Stack $0100")); - stackText = new QTextEdit(this); + stackText = new QPlainTextEdit(this); hbox = new QHBoxLayout(); hbox->addWidget( stackText ); vbox2->addWidget( stackFrame ); @@ -264,17 +267,23 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent) setLayout( mainLayout ); - displayROMoffsets = 0; + displayROMoffsets = false; + windowUpdateReq = true; asmPC = NULL; dbgWinList.push_back( this ); - updateWindowData(); + periodicTimer = new QTimer( this ); + + connect( periodicTimer, &QTimer::timeout, this, &ConsoleDebugger::updatePeriodic ); + + periodicTimer->start( 100 ); // 10hz } //---------------------------------------------------------------------------- ConsoleDebugger::~ConsoleDebugger(void) { printf("Destroy Debugger Window\n"); + periodicTimer->stop(); asmClear(); } //---------------------------------------------------------------------------- @@ -467,6 +476,8 @@ void ConsoleDebugger::updateAssemblyView(void) addr = starting_address; asmPC = NULL; + asmText->clear(); + //gtk_text_buffer_get_start_iter( textbuf, &iter ); //textview_lines_allocated = gtk_text_buffer_get_line_count( textbuf ) - 1; @@ -592,16 +603,43 @@ void ConsoleDebugger::updateWindowData(void) { updateAssemblyView(); + windowUpdateReq = false; +} +//---------------------------------------------------------------------------- +void ConsoleDebugger::updatePeriodic(void) +{ + //printf("Update Periodic\n"); + + if ( windowUpdateReq ) + { + fceuWrapperLock(); + updateWindowData(); + fceuWrapperUnLock(); + } +} +//---------------------------------------------------------------------------- +void ConsoleDebugger::breakPointNotify( int addr ) +{ + windowUpdateReq = true; } //---------------------------------------------------------------------------- void FCEUD_DebugBreakpoint( int addr ) { std::list ::iterator it; + printf("Breakpoint Hit: 0x%04X \n", addr ); + + fceuWrapperUnLock(); for (it=dbgWinList.begin(); it!=dbgWinList.end(); it++) { - (*it)->updateWindowData(); + (*it)->breakPointNotify( addr ); } + + while (FCEUI_EmulationPaused() && !FCEUI_EmulationFrameStepped()) + { + usleep(100000); + } + fceuWrapperLock(); } //---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/ConsoleDebugger.h b/src/drivers/Qt/ConsoleDebugger.h index a808d0a0..5d52a924 100644 --- a/src/drivers/Qt/ConsoleDebugger.h +++ b/src/drivers/Qt/ConsoleDebugger.h @@ -13,12 +13,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include "Qt/main.h" @@ -57,6 +59,7 @@ class ConsoleDebugger : public QDialog void updateAssemblyView(void); void asmClear(void); int getAsmLineFromAddr(int addr); + void breakPointNotify(int addr); protected: void closeEvent(QCloseEvent *event); @@ -64,8 +67,8 @@ class ConsoleDebugger : public QDialog //void keyReleaseEvent(QKeyEvent *event); //QTreeWidget *tree; - QTextEdit *asmText; - QTextEdit *stackText; + QPlainTextEdit *asmText; + QPlainTextEdit *stackText; QLineEdit *seekEntry; QLineEdit *pcEntry; QLineEdit *regAEntry; @@ -94,17 +97,20 @@ class ConsoleDebugger : public QDialog QLabel *pixLbl; QLabel *cpuCyclesLbl; QLabel *cpuInstrsLbl; + QTimer *periodicTimer; QFont font; dbg_asm_entry_t *asmPC; std::vector asmEntry; - char displayROMoffsets; + bool displayROMoffsets; + bool windowUpdateReq; private: public slots: void closeWindow(void); private slots: + void updatePeriodic(void); };