@@ -74,6 +74,9 @@ RegistersDock::RegistersDock(QWidget *parent) : QDockWidget(parent) {
74
74
scrollarea = new QScrollArea (this );
75
75
scrollarea->setWidgetResizable (true );
76
76
widg = new StaticTable (scrollarea);
77
+ gp_highlighted = 0 ;
78
+ hi_highlighted = false ;
79
+ lo_highlighted = false ;
77
80
78
81
#define INIT (X, LABEL ) do { \
79
82
X = new QLabel (" 0x00000000" , widg); \
@@ -94,6 +97,13 @@ RegistersDock::RegistersDock(QWidget *parent) : QDockWidget(parent) {
94
97
setWidget (scrollarea);
95
98
setObjectName (" Registers" );
96
99
setWindowTitle (" Registers" );
100
+
101
+ pal_normal = QPalette (gp[0 ]->palette ());
102
+ pal_updated = QPalette (gp[0 ]->palette ());
103
+ pal_read = QPalette (gp[0 ]->palette ());
104
+ pal_normal.setColor (QPalette::WindowText, QColor (0 , 0 , 0 ));
105
+ pal_updated.setColor (QPalette::WindowText, QColor (240 , 0 , 0 ));
106
+ pal_read.setColor (QPalette::WindowText, QColor (0 , 0 , 240 ));
97
107
}
98
108
99
109
RegistersDock::~RegistersDock () {
@@ -118,16 +128,20 @@ void RegistersDock::setup(machine::QtMipsMachine *machine) {
118
128
}
119
129
120
130
const machine::Registers *regs = machine->registers ();
121
- connect (regs, SIGNAL (pc_update (std::uint32_t )), this , SLOT (pc_changed (std::uint32_t )));
122
- connect (regs, SIGNAL (gp_update (std::uint8_t ,std::uint32_t )), this , SLOT (gp_changed (std::uint8_t ,std::uint32_t )));
123
- connect (regs, SIGNAL (hi_lo_update (bool ,std::uint32_t )), this , SLOT (hi_lo_changed (bool ,std::uint32_t )));
124
131
125
132
// Load values
126
133
labelVal (pc, regs->read_pc ());
127
134
labelVal (hi, regs->read_hi_lo (true ));
128
135
labelVal (lo, regs->read_hi_lo (false ));
129
136
for (int i = 0 ; i < 32 ; i++)
130
137
labelVal (gp[i], regs->read_gp (i));
138
+
139
+ connect (regs, SIGNAL (pc_update (std::uint32_t )), this , SLOT (pc_changed (std::uint32_t )));
140
+ connect (regs, SIGNAL (gp_update (std::uint8_t ,std::uint32_t )), this , SLOT (gp_changed (std::uint8_t ,std::uint32_t )));
141
+ connect (regs, SIGNAL (hi_lo_update (bool ,std::uint32_t )), this , SLOT (hi_lo_changed (bool ,std::uint32_t )));
142
+ connect (regs, SIGNAL (gp_read (std::uint8_t ,std::uint32_t )), this , SLOT (gp_read (std::uint8_t ,std::uint32_t )));
143
+ connect (regs, SIGNAL (hi_lo_read (bool ,std::uint32_t )), this , SLOT (hi_lo_read (bool ,std::uint32_t )));
144
+ connect (machine, SIGNAL (tick ()), this , SLOT (clear_highlights ()));
131
145
}
132
146
133
147
void RegistersDock::pc_changed (std::uint32_t val) {
@@ -137,13 +151,58 @@ void RegistersDock::pc_changed(std::uint32_t val) {
137
151
void RegistersDock::gp_changed (std::uint8_t i, std::uint32_t val) {
138
152
SANITY_ASSERT (i < 32 , QString (" RegistersDock received signal with invalid gp register: " ) + QString::number (i));
139
153
labelVal (gp[i], val);
154
+ gp[i]->setPalette (pal_updated);
155
+ gp_highlighted |= 1 << i;
156
+ }
157
+
158
+ void RegistersDock::gp_read (std::uint8_t i, std::uint32_t val) {
159
+ (void )val;
160
+ SANITY_ASSERT (i < 32 , QString (" RegistersDock received signal with invalid gp register: " ) + QString::number (i));
161
+ if (!(gp_highlighted & (1 << i))) {
162
+ gp[i]->setPalette (pal_read);
163
+ gp_highlighted |= 1 << i;
164
+ }
140
165
}
141
166
142
167
void RegistersDock::hi_lo_changed (bool hi, std::uint32_t val) {
143
- if (hi)
168
+ if (hi) {
144
169
labelVal (this ->hi , val);
145
- else
170
+ this ->hi ->setPalette (pal_updated);
171
+ hi_highlighted = true ;
172
+ } else {
146
173
labelVal (lo, val);
174
+ this ->lo ->setPalette (pal_updated);
175
+ lo_highlighted = true ;
176
+ }
177
+ }
178
+
179
+ void RegistersDock::hi_lo_read (bool hi, std::uint32_t val) {
180
+ (void )val;
181
+ if (hi) {
182
+ if (!hi_highlighted)
183
+ this ->hi ->setPalette (pal_read);
184
+ hi_highlighted = true ;
185
+ } else {
186
+ if (!lo_highlighted)
187
+ this ->lo ->setPalette (pal_read);
188
+ lo_highlighted = true ;
189
+ }
190
+ }
191
+
192
+ void RegistersDock::clear_highlights () {
193
+ if (hi_highlighted)
194
+ this ->hi ->setPalette (pal_normal);
195
+ if (lo_highlighted)
196
+ this ->lo ->setPalette (pal_normal);
197
+ if (gp_highlighted != 0 ) {
198
+ for (int i = 0 ; i < 32 ; i++) {
199
+ if (gp_highlighted & (1 << i))
200
+ gp[i]->setPalette (pal_normal);
201
+ }
202
+ }
203
+ gp_highlighted = 0 ;
204
+ hi_highlighted = false ;
205
+ lo_highlighted = false ;
147
206
}
148
207
149
208
void RegistersDock::labelVal (QLabel *label, std::uint32_t value) {
0 commit comments