Debian Codegraph @

src/VDPStatusRegViewer.cpp

raw symbols SCIP
1 #include "VDPStatusRegViewer.h"
2 #include "VramBitMappedView.h"
3 #include "VDPDataStore.h"
4 #include "InteractiveLabel.h"
5 #include <QMessageBox>
6 #include <QPalette>
7
8
9 highlightDispatcher::highlightDispatcher()
10 {
11 counter = 0;
12 }
13
14 void highlightDispatcher::receiveState(bool state)
15 {
16 if (state) {
17 if (counter == 0) {
18 emit stateDispatched(true);
19 }
20 ++counter;
21 } else {
22 --counter;
23 if (counter == 0) {
24 emit stateDispatched(false);
25 }
26 }
27 }
28
29
30 VDPStatusRegViewer::VDPStatusRegViewer(QWidget* parent)
31 : QDialog(parent)
32 {
33 setupUi(this);
34 //statusregs = VDPDataStore::instance().getStatusRegsPointer();
35
36 // now hook up some signals and slots
37 connectHighLights();
38
39 // get initial data
40 refresh();
41 }
42
43 void VDPStatusRegViewer::decodeVDPStatusRegs()
44 {
45 // first update all hex values
46 label_val_0->setText(QString("%1").arg(statusregs[0], 2, 16, QChar('0')).toUpper());
47 label_val_1->setText(QString("%1").arg(statusregs[1], 2, 16, QChar('0')).toUpper());
48 label_val_2->setText(QString("%1").arg(statusregs[2], 2, 16, QChar('0')).toUpper());
49 label_val_3->setText(QString("%1").arg(statusregs[3], 2, 16, QChar('0')).toUpper());
50 label_val_4->setText(QString("%1").arg(statusregs[4], 2, 16, QChar('0')).toUpper());
51 label_val_5->setText(QString("%1").arg(statusregs[5], 2, 16, QChar('0')).toUpper());
52 label_val_6->setText(QString("%1").arg(statusregs[6], 2, 16, QChar('0')).toUpper());
53 label_val_7->setText(QString("%1").arg(statusregs[7], 2, 16, QChar('0')).toUpper());
54 label_val_8->setText(QString("%1").arg(statusregs[8], 2, 16, QChar('0')).toUpper());
55 label_val_9->setText(QString("%1").arg(statusregs[9], 2, 16, QChar('0')).toUpper());
56
57 // update all the individual bits
58 for (int r = 0; r <= 9; ++r) {
59 for (int b = 7; b >= 0; --b) {
60 QString name = QString("label_%1_%2").arg(r).arg(b);
61 auto* l = findChild<InteractiveLabel*>(name);
62 l->setText((statusregs[r] & (1 << b)) ? "1" : "0");
63 }
64 }
65
66 // Start the interpretation
67 label_I_0_7->setText((statusregs[0] & 128) ? "Interrupt" : "No int");
68 label_I_0_6->setText((statusregs[0] & 64) ? "5th sprite" : "No 5th");
69 label_I_0_5->setText((statusregs[0] & 32) ? "Collision" : "No collision");
70 label_I_0_0->setText(QString("sprnr:%1").arg(statusregs[0] & 31));
71
72 label_I_1_7->setText((statusregs[1] & 128) ? "Light" : "No light");
73 label_I_1_6->setText((statusregs[1] & 64) ? "switch on" : "Switch off");
74 label_I_1_0->setText((statusregs[1] & 1) ? "hor scanline int" : "no hor int");
75 QString id;
76 switch (statusregs[1] & 62) {
77 case 0:
78 id = QString("v9938");
79 break;
80 case 2:
81 id = QString("v9948");
82 break;
83 case 4:
84 id = QString("v9958");
85 break;
86 default:
87 id = QString("unknown VDP");
88 }
89 label_I_1_1->setText(id);
90
91 label_I_2_7->setText((statusregs[2] & 128) ? "Transfer ready" : "Transferring");
92 label_I_2_6->setText((statusregs[2] & 64) ? "Vertical scanning" : "Not vert scan");
93 label_I_2_5->setText((statusregs[2] & 32) ? "Horizontal scanning" : "Not hor scan");
94 label_I_2_4->setText((statusregs[2] & 16) ? "Boundary color detected" : "BC not deteced");
95 label_I_2_1->setText((statusregs[2] & 2) ? "First field" : "Second field");
96 label_I_2_0->setText((statusregs[2] & 1) ? "Command execution" : "No command exec");
97
98 label_I_3->setText(QString("Column: %1").arg(statusregs[3] | ((statusregs[4] & 1) << 8)));
99 label_I_5->setText(QString("Row: %1").arg(statusregs[5] | ((statusregs[6] & 3) << 8)));
100 label_I_7->setText(QString("Color: %1").arg(statusregs[7]));
101 label_I_8->setText(QString("Border X: %1").arg(statusregs[8] | ((statusregs[9] & 1) << 8)));
102 }
103
104 void VDPStatusRegViewer::doConnect(InteractiveLabel* lab, highlightDispatcher* dis)
105 {
106 connect(lab, &InteractiveLabel::mouseOver,
107 dis, &highlightDispatcher::receiveState);
108 connect(dis, &highlightDispatcher::stateDispatched,
109 lab, &InteractiveLabel::highlight);
110 }
111
112 void VDPStatusRegViewer::makeGroup(QList<InteractiveLabel*> list, InteractiveLabel* explained)
113 {
114 // First "steal" the Tooltip of the explained widget.
115 for (auto* item : list) {
116 item->setToolTip(explained->toolTip());
117 }
118 // now create a dispatcher and connect all to them
119 list << explained;
120 auto* dispat = new highlightDispatcher();
121 for (auto* item : list) {
122 doConnect(item, dispat);
123 }
124 }
125
126 void VDPStatusRegViewer::connectHighLights()
127 {
128 QList<InteractiveLabel*> list;
129
130 list.clear();
131 list << label_0_7;
132 makeGroup(list, label_I_0_7);
133
134 list.clear();
135 list << label_0_6;
136 makeGroup(list, label_I_0_6);
137
138 list.clear();
139 list << label_0_5;
140 makeGroup(list, label_I_0_5);
141
142 list.clear();
143 list << label_0_4 << label_0_3 << label_0_2 << label_0_1 << label_0_0;
144 makeGroup(list, label_I_0_0);
145
146 list.clear();
147 list << label_1_7;
148 makeGroup(list, label_I_1_7);
149
150 list.clear();
151 list << label_1_6;
152 makeGroup(list, label_I_1_6);
153
154 list.clear();
155 list << label_1_4 << label_1_3 << label_1_2 << label_1_1;
156 makeGroup(list, label_I_1_1);
157
158 list.clear();
159 list << label_1_0;
160 makeGroup(list, label_I_1_0);
161
162 list.clear();
163 list << label_2_7;
164 makeGroup(list, label_I_2_7);
165
166 list.clear();
167 list << label_2_6;
168 makeGroup(list, label_I_2_6);
169
170 list.clear();
171 list << label_2_5;
172 makeGroup(list, label_I_2_5);
173
174 list.clear();
175 list << label_2_4;
176 makeGroup(list, label_I_2_4);
177
178 list.clear();
179 list << label_2_1;
180 makeGroup(list, label_I_2_1);
181
182 list.clear();
183 list << label_2_0;
184 makeGroup(list, label_I_2_0);
185
186 list.clear();
187 list << label_2_0;
188 makeGroup(list, label_I_2_0);
189
190 list.clear();
191 list << label_3_7 << label_3_6 << label_3_5 << label_3_4;
192 list << label_3_3 << label_3_2 << label_3_1 << label_3_0;
193 list << label_4_7 << label_4_6 << label_4_5 << label_4_4;
194 list << label_4_3 << label_4_2 << label_4_1 << label_4_0;
195 makeGroup(list, label_I_3);
196
197 list.clear();
198 list << label_5_7 << label_5_6 << label_5_5 << label_5_4;
199 list << label_5_3 << label_5_2 << label_5_1 << label_5_0;
200 list << label_6_7 << label_6_6 << label_6_5 << label_6_4;
201 list << label_6_3 << label_6_2 << label_6_1 << label_6_0;
202 makeGroup(list, label_I_5);
203
204 list.clear();
205 list << label_7_7 << label_7_6 << label_7_5 << label_7_4;
206 list << label_7_3 << label_7_2 << label_7_1 << label_7_0;
207 makeGroup(list, label_I_7);
208
209 list.clear();
210 list << label_8_7 << label_8_6 << label_8_5 << label_8_4;
211 list << label_8_3 << label_8_2 << label_8_1 << label_8_0;
212 list << label_9_7 << label_9_6 << label_9_5 << label_9_4;
213 list << label_9_3 << label_9_2 << label_9_1 << label_9_0;
214 makeGroup(list, label_I_8);
215 }
216
217 void VDPStatusRegViewer::refresh()
218 {
219 new SimpleHexRequest("{VDP status regs}", 0, 16, statusregs, *this);
220 }
221
222 void VDPStatusRegViewer::DataHexRequestReceived()
223 {
224 decodeVDPStatusRegs();
225 }