diff options
Diffstat (limited to 'qtmips_gui')
-rw-r--r-- | qtmips_gui/cop0dock.cpp | 46 | ||||
-rw-r--r-- | qtmips_gui/cop0dock.h | 9 | ||||
-rw-r--r-- | qtmips_gui/registersdock.cpp | 69 | ||||
-rw-r--r-- | qtmips_gui/registersdock.h | 12 |
4 files changed, 128 insertions, 8 deletions
diff --git a/qtmips_gui/cop0dock.cpp b/qtmips_gui/cop0dock.cpp index 1070444..9e35d6b 100644 --- a/qtmips_gui/cop0dock.cpp +++ b/qtmips_gui/cop0dock.cpp @@ -50,14 +50,24 @@ Cop0Dock::Cop0Dock(QWidget *parent) : QDockWidget(parent) { } while(false) cop0reg[0] = nullptr; - for (int i = 1; i < machine::Cop0State::COP0REGS_CNT; i++) + for (int i = 1; i < machine::Cop0State::COP0REGS_CNT; i++) { INIT(cop0reg[i], machine::Cop0State::cop0reg_name((machine::Cop0State::Cop0Registers)i)); + cop0reg_highlighted[i] = false; + } #undef INIT scrollarea->setWidget(widg); setWidget(scrollarea); setObjectName("Coprocessor0"); setWindowTitle("Coprocessor0"); + + pal_normal = QPalette(cop0reg[1]->palette()); + pal_updated = QPalette(cop0reg[1]->palette()); + pal_read = QPalette(cop0reg[1]->palette()); + pal_normal.setColor(QPalette::WindowText, QColor(0, 0, 0)); + pal_updated.setColor(QPalette::WindowText, QColor(240, 0, 0)); + pal_read.setColor(QPalette::WindowText, QColor(0, 0, 240)); + cop0reg_highlighted_any = false; } Cop0Dock::~Cop0Dock() { @@ -76,11 +86,15 @@ void Cop0Dock::setup(machine::QtMipsMachine *machine) { } const machine::Cop0State *cop0state = machine->cop0state(); - connect(cop0state, &machine::Cop0State::cop0reg_update, - this, &Cop0Dock::cop0reg_changed); for (int i = 1; i < machine::Cop0State::COP0REGS_CNT; i++) labelVal(cop0reg[i], cop0state->read_cop0reg((machine::Cop0State::Cop0Registers)i)); + + connect(cop0state, &machine::Cop0State::cop0reg_update, + this, &Cop0Dock::cop0reg_changed); + connect(cop0state, &machine::Cop0State::cop0reg_read, + this, &Cop0Dock::cop0reg_read); + connect(machine, SIGNAL(tick()), this, SLOT(clear_highlights())); } void Cop0Dock::cop0reg_changed(enum machine::Cop0State::Cop0Registers reg, std::uint32_t val) { @@ -88,6 +102,32 @@ void Cop0Dock::cop0reg_changed(enum machine::Cop0State::Cop0Registers reg, std:: QString("Cop0Dock received signal with invalid cop0 register: ") + QString::number((uint)reg)); labelVal(cop0reg[(uint)reg], val); + cop0reg[reg]->setPalette(pal_updated); + cop0reg_highlighted[reg] = true; + cop0reg_highlighted_any = true; +} + +void Cop0Dock::cop0reg_read(enum machine::Cop0State::Cop0Registers reg, std::uint32_t val) { + (void)val; + SANITY_ASSERT((uint)reg < machine::Cop0State::COP0REGS_CNT && (uint)reg, + QString("Cop0Dock received signal with invalid cop0 register: ") + + QString::number((uint)reg)); + if (!cop0reg_highlighted[reg]) + cop0reg[reg]->setPalette(pal_read); + cop0reg_highlighted[reg] = true; + cop0reg_highlighted_any = true; +} + +void Cop0Dock::clear_highlights() { + if (!cop0reg_highlighted_any) + return; + for (int i = 1; i < machine::Cop0State::COP0REGS_CNT; i++) { + if (cop0reg_highlighted[i]) { + cop0reg[i]->setPalette(pal_normal); + cop0reg_highlighted[i] = false; + } + } + cop0reg_highlighted_any = false; } void Cop0Dock::labelVal(QLabel *label, std::uint32_t value) { diff --git a/qtmips_gui/cop0dock.h b/qtmips_gui/cop0dock.h index 5dfa058..79f8a3e 100644 --- a/qtmips_gui/cop0dock.h +++ b/qtmips_gui/cop0dock.h @@ -41,6 +41,7 @@ #include <QFormLayout> #include <QScrollArea> #include <QPropertyAnimation> +#include <QPalette> #include "qtmipsmachine.h" #include "statictable.h" @@ -54,12 +55,20 @@ public: private slots: void cop0reg_changed(enum machine::Cop0State::Cop0Registers reg, std::uint32_t val); + void cop0reg_read(enum machine::Cop0State::Cop0Registers reg, std::uint32_t val); + void clear_highlights(); private: StaticTable *widg; QScrollArea *scrollarea; QLabel *cop0reg[machine::Cop0State::COP0REGS_CNT]; + bool cop0reg_highlighted[machine::Cop0State::COP0REGS_CNT]; + bool cop0reg_highlighted_any; + + QPalette pal_normal; + QPalette pal_updated; + QPalette pal_read; void labelVal(QLabel *label, std::uint32_t val); }; diff --git a/qtmips_gui/registersdock.cpp b/qtmips_gui/registersdock.cpp index 2823abc..b72696d 100644 --- a/qtmips_gui/registersdock.cpp +++ b/qtmips_gui/registersdock.cpp @@ -74,6 +74,9 @@ RegistersDock::RegistersDock(QWidget *parent) : QDockWidget(parent) { scrollarea = new QScrollArea(this); scrollarea->setWidgetResizable(true); widg = new StaticTable(scrollarea); + gp_highlighted = 0; + hi_highlighted = false; + lo_highlighted = false; #define INIT(X, LABEL) do{ \ X = new QLabel("0x00000000", widg); \ @@ -94,6 +97,13 @@ RegistersDock::RegistersDock(QWidget *parent) : QDockWidget(parent) { setWidget(scrollarea); setObjectName("Registers"); setWindowTitle("Registers"); + + pal_normal = QPalette(gp[0]->palette()); + pal_updated = QPalette(gp[0]->palette()); + pal_read = QPalette(gp[0]->palette()); + pal_normal.setColor(QPalette::WindowText, QColor(0, 0, 0)); + pal_updated.setColor(QPalette::WindowText, QColor(240, 0, 0)); + pal_read.setColor(QPalette::WindowText, QColor(0, 0, 240)); } RegistersDock::~RegistersDock() { @@ -118,9 +128,6 @@ void RegistersDock::setup(machine::QtMipsMachine *machine) { } const machine::Registers *regs = machine->registers(); - connect(regs, SIGNAL(pc_update(std::uint32_t)), this, SLOT(pc_changed(std::uint32_t))); - connect(regs, SIGNAL(gp_update(std::uint8_t,std::uint32_t)), this, SLOT(gp_changed(std::uint8_t,std::uint32_t))); - connect(regs, SIGNAL(hi_lo_update(bool,std::uint32_t)), this, SLOT(hi_lo_changed(bool,std::uint32_t))); // Load values labelVal(pc, regs->read_pc()); @@ -128,6 +135,13 @@ void RegistersDock::setup(machine::QtMipsMachine *machine) { labelVal(lo, regs->read_hi_lo(false)); for (int i = 0; i < 32; i++) labelVal(gp[i], regs->read_gp(i)); + + connect(regs, SIGNAL(pc_update(std::uint32_t)), this, SLOT(pc_changed(std::uint32_t))); + connect(regs, SIGNAL(gp_update(std::uint8_t,std::uint32_t)), this, SLOT(gp_changed(std::uint8_t,std::uint32_t))); + connect(regs, SIGNAL(hi_lo_update(bool,std::uint32_t)), this, SLOT(hi_lo_changed(bool,std::uint32_t))); + connect(regs, SIGNAL(gp_read(std::uint8_t,std::uint32_t)), this, SLOT(gp_read(std::uint8_t,std::uint32_t))); + connect(regs, SIGNAL(hi_lo_read(bool,std::uint32_t)), this, SLOT(hi_lo_read(bool,std::uint32_t))); + connect(machine, SIGNAL(tick()), this, SLOT(clear_highlights())); } void RegistersDock::pc_changed(std::uint32_t val) { @@ -137,13 +151,58 @@ void RegistersDock::pc_changed(std::uint32_t val) { void RegistersDock::gp_changed(std::uint8_t i, std::uint32_t val) { SANITY_ASSERT(i < 32, QString("RegistersDock received signal with invalid gp register: ") + QString::number(i)); labelVal(gp[i], val); + gp[i]->setPalette(pal_updated); + gp_highlighted |= 1 << i; +} + +void RegistersDock::gp_read(std::uint8_t i, std::uint32_t val) { + (void)val; + SANITY_ASSERT(i < 32, QString("RegistersDock received signal with invalid gp register: ") + QString::number(i)); + if (!(gp_highlighted & (1 << i))) { + gp[i]->setPalette(pal_read); + gp_highlighted |= 1 << i; + } } void RegistersDock::hi_lo_changed(bool hi, std::uint32_t val) { - if (hi) + if (hi) { labelVal(this->hi, val); - else + this->hi->setPalette(pal_updated); + hi_highlighted = true; + } else { labelVal(lo, val); + this->lo->setPalette(pal_updated); + lo_highlighted = true; + } +} + +void RegistersDock::hi_lo_read(bool hi, std::uint32_t val) { + (void)val; + if (hi) { + if (!hi_highlighted) + this->hi->setPalette(pal_read); + hi_highlighted = true; + } else { + if (!lo_highlighted) + this->lo->setPalette(pal_read); + lo_highlighted = true; + } +} + +void RegistersDock::clear_highlights() { + if (hi_highlighted) + this->hi->setPalette(pal_normal); + if (lo_highlighted) + this->lo->setPalette(pal_normal); + if (gp_highlighted != 0) { + for (int i = 0; i < 32; i++) { + if (gp_highlighted & (1 << i)) + gp[i]->setPalette(pal_normal); + } + } + gp_highlighted = 0; + hi_highlighted = false; + lo_highlighted = false; } void RegistersDock::labelVal(QLabel *label, std::uint32_t value) { diff --git a/qtmips_gui/registersdock.h b/qtmips_gui/registersdock.h index c56f375..dcc5e9b 100644 --- a/qtmips_gui/registersdock.h +++ b/qtmips_gui/registersdock.h @@ -41,6 +41,7 @@ #include <QFormLayout> #include <QScrollArea> #include <QPropertyAnimation> +#include <QPalette> #include "qtmipsmachine.h" #include "statictable.h" @@ -56,6 +57,9 @@ private slots: void pc_changed(std::uint32_t val); void gp_changed(std::uint8_t i, std::uint32_t val); void hi_lo_changed(bool hi, std::uint32_t val); + void gp_read(std::uint8_t i, std::uint32_t val); + void hi_lo_read(bool hi, std::uint32_t val); + void clear_highlights(); private: StaticTable *widg; @@ -66,6 +70,14 @@ private: QLabel *lo; QLabel *gp[32]; + std::uint32_t gp_highlighted; + bool hi_highlighted; + bool lo_highlighted; + + QPalette pal_normal; + QPalette pal_updated; + QPalette pal_read; + void labelVal(QLabel *label, std::uint32_t val); }; |