| 1 | #include "VDPRegViewer.h" |
| 2 | #include "VDPDataStore.h" |
| 3 | #include "InteractiveButton.h" |
| 4 | #include "CommClient.h" |
| 5 | |
| 6 | static const int VDP_TMS99X8 = 1; |
| 7 | static const int VDP_V9938 = 0; |
| 8 | static const int VDP_V9958 = 4; |
| 9 | |
| 10 | |
| 11 | // class buttonHighlightDispatcher |
| 12 | |
| 13 | buttonHighlightDispatcher::buttonHighlightDispatcher() |
| 14 | : counter(0) |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | void buttonHighlightDispatcher::receiveState(bool state) |
| 19 | { |
| 20 | if (state) { |
| 21 | if (counter == 0) { |
| 22 | emit stateDispatched(true); |
| 23 | } |
| 24 | ++counter; |
| 25 | } else { |
| 26 | --counter; |
| 27 | if (counter == 0) { |
| 28 | emit stateDispatched(false); |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | |
| 34 | // class VDPRegViewer |
| 35 | |
| 36 | VDPRegViewer::VDPRegViewer(QWidget *parent) |
| 37 | : QDialog(parent) |
| 38 | { |
| 39 | setupUi(this); |
| 40 | connect(VDPcomboBox, qOverload<int>(&QComboBox::currentIndexChanged), this, &VDPRegViewer::on_VDPcomboBox_currentIndexChanged); |
| 41 | |
| 42 | vdpId = 99; // make sure that we parse the first time the status registers are read |
| 43 | vdpId = VDP_V9958; // quick hack for now |
| 44 | |
| 45 | // now hook up some signals and slots |
| 46 | connectHighLights(); |
| 47 | |
| 48 | // Now hook up some signals and slots. |
| 49 | // This allows the VDPDatastore to start asking for data as quickly as possible. |
| 50 | auto& dataStore = VDPDataStore::instance(); |
| 51 | connect(&dataStore, &VDPDataStore::dataRefreshed, this, &VDPRegViewer::refresh); |
| 52 | dataStore.refresh(); |
| 53 | } |
| 54 | |
| 55 | void VDPRegViewer::setRegisterVisible(int r, bool visible) |
| 56 | { |
| 57 | QString name1 = QString("label_R%1").arg(r); |
| 58 | auto* l1 = findChild<QLabel*>(name1); |
| 59 | l1->setVisible(visible); |
| 60 | |
| 61 | QString name2 = QString("label_val_%1").arg(r); |
| 62 | auto* l2 = findChild<QLabel*>(name2); |
| 63 | l2->setVisible(visible); |
| 64 | |
| 65 | for (int b = 7; b >= 0; --b) { |
| 66 | QString name3 = QString("pushButton_%1_%2").arg(r).arg(b); |
| 67 | auto *i = findChild<InteractiveButton*>(name3); |
| 68 | i->setVisible(visible); |
| 69 | } |
| 70 | |
| 71 | // now hide/show the explications of the give register |
| 72 | switch (r) { |
| 73 | case 8: |
| 74 | label_dec_tp->setVisible(visible); |
| 75 | label_dec_spd->setVisible(visible); |
| 76 | break; |
| 77 | case 9: |
| 78 | label_dec_nt->setVisible(visible); |
| 79 | label_dec_nt2->setVisible(visible); |
| 80 | label_dec_il->setVisible(visible); |
| 81 | label_dec_eo->setVisible(visible); |
| 82 | label_dec_ln->setVisible(visible); |
| 83 | label_dec_ln2->setVisible(visible); |
| 84 | break; |
| 85 | case 12: |
| 86 | label_t2->setVisible(visible); |
| 87 | label_bc->setVisible(visible); |
| 88 | label_dec_t2->setVisible(visible); |
| 89 | label_dec_bc->setVisible(visible); |
| 90 | break; |
| 91 | case 13: |
| 92 | label_on->setVisible(visible); |
| 93 | label_off->setVisible(visible); |
| 94 | label_dec_on->setVisible(visible); |
| 95 | label_dec_off->setVisible(visible); |
| 96 | break; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | void VDPRegViewer::decodeStatusVDPRegs() |
| 101 | { |
| 102 | //const uint8_t* statusregs = regs + 64; |
| 103 | //int id = statusregs[1] & 62; // + (machine_has_TMS99x8 ? 1 : 0) |
| 104 | // test MSX1 id = 1; |
| 105 | //if (vdpId != id) { |
| 106 | // vdpId = id; |
| 107 | if (vdpId == VDP_TMS99X8) { |
| 108 | // TMS9918 = MSX1 VDP |
| 109 | groupBox_V9958->setVisible(false); |
| 110 | groupBox_TableBase->setVisible(true); |
| 111 | groupBox_Color->setVisible(true); |
| 112 | groupBox_Display->setVisible(false); |
| 113 | groupBox_Access->setVisible(false); |
| 114 | groupBox_dec_V9958->setVisible(false); |
| 115 | groupBox_dec_TableBase->setVisible(true); |
| 116 | groupBox_dec_Color->setVisible(true); |
| 117 | groupBox_dec_Display->setVisible(false); |
| 118 | groupBox_dec_Access->setVisible(false); |
| 119 | label_dec_416K->setVisible(true); |
| 120 | label_dec_ie1->setVisible(false); |
| 121 | label_dec_ie2->setVisible(false); |
| 122 | label_dec_dg->setVisible(false); |
| 123 | setRegisterVisible( 8, false); |
| 124 | setRegisterVisible( 9, false); |
| 125 | setRegisterVisible(10, false); |
| 126 | setRegisterVisible(11, false); |
| 127 | setRegisterVisible(12, false); |
| 128 | setRegisterVisible(13, false); |
| 129 | setRegisterVisible(20, false); |
| 130 | setRegisterVisible(21, false); |
| 131 | setRegisterVisible(22, false); |
| 132 | pushButton_0_2->setText("0"); |
| 133 | pushButton_0_2->setToolTip(""); |
| 134 | pushButton_0_3->setText("0"); |
| 135 | pushButton_0_3->setToolTip(""); |
| 136 | pushButton_0_4->setText("0"); |
| 137 | pushButton_0_4->setToolTip(""); |
| 138 | pushButton_0_5->setText("0"); |
| 139 | pushButton_0_5->setToolTip(""); |
| 140 | pushButton_0_6->setText("0"); |
| 141 | pushButton_0_6->setToolTip(""); |
| 142 | pushButton_1_7->setText("4/16"); |
| 143 | pushButton_1_7->setToolTip( |
| 144 | "4/16K selection\n" |
| 145 | "0 selects 4027 RAM operation\n" |
| 146 | "1 selects 4108/4116 RAM operation"); |
| 147 | // mask all A16 bits of regs < 7 |
| 148 | pushButton_2_6->setText("0"); |
| 149 | pushButton_4_5->setText("0"); |
| 150 | pushButton_6_5->setText("0"); |
| 151 | // mask all A15 |
| 152 | pushButton_2_5->setText("0"); |
| 153 | pushButton_4_4->setText("0"); |
| 154 | pushButton_6_4->setText("0"); |
| 155 | // mask all A14 bits of regs < 7 |
| 156 | pushButton_2_4->setText("0"); |
| 157 | pushButton_4_3->setText("0"); |
| 158 | pushButton_6_3->setText("0"); |
| 159 | disconnect(modeBitsDispat, nullptr, pushButton_0_2, nullptr); |
| 160 | disconnect(modeBitsDispat, nullptr, pushButton_0_3, nullptr); |
| 161 | disconnect(pushButton_0_2, nullptr, nullptr, nullptr); |
| 162 | disconnect(pushButton_0_3, nullptr, nullptr, nullptr); |
| 163 | disconnect(pushButton_0_4, nullptr, nullptr, nullptr); |
| 164 | disconnect(pushButton_0_5, nullptr, nullptr, nullptr); |
| 165 | disconnect(pushButton_0_6, nullptr, nullptr, nullptr); |
| 166 | monoGroup(pushButton_1_7, label_dec_416K); |
| 167 | } else { |
| 168 | // V9938 = MSX2 VDP |
| 169 | // or |
| 170 | // V9958 = MSX2+ VDP |
| 171 | groupBox_TableBase->setVisible(true); |
| 172 | groupBox_Color->setVisible(true); |
| 173 | groupBox_Display->setVisible(true); |
| 174 | groupBox_Access->setVisible(true); |
| 175 | groupBox_dec_TableBase->setVisible(true); |
| 176 | groupBox_dec_Color->setVisible(true); |
| 177 | groupBox_dec_Display->setVisible(true); |
| 178 | groupBox_dec_Access->setVisible(true); |
| 179 | label_dec_416K->setVisible(false); |
| 180 | label_dec_ie1->setVisible(true); |
| 181 | label_dec_dg->setVisible(true); |
| 182 | setRegisterVisible( 8, true); |
| 183 | setRegisterVisible( 9, true); |
| 184 | setRegisterVisible(10, true); |
| 185 | setRegisterVisible(11, true); |
| 186 | setRegisterVisible(12, true); |
| 187 | setRegisterVisible(13, true); |
| 188 | setRegisterVisible(20, true); |
| 189 | setRegisterVisible(21, true); |
| 190 | setRegisterVisible(22, true); |
| 191 | pushButton_0_2->setText("M4"); |
| 192 | pushButton_0_3->setText("M5"); |
| 193 | pushButton_0_4->setText("IE1"); |
| 194 | pushButton_0_6->setText("DG"); |
| 195 | pushButton_1_7->setText("0"); |
| 196 | pushButton_0_2->setToolTip("Used to change the display mode."); |
| 197 | pushButton_0_3->setToolTip("Used to change the display mode."); |
| 198 | pushButton_0_4->setToolTip("Enables interrupt from Horizontal scanning line by Interrupt Enable 1."); |
| 199 | pushButton_0_6->setToolTip("Sets the color bus to input mode, and inputs data into the VRAM."); |
| 200 | pushButton_1_7->setToolTip(""); |
| 201 | |
| 202 | // all A16 bits of regs < 7 |
| 203 | pushButton_4_5->setText("A16"); |
| 204 | pushButton_6_5->setText("A16"); |
| 205 | // all A15 |
| 206 | pushButton_4_4->setText("A15"); |
| 207 | pushButton_6_4->setText("A15"); |
| 208 | // all A14 |
| 209 | pushButton_4_3->setText("A14"); |
| 210 | pushButton_6_3->setText("A14"); |
| 211 | ////pushButton_0_5->setText("IE2"); |
| 212 | |
| 213 | ////disconnect(pushButton_0_7, 0, 0, 0); |
| 214 | ////disconnect(label_dec_416K, 0, 0, 0); |
| 215 | |
| 216 | ////reGroup(pushButton_0_2, modeBitsDispat); |
| 217 | ////reGroup(pushButton_0_3, modeBitsDispat); |
| 218 | |
| 219 | ////monoGroup(pushButton_0_4, label_dec_ie1); |
| 220 | ////monoGroup(pushButton_0_5, label_dec_ie2); |
| 221 | ////monoGroup(pushButton_0_6, label_dec_dg); |
| 222 | |
| 223 | //break; |
| 224 | // V9958 = MSX2+ VDP |
| 225 | ////groupBox_TableBase->setVisible(true); |
| 226 | ////groupBox_Color->setVisible(true); |
| 227 | ////groupBox_Display->setVisible(true); |
| 228 | ////groupBox_Access->setVisible(true); |
| 229 | ////groupBox_dec_TableBase->setVisible(true); |
| 230 | ////groupBox_dec_Color->setVisible(true); |
| 231 | ////groupBox_dec_Display->setVisible(true); |
| 232 | ////groupBox_dec_Access->setVisible(true); |
| 233 | ////label_dec_416K->setVisible(false); |
| 234 | ////label_dec_ie1->setVisible(true); |
| 235 | ////label_dec_dg->setVisible(true); |
| 236 | ////setRegisterVisible( 8, true); |
| 237 | ////setRegisterVisible( 9, true); |
| 238 | ////setRegisterVisible(10, true); |
| 239 | ////setRegisterVisible(11, true); |
| 240 | ////setRegisterVisible(12, true); |
| 241 | ////setRegisterVisible(13, true); |
| 242 | ////setRegisterVisible(20, true); |
| 243 | ////setRegisterVisible(21, true); |
| 244 | ////setRegisterVisible(22, true); |
| 245 | ////pushButton_0_2->setText("M4"); |
| 246 | ////pushButton_0_3->setText("M5"); |
| 247 | ////pushButton_0_4->setText("IE1"); |
| 248 | ////pushButton_0_6->setText("DG"); |
| 249 | ////pushButton_1_7->setText("0"); |
| 250 | ////pushButton_0_2->setToolTip("Used to change the display mode."); |
| 251 | ////pushButton_0_3->setToolTip("Used to change the display mode."); |
| 252 | ////pushButton_0_4->setToolTip("Enables interrupt from Horizontal scanning line by Interrupt Enable 1."); |
| 253 | ////pushButton_0_6->setToolTip("Sets the color bus to input mode, and inputs data into the VRAM."); |
| 254 | ////pushButton_1_7->setToolTip(""); |
| 255 | |
| 256 | pushButton_1_7->setToolTip(""); |
| 257 | disconnect(pushButton_0_7, nullptr, nullptr, nullptr); |
| 258 | disconnect(label_dec_416K, nullptr, nullptr, nullptr); |
| 259 | |
| 260 | reGroup(pushButton_0_2, modeBitsDispat); |
| 261 | reGroup(pushButton_0_3, modeBitsDispat); |
| 262 | |
| 263 | monoGroup(pushButton_0_4, label_dec_ie1); |
| 264 | monoGroup(pushButton_0_5, label_dec_ie2); |
| 265 | monoGroup(pushButton_0_6, label_dec_dg); |
| 266 | |
| 267 | if (vdpId == VDP_V9938) { |
| 268 | groupBox_V9958->setVisible(false); |
| 269 | groupBox_dec_V9958->setVisible(false); |
| 270 | label_dec_ie2->setVisible(true); |
| 271 | pushButton_0_5->setText("IE2"); |
| 272 | pushButton_0_5->setToolTip("Enables interrupt from light pen by Interrupt Enable 2."); |
| 273 | pushButton_8_6->setText("LP"); |
| 274 | pushButton_8_6->setToolTip("When 1, enables light pen. When 0, disables light pen."); |
| 275 | pushButton_8_7->setText("MS"); |
| 276 | pushButton_8_7->setToolTip("When 1, sets the color bus to input mode and enables mouse. When 0, sets the color bus to output mode and disables mouse."); |
| 277 | } else { |
| 278 | groupBox_V9958->setVisible(true); |
| 279 | groupBox_dec_V9958->setVisible(true); |
| 280 | label_dec_ie2->setVisible(false); |
| 281 | pushButton_0_5->setText("0"); |
| 282 | pushButton_0_5->setToolTip(""); |
| 283 | pushButton_8_7->setText("0"); |
| 284 | pushButton_8_7->setToolTip(""); |
| 285 | pushButton_8_6->setText("0"); |
| 286 | pushButton_8_6->setToolTip(""); |
| 287 | /* Since mouse/lightpen are disabled this will affect |
| 288 | * status reg1 bit 7 (LPS) and |
| 289 | * status reg1 bit 6 (FL) |
| 290 | */ |
| 291 | } |
| 292 | //break; |
| 293 | } |
| 294 | //} |
| 295 | } |
| 296 | |
| 297 | static QString dec2(int val) |
| 298 | { |
| 299 | return QString("%1").arg(val, 2, 10, QChar('0')); |
| 300 | } |
| 301 | static QString dec3(int val) |
| 302 | { |
| 303 | return QString("%1").arg(val, 3, 10, QChar('0')); |
| 304 | } |
| 305 | static QString hex2(int val) |
| 306 | { |
| 307 | return QString("%1").arg(val, 2, 16, QChar('0')).toUpper(); |
| 308 | } |
| 309 | static QString hex5(int val) |
| 310 | { |
| 311 | return QString("%1").arg(val, 5, 16, QChar('0')).toUpper(); |
| 312 | } |
| 313 | void VDPRegViewer::decodeVDPRegs() |
| 314 | { |
| 315 | // first update all hex values |
| 316 | label_val_0->setText(hex2(regs[0])); |
| 317 | label_val_1->setText(hex2(regs[1])); |
| 318 | label_val_2->setText(hex2(regs[2])); |
| 319 | label_val_3->setText(hex2(regs[3])); |
| 320 | label_val_4->setText(hex2(regs[4])); |
| 321 | label_val_5->setText(hex2(regs[5])); |
| 322 | label_val_6->setText(hex2(regs[6])); |
| 323 | label_val_7->setText(hex2(regs[7])); |
| 324 | |
| 325 | // Only on V9938 and V9958 this makes sence |
| 326 | if (vdpId != VDP_TMS99X8) { |
| 327 | label_val_8 ->setText(hex2(regs[ 8])); |
| 328 | label_val_9 ->setText(hex2(regs[ 9])); |
| 329 | label_val_10->setText(hex2(regs[10])); |
| 330 | label_val_11->setText(hex2(regs[11])); |
| 331 | label_val_12->setText(hex2(regs[12])); |
| 332 | label_val_13->setText(hex2(regs[13])); |
| 333 | label_val_14->setText(hex2(regs[14])); |
| 334 | label_val_15->setText(hex2(regs[15])); |
| 335 | label_val_16->setText(hex2(regs[16])); |
| 336 | label_val_17->setText(hex2(regs[17])); |
| 337 | label_val_18->setText(hex2(regs[18])); |
| 338 | label_val_19->setText(hex2(regs[19])); |
| 339 | label_val_20->setText(hex2(regs[20])); |
| 340 | label_val_21->setText(hex2(regs[21])); |
| 341 | label_val_22->setText(hex2(regs[22])); |
| 342 | label_val_23->setText(hex2(regs[23])); |
| 343 | } |
| 344 | // Only on V9958 this makes sence |
| 345 | if (vdpId == VDP_V9958) { |
| 346 | label_val_25->setText(hex2(regs[25])); |
| 347 | label_val_26->setText(hex2(regs[26])); |
| 348 | label_val_27->setText(hex2(regs[27])); |
| 349 | } |
| 350 | |
| 351 | // determine screenmode |
| 352 | int m = ((regs[0] & 0x0E) << 1) | ((regs[1] & 0x18) >> 3); |
| 353 | const char* const screen[32] = { |
| 354 | "SCREEN 1", "SCREEN 3", "SCREEN 0", |
| 355 | "let's find out 3", "SCREEN 2", "let's find out 5", |
| 356 | "let's find out 6", "let's find out 7", "SCREEN 4", |
| 357 | "let's find out 9", "SCREEN 0 width 80", "let's find out 11", |
| 358 | "SCREEN 5", "let's find out 13", "let's find out 14", |
| 359 | "let's find out 15", "SCREEN 6", "let's find out 17", |
| 360 | "let's find out 18", "let's find out 19", "SCREEN 7", |
| 361 | "let's find out 21", "let's find out 22", "let's find out 23", |
| 362 | "let's find out 24", "let's find out 25", "let's find out 26", |
| 363 | "let's find out 27", "SCREEN 8", "let's find out 29", |
| 364 | "let's find out 30", "let's find out 31" |
| 365 | }; |
| 366 | int basicscreen; |
| 367 | switch (m) { |
| 368 | case 2: basicscreen=0;break; |
| 369 | case 0: basicscreen=1;break; |
| 370 | case 4: basicscreen=2;break; |
| 371 | case 1: basicscreen=3;break; |
| 372 | case 8: basicscreen=4;break; |
| 373 | case 12: basicscreen=5;break; |
| 374 | case 16: basicscreen=6;break; |
| 375 | case 20: basicscreen=7;break; |
| 376 | case 28: basicscreen=8;break; |
| 377 | case 10: basicscreen=9;break; //screen 0 width 80 |
| 378 | default: basicscreen=10; //not a valid basic screen mode |
| 379 | }; |
| 380 | |
| 381 | // 2 vdps, 11 basic screenmodes, 12 registers |
| 382 | static const int mustbeone[][11][12] = { |
| 383 | { // TMS99x8 MSX1 VDP chip |
| 384 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 0; |
| 385 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 1; |
| 386 | {0, 0, 0x00, 0x7f, 0x03, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 2; |
| 387 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 3; |
| 388 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 4; |
| 389 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 5; |
| 390 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 6; |
| 391 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 7; |
| 392 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 8; |
| 393 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 0 width 80; |
| 394 | {0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0} // undefined basic screen; |
| 395 | }, |
| 396 | { // V9938 and V9958 MSX2/2+ VDP chip |
| 397 | // Note that there is a hardcoded check for reg5 bit 2 (A9) in spritemode 2 |
| 398 | // which deliberatly isn't set here in the table! |
| 399 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 0; |
| 400 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 1; |
| 401 | {0, 0, 0x00, 0x7f, 0x03, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 2; |
| 402 | {0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 3; |
| 403 | {0, 0, 0x00, 0x7f, 0x03, 0x03, 0x00, 0x00, 0,0,0,0}, // screen 4; |
| 404 | {0, 0, 0x1f, 0x00, 0x00, 0x03, 0x00, 0x00, 0,0,0,0}, // screen 5; |
| 405 | {0, 0, 0x1f, 0x00, 0x00, 0x03, 0x00, 0x00, 0,0,0,0}, // screen 6; |
| 406 | {0, 0, 0x1f, 0x00, 0x00, 0x03, 0x00, 0x00, 0,0,0,0}, // screen 7; |
| 407 | {0, 0, 0x1f, 0x00, 0x00, 0x03, 0x00, 0x00, 0,0,0,0}, // screen 8; |
| 408 | {0, 0, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0,0,0,0}, // screen 0 width 80; |
| 409 | {0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0} // undefined basic screen; |
| 410 | } |
| 411 | |
| 412 | }; |
| 413 | static const int bitsused[][11][12] = { |
| 414 | {// MSX1 = static const int VDP_TMS99X8 = 1 |
| 415 | {0,1, 0x0f, 0xff, 0x07, 0x7f, 0x07, 7,8,9, 0x00, 0x00}, // screen 0; |
| 416 | {0,1, 0x0f, 0xff, 0x07, 0x7f, 0x07, 7,8,9, 0x00, 0x00}, // screen 1; |
| 417 | {0,1, 0x0f, 0xff, 0x07, 0x7f, 0x07, 7,8,9, 0x00, 0x00}, // screen 2; |
| 418 | {0,1, 0x0f, 0xff, 0x07, 0x7f, 0x07, 7,8,9, 0x00, 0x00}, // screen 3; |
| 419 | {0,1, 0x00, 0x00, 0x00, 0x00, 0x00, 7,8,9, 0x00, 0x00}, // screen 4; |
| 420 | {0,1, 0x00, 0x00, 0x00, 0x00, 0x00, 7,8,9, 0x00, 0x00}, // screen 5; |
| 421 | {0,1, 0x00, 0x00, 0x00, 0x00, 0x00, 7,8,9, 0x00, 0x00}, // screen 6; |
| 422 | {0,1, 0x00, 0x00, 0x00, 0x00, 0x00, 7,8,9, 0x00, 0x00}, // screen 7; |
| 423 | {0,1, 0x00, 0x00, 0x00, 0x00, 0x00, 7,8,9, 0x00, 0x00}, // screen 8; |
| 424 | {0,1, 0x00, 0x00, 0x00, 0x00, 0x00, 7,8,9, 0x00, 0x00}, // screen 0 width 80; |
| 425 | {255,255,255,255,255,255,255,255,255,255,255,255} // undefined basic screen; |
| 426 | }, |
| 427 | { // MSX2 = static const int VDP_V9938 = 0; |
| 428 | {0,1, 0x7f, 0xff, 0x3f, 0xff, 0x3f, 7,8,9, 0x07, 0x03}, // screen 0; |
| 429 | {0,1, 0x7f, 0xff, 0x3f, 0xff, 0x3f, 7,8,9, 0x07, 0x03}, // screen 1; |
| 430 | {0,1, 0x7f, 0xff, 0x3f, 0xff, 0x3f, 7,8,9, 0x07, 0x03}, // screen 2; |
| 431 | {0,1, 0x7f, 0xff, 0x3f, 0xff, 0x3f, 7,8,9, 0x07, 0x03}, // screen 3; |
| 432 | {0,1, 0x7f, 0xff, 0x3f, 0xfc, 0x3f, 7,8,9, 0x07, 0x03}, // screen 4; |
| 433 | {0,1, 0x7f, 0xff, 0x3f, 0xfc, 0x3f, 7,8,9, 0x07, 0x03}, // screen 5; |
| 434 | {0,1, 0x7f, 0xff, 0x3f, 0xfc, 0x3f, 7,8,9, 0x07, 0x03}, // screen 6; |
| 435 | {0,1, 0x7f, 0xff, 0x3f, 0xfc, 0x3f, 7,8,9, 0x07, 0x03}, // screen 7; |
| 436 | {0,1, 0x7f, 0xff, 0x3f, 0xfc, 0x3f, 7,8,9, 0x07, 0x03}, // screen 8; |
| 437 | {0,1, 0x7f, 0xff, 0x3f, 0xff, 0x3f, 7,8,9, 0x07, 0x03}, // screen 0 width 80; |
| 438 | {255,255,255,255,255,255,255,255,255,255,255,255} // undefined basic screen; |
| 439 | } |
| 440 | }; |
| 441 | |
| 442 | // update all the individual bits |
| 443 | int upper_r = (vdpId == VDP_TMS99X8) ? 7 : (vdpId == VDP_V9938) ? 23 : 27; |
| 444 | for (int r = 0; r <= upper_r; ++r) { |
| 445 | if (r == 24) continue; |
| 446 | for (int b = 7; b >= 0; --b) { |
| 447 | QString name = QString("pushButton_%1_%2").arg(r).arg(b); |
| 448 | auto* i = findChild<InteractiveButton*>(name); |
| 449 | i->setChecked(regs[r] & (1 << b)); |
| 450 | if (r < 12) { |
| 451 | i->mustBeSet(mustbeone[(vdpId == VDP_TMS99X8) ? 0 : 1][basicscreen][r] & (1 << b)); |
| 452 | // if A8 of R5 is a 'must-be-one' then we indicate this for A9 also |
| 453 | // This bit is cleared in the table since it isn't used in the Sprite |
| 454 | // Attribute Table address calculation otherwise, but will only impact the |
| 455 | // Sprite Color Table |
| 456 | if (r == 5 && b == 2 && vdpId != VDP_TMS99X8 && mustbeone[1][basicscreen][5]) { |
| 457 | i->mustBeSet(true); |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | // Start the interpretation |
| 464 | label_dec_ie2->setText((regs[0] & 32) |
| 465 | ? "Interrupt from lightpen enabled" |
| 466 | : "Interrupt from lightpen disabled"); |
| 467 | label_dec_ie1->setText((regs[0] & 16) |
| 468 | ? "Reg 19 scanline interrupt enabled" |
| 469 | : "Reg 19 scanline interrupt disabled"); |
| 470 | |
| 471 | if (vdpId != VDP_TMS99X8) { |
| 472 | if (m == 20 || m == 28) { |
| 473 | pushButton_2_6->setText("0"); |
| 474 | pushButton_2_5->setText("A16"); |
| 475 | pushButton_2_4->setText("A15"); |
| 476 | pushButton_2_3->setText("A14"); |
| 477 | pushButton_2_2->setText("A13"); |
| 478 | pushButton_2_1->setText("A12"); |
| 479 | pushButton_2_0->setText("A11"); |
| 480 | } else { |
| 481 | pushButton_2_6->setText("A16"); |
| 482 | pushButton_2_5->setText("A15"); |
| 483 | pushButton_2_4->setText("A14"); |
| 484 | pushButton_2_3->setText("A13"); |
| 485 | pushButton_2_2->setText("A12"); |
| 486 | pushButton_2_1->setText("A11"); |
| 487 | pushButton_2_0->setText("A10"); |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | if (m == 28 && vdpId == VDP_V9958) { |
| 492 | bool yjk = (regs[25] & 8); |
| 493 | bool yae = (regs[25] & 16); |
| 494 | int scr = yjk ? (yae ? 10 : 12) : 8; |
| 495 | label_dec_m->setText(QString("M=%1%2%3 : SCREEN %4") |
| 496 | .arg(m) |
| 497 | .arg(yjk ? "+YJK" : "") |
| 498 | .arg(yae ? "+YAE" : "") |
| 499 | .arg(scr)); |
| 500 | } else { |
| 501 | label_dec_m->setText(QString("M=%1 : %2") |
| 502 | .arg(m) |
| 503 | .arg(screen[m])); |
| 504 | } |
| 505 | |
| 506 | label_dec_bl->setText((regs[1] & 64) |
| 507 | ? "Display enabled" |
| 508 | : "Display disabled"); |
| 509 | label_dec_ie0->setText((regs[1] & 32) |
| 510 | ? "V-Blank interrupt enabled" |
| 511 | : "V-Blank interrupt disabled"); |
| 512 | |
| 513 | label_dec_si->setText((regs[1] & 2) |
| 514 | ? "16x16 sprites" |
| 515 | : "8x8 sprites"); |
| 516 | label_dec_mag->setText((regs[1] & 1) |
| 517 | ? "magnified sprites" |
| 518 | : "regular sized"); |
| 519 | |
| 520 | |
| 521 | |
| 522 | // Now calculate the addresses of all tables |
| 523 | // TODO : clean up code and get rid of all the mustbeset bits for regs>5 since there are never must bits. |
| 524 | |
| 525 | |
| 526 | // some variables used for readability of the code below |
| 527 | int row = vdpId == VDP_TMS99X8 ? 0 : 1; |
| 528 | QString regtexttext; |
| 529 | int must,must2; |
| 530 | |
| 531 | // the pattern name table address |
| 532 | must=mustbeone[row][basicscreen][2] ; |
| 533 | long nameTable = ((255^must) & bitsused[row][basicscreen][2] & regs[2]) << 10; |
| 534 | if ((m == 20 || m == 28) && vdpId != VDP_TMS99X8) |
| 535 | nameTable = ((nameTable & 0xffff) << 1) | ((nameTable & 0x10000) >> 16); |
| 536 | regtexttext = hex5(nameTable); |
| 537 | |
| 538 | if ((must & regs[2]) != must) { |
| 539 | label_dec_r2->setText("<font color=red>" + regtexttext +"</font>"); |
| 540 | label_dec_r2->setToolTip("Some of the obligatory 1 bits are reset!"); |
| 541 | } else { |
| 542 | label_dec_r2->setText(regtexttext); |
| 543 | label_dec_r2->setToolTip(nullptr); |
| 544 | } |
| 545 | |
| 546 | // the color table address |
| 547 | must=mustbeone[row][basicscreen][3] ; |
| 548 | must2=mustbeone[row][basicscreen][10] ; |
| 549 | regtexttext=hex5( |
| 550 | ( |
| 551 | ((255 ^ must ) & bitsused[row][basicscreen][ 3] & regs[ 3]) << 6 |
| 552 | ) | ( |
| 553 | ((255 ^ must2) & bitsused[row][basicscreen][10] & regs[10]) << 14 |
| 554 | ) |
| 555 | ); |
| 556 | if (((must & regs[3]) != must) || ((must2 & regs[10]) != must2)) { |
| 557 | label_dec_r3->setText("<font color=red>" + regtexttext +"</font>"); |
| 558 | label_dec_r3->setToolTip("Some of the obligatory 1 bits are reset!"); |
| 559 | } else { |
| 560 | label_dec_r3->setText(regtexttext); |
| 561 | label_dec_r3->setToolTip(nullptr); |
| 562 | } |
| 563 | |
| 564 | // the pattern generator address |
| 565 | must=mustbeone[row][basicscreen][4] ; |
| 566 | regtexttext=hex5( |
| 567 | ( |
| 568 | (255 ^ must) & bitsused[row][basicscreen][4] & regs[4]) << 11 |
| 569 | ); |
| 570 | if ((must & regs[4]) != must) { |
| 571 | label_dec_r4->setText("<font color=red>" + regtexttext +"</font>"); |
| 572 | label_dec_r4->setToolTip("Some of the obligatory 1 bits are reset!"); |
| 573 | } else { |
| 574 | label_dec_r4->setText(regtexttext); |
| 575 | label_dec_r4->setToolTip(nullptr); |
| 576 | } |
| 577 | |
| 578 | // the sprite attribute tabel address |
| 579 | must = mustbeone[row][basicscreen][ 5]; |
| 580 | must2 = mustbeone[row][basicscreen][11]; |
| 581 | regtexttext = hex5( |
| 582 | ( |
| 583 | (((255^must) & bitsused[row][basicscreen][ 5] & regs[ 5]) << 7) | |
| 584 | (((255^must2) & bitsused[row][basicscreen][11] & regs[11]) << 15)) |
| 585 | ); |
| 586 | if (((must & regs[5]) != must) || ((must2 & regs[11]) != must2)) { |
| 587 | label_dec_r5->setText("<font color=red>" + regtexttext +"</font>"); |
| 588 | label_dec_r5->setToolTip("Some of the obligatory 1 bits are reset!"); |
| 589 | } else { |
| 590 | label_dec_r5->setText(regtexttext); |
| 591 | label_dec_r5->setToolTip(nullptr); |
| 592 | }; |
| 593 | // special case for sprite mode 2 |
| 594 | if (must && !(4 & regs[ 5])) { // only in mode2 there are some 'must'-bits :-) |
| 595 | label_dec_r5->setText("<font color=red>" + regtexttext +"</font>"); |
| 596 | label_dec_r5->setToolTip("Bit A9 should be set, to obtain the Sprite Color Table address this bit is masked<br>With the current bit reset the Color Tabel will use the same address as the Sprite Attribute Table!"); |
| 597 | }; |
| 598 | |
| 599 | |
| 600 | // the sprite pattern generator address |
| 601 | label_dec_r6->setText(hex5( |
| 602 | ((255^mustbeone[row][basicscreen][6]) & bitsused[row][basicscreen][6] & regs[6]) << 11)); |
| 603 | |
| 604 | // end of address calculations |
| 605 | |
| 606 | label_dec_tc->setText(dec2((regs[7] >> 4) & 15)); |
| 607 | label_dec_bd->setText(dec2((regs[7] >> 0) & 15)); |
| 608 | |
| 609 | if (vdpId != VDP_TMS99X8) { |
| 610 | label_dec_dg->setText((regs[0] & 64) |
| 611 | ? "Color bus set for input" |
| 612 | : "Color bus set for output"); |
| 613 | label_dec_tp->setText((regs[8] & 32) |
| 614 | ? "Color 0 uses the color registers" |
| 615 | : "Color 0 is transparent (=shows border)"); |
| 616 | label_dec_spd->setText((regs[8] & 2) |
| 617 | ? "Sprites disabled" |
| 618 | : "Sprites enabled"); |
| 619 | |
| 620 | label_dec_ln->setText((regs[9] & 128) ? "212" : "192"); |
| 621 | label_dec_il->setText((regs[9] & 8) ? "interlaced" : "non-interlaced"); |
| 622 | label_dec_eo->setText((regs[9] & 4) ? "alternate pages" : "same page"); |
| 623 | label_dec_nt->setText((regs[9] & 2) ? "PAL" : "NTSC"); |
| 624 | |
| 625 | label_dec_t2 ->setText(dec2((regs[12] >> 4) & 15)); |
| 626 | label_dec_bc ->setText(dec2((regs[12] >> 0) & 15)); |
| 627 | label_dec_on ->setText(dec2((regs[13] >> 4) & 15)); |
| 628 | label_dec_off->setText(dec2((regs[13] >> 0) & 15)); |
| 629 | |
| 630 | int x = ((regs[18] >> 0) & 15); |
| 631 | int y = ((regs[18] >> 4) & 15); |
| 632 | x = x > 7 ? 16 - x : -x; |
| 633 | y = y > 7 ? 16 - y : -y; |
| 634 | label_dec_r18->setText(QString("(%1,%2)").arg(x).arg(y)); |
| 635 | |
| 636 | label_dec_r19->setText(dec3(regs[19])); |
| 637 | label_dec_r23->setText(dec3(regs[23])); |
| 638 | |
| 639 | auto& dataStore = VDPDataStore::instance(); |
| 640 | label_dec_r14->setText(hex5(((regs[14] & 7) << 14) | ((regs[81] & 63) << 8) | regs[80]) |
| 641 | .append(dataStore.getVramAccessStatusAvailable() ? (regs[85] ? ", write" : ", read") : "")); |
| 642 | |
| 643 | label_dec_r15->setText(dec2(regs[15] & 15)); |
| 644 | label_dec_r16->setText(dec2(regs[16] & 15)); |
| 645 | label_dec_r17->setText(dec3(regs[17] & 63).append((regs[17] & 128) ? "" : ", auto incr")); |
| 646 | |
| 647 | label_dec_latch->setText(dataStore.getRegisterLatchAvailable() ? |
| 648 | QString("%1/%2") |
| 649 | .arg(hex2(regs[84])) |
| 650 | .arg(regs[82] ? "register" : "value") : "---/---"); |
| 651 | } |
| 652 | |
| 653 | //V9958 registers |
| 654 | if (vdpId == VDP_V9958) { |
| 655 | label_dec_r26->setText(QString("horizontal scroll %1") |
| 656 | .arg((regs[26] & 63) * 8 - (7 & regs[27]))); |
| 657 | label_dec_sp2->setText((regs[25] & 1) |
| 658 | ? "Scroll uses 2 pages" |
| 659 | : "Scroll same page"); |
| 660 | label_dec_msk->setText((regs[25] & 2) |
| 661 | ? "Hide 8 leftmost pixels" |
| 662 | : "No masking"); |
| 663 | label_dec_wte->setText((regs[25] & 4) |
| 664 | ? "CPU Waitstate enabled" |
| 665 | : "CPU Waitstate disabled"); |
| 666 | if (regs[25] & 8) { |
| 667 | label_dec_yjk->setText("YJK System"); |
| 668 | label_dec_yae->setText((regs[25] & 16) |
| 669 | ? "Attribute enabled (Y=4bits)" |
| 670 | : "regular YJK (Y=5bits)"); |
| 671 | } else { |
| 672 | label_dec_yjk->setText("Normal RGB"); |
| 673 | label_dec_yae->setText("Ignored (YJK disabled)"); |
| 674 | } |
| 675 | label_dec_vds->setText((regs[25] & 32) |
| 676 | ? "Pin8 is /VDS" |
| 677 | : "Pin8 is CPUCLK"); |
| 678 | label_dec_cmd->setText((regs[25] & 64) |
| 679 | ? "CMD engine in char modes" |
| 680 | : "V9938 VDP CMD engine"); |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | void VDPRegViewer::doConnect(InteractiveButton* but, buttonHighlightDispatcher* dis) |
| 685 | { |
| 686 | connect(but, &InteractiveButton::mouseOver, |
| 687 | dis, &buttonHighlightDispatcher::receiveState); |
| 688 | connect(dis, &buttonHighlightDispatcher::stateDispatched, |
| 689 | but, &InteractiveButton::highlight); |
| 690 | } |
| 691 | |
| 692 | void VDPRegViewer::monoGroup(InteractiveButton* but, InteractiveLabel* lab) |
| 693 | { |
| 694 | connect(lab, &InteractiveLabel ::mouseOver, but, &InteractiveButton::highlight); |
| 695 | connect(but, &InteractiveButton::mouseOver, lab, &InteractiveLabel ::highlight); |
| 696 | connect(lab, &InteractiveLabel ::mouseOver, lab, &InteractiveLabel ::highlight); |
| 697 | connect(but, &InteractiveButton::mouseOver, but, &InteractiveButton::highlight); |
| 698 | } |
| 699 | |
| 700 | void VDPRegViewer::reGroup(InteractiveButton* item, buttonHighlightDispatcher* dispat) |
| 701 | { |
| 702 | //button must re-highlight itself |
| 703 | connect(item, &InteractiveButton::mouseOver, item, &InteractiveButton::highlight); |
| 704 | // and then talk to dispatcher |
| 705 | doConnect(item, dispat); |
| 706 | } |
| 707 | |
| 708 | buttonHighlightDispatcher* VDPRegViewer::makeGroup( |
| 709 | const QList<InteractiveButton*>& list, InteractiveLabel* explained) |
| 710 | { |
| 711 | // First "steal" the Tooltip of the explained widget. |
| 712 | //for (auto* item : list) { |
| 713 | // item->setToolTip(explained->toolTip()); |
| 714 | //} |
| 715 | |
| 716 | // Create a dispatcher and connect all to them |
| 717 | auto* dispat = new buttonHighlightDispatcher(); |
| 718 | connect(explained, &InteractiveLabel::mouseOver, |
| 719 | dispat, &buttonHighlightDispatcher::receiveState); |
| 720 | connect(dispat, &buttonHighlightDispatcher::stateDispatched, |
| 721 | explained, &InteractiveLabel::highlight); |
| 722 | for (auto* item : list) { |
| 723 | doConnect(item, dispat); |
| 724 | } |
| 725 | return dispat; |
| 726 | } |
| 727 | |
| 728 | void VDPRegViewer::connectHighLights() |
| 729 | { |
| 730 | // Before connecting the highlights we connect the special |
| 731 | // 'Toggled Bit' event |
| 732 | // Warning: This function is not available with MSVC 6!! Not that it |
| 733 | // matters to me on my Linux environment :-) |
| 734 | QList<InteractiveButton*> list = findChildren<InteractiveButton*>(); |
| 735 | for (auto* item : list) { |
| 736 | connect(item, &InteractiveButton::newBitValue, |
| 737 | this, &VDPRegViewer::registerBitChanged); |
| 738 | } |
| 739 | |
| 740 | // register 0 (+M1,M2) |
| 741 | monoGroup(pushButton_0_5, label_dec_ie2); |
| 742 | monoGroup(pushButton_0_4, label_dec_ie1); |
| 743 | |
| 744 | list.clear(); |
| 745 | list << pushButton_0_3 << pushButton_0_2 << pushButton_0_1; |
| 746 | list << pushButton_1_4 << pushButton_1_3; |
| 747 | modeBitsDispat = makeGroup(list, label_dec_m); |
| 748 | |
| 749 | // register 1 |
| 750 | monoGroup(pushButton_1_6, label_dec_bl); |
| 751 | monoGroup(pushButton_1_5, label_dec_ie0); |
| 752 | monoGroup(pushButton_1_1, label_dec_si); |
| 753 | monoGroup(pushButton_1_0, label_dec_mag); |
| 754 | |
| 755 | // register 8 |
| 756 | //monoGroup(pushButton_8_7, label_dec_ms); |
| 757 | //monoGroup(pushButton_8_6, label_dec_lp); |
| 758 | monoGroup(pushButton_8_5, label_dec_tp); |
| 759 | //monoGroup(pushButton_8_4, label_dec_cb); |
| 760 | //monoGroup(pushButton_8_3, label_dec_vr); |
| 761 | monoGroup(pushButton_8_1, label_dec_spd); |
| 762 | //monoGroup(pushButton_8_0, label_dec_bw); |
| 763 | |
| 764 | // register 9 |
| 765 | monoGroup(pushButton_9_7, label_dec_ln); |
| 766 | list.clear(); |
| 767 | list << pushButton_9_5 << pushButton_9_4; |
| 768 | makeGroup(list, label_dec_m); //TODO fix label |
| 769 | monoGroup(pushButton_9_3, label_dec_il); |
| 770 | monoGroup(pushButton_9_2, label_dec_eo); |
| 771 | monoGroup(pushButton_9_1, label_dec_nt); |
| 772 | //monoGroup(pushButton_9_0, label_dec_dc); |
| 773 | |
| 774 | // register 2 |
| 775 | list.clear(); |
| 776 | list << pushButton_2_7 << pushButton_2_6 << pushButton_2_5; |
| 777 | list << pushButton_2_4 << pushButton_2_3 << pushButton_2_2; |
| 778 | list << pushButton_2_1 << pushButton_2_0; |
| 779 | makeGroup(list, label_dec_r2); |
| 780 | |
| 781 | // register 3 + 10 |
| 782 | list.clear(); |
| 783 | list << pushButton_3_7 << pushButton_3_6 << pushButton_3_5; |
| 784 | list << pushButton_3_4 << pushButton_3_3 << pushButton_3_2; |
| 785 | list << pushButton_3_1 << pushButton_3_0; |
| 786 | list << pushButton_10_7 << pushButton_10_6 << pushButton_10_5; |
| 787 | list << pushButton_10_4 << pushButton_10_3 << pushButton_10_2; |
| 788 | list << pushButton_10_1 << pushButton_10_0; |
| 789 | makeGroup(list, label_dec_r3); |
| 790 | |
| 791 | // register 4 |
| 792 | list.clear(); |
| 793 | list << pushButton_4_7 << pushButton_4_6 << pushButton_4_5; |
| 794 | list << pushButton_4_4 << pushButton_4_3 << pushButton_4_2; |
| 795 | list << pushButton_4_1 << pushButton_4_0; |
| 796 | makeGroup(list, label_dec_r4); |
| 797 | |
| 798 | // register 5 + 11 |
| 799 | list.clear(); |
| 800 | list << pushButton_5_7 << pushButton_5_6 << pushButton_5_5; |
| 801 | list << pushButton_5_4 << pushButton_5_3 << pushButton_5_2; |
| 802 | list << pushButton_5_1 << pushButton_5_0; |
| 803 | list << pushButton_11_7 << pushButton_11_6 << pushButton_11_5; |
| 804 | list << pushButton_11_4 << pushButton_11_3 << pushButton_11_2; |
| 805 | list << pushButton_11_1 << pushButton_11_0; |
| 806 | makeGroup(list, label_dec_r5); |
| 807 | |
| 808 | // register 6 |
| 809 | list.clear(); |
| 810 | list << pushButton_6_7 << pushButton_6_6 << pushButton_6_5; |
| 811 | list << pushButton_6_4 << pushButton_6_3 << pushButton_6_2; |
| 812 | list << pushButton_6_1 << pushButton_6_0; |
| 813 | makeGroup(list, label_dec_r6); |
| 814 | |
| 815 | // register 7 |
| 816 | list.clear(); |
| 817 | list << pushButton_7_7 << pushButton_7_6; |
| 818 | list << pushButton_7_5 << pushButton_7_4; |
| 819 | makeGroup(list, label_dec_tc); |
| 820 | |
| 821 | list.clear(); |
| 822 | list << pushButton_7_3 << pushButton_7_2; |
| 823 | list << pushButton_7_1 << pushButton_7_0; |
| 824 | makeGroup(list, label_dec_bd); |
| 825 | |
| 826 | // register 12 |
| 827 | list.clear(); |
| 828 | list << pushButton_12_7 << pushButton_12_6; |
| 829 | list << pushButton_12_5 << pushButton_12_4; |
| 830 | makeGroup(list, label_dec_t2); |
| 831 | |
| 832 | list.clear(); |
| 833 | list << pushButton_12_3 << pushButton_12_2; |
| 834 | list << pushButton_12_1 << pushButton_12_0; |
| 835 | makeGroup(list, label_dec_bc); |
| 836 | |
| 837 | // register 13 |
| 838 | list.clear(); |
| 839 | list << pushButton_13_7 << pushButton_13_6; |
| 840 | list << pushButton_13_5 << pushButton_13_4; |
| 841 | makeGroup(list, label_dec_on); |
| 842 | |
| 843 | list.clear(); |
| 844 | list << pushButton_13_3 << pushButton_13_2; |
| 845 | list << pushButton_13_1 << pushButton_13_0; |
| 846 | makeGroup(list, label_dec_off); |
| 847 | |
| 848 | // register 14 |
| 849 | list.clear(); |
| 850 | list << pushButton_14_7 << pushButton_14_6 << pushButton_14_5; |
| 851 | list << pushButton_14_4 << pushButton_14_3 << pushButton_14_2; |
| 852 | list << pushButton_14_1 << pushButton_14_0; |
| 853 | makeGroup(list, label_dec_r14); |
| 854 | |
| 855 | // register 15 |
| 856 | list.clear(); |
| 857 | list << pushButton_15_7 << pushButton_15_6 << pushButton_15_5; |
| 858 | list << pushButton_15_4 << pushButton_15_3 << pushButton_15_2; |
| 859 | list << pushButton_15_1 << pushButton_15_0; |
| 860 | makeGroup(list, label_dec_r15); |
| 861 | |
| 862 | // register 16 |
| 863 | list.clear(); |
| 864 | list << pushButton_16_7 << pushButton_16_6 << pushButton_16_5; |
| 865 | list << pushButton_16_4 << pushButton_16_3 << pushButton_16_2; |
| 866 | list << pushButton_16_1 << pushButton_16_0; |
| 867 | makeGroup(list, label_dec_r16); |
| 868 | |
| 869 | // register 17 |
| 870 | list.clear(); |
| 871 | list << pushButton_17_7 << pushButton_17_6 << pushButton_17_5; |
| 872 | list << pushButton_17_4 << pushButton_17_3 << pushButton_17_2; |
| 873 | list << pushButton_17_1 << pushButton_17_0; |
| 874 | makeGroup(list, label_dec_r17); |
| 875 | |
| 876 | // register 18 |
| 877 | list.clear(); |
| 878 | list << pushButton_18_7 << pushButton_18_6 << pushButton_18_5; |
| 879 | list << pushButton_18_4 << pushButton_18_3 << pushButton_18_2; |
| 880 | list << pushButton_18_1 << pushButton_18_0; |
| 881 | makeGroup(list, label_dec_r18); |
| 882 | |
| 883 | // register 19 |
| 884 | list.clear(); |
| 885 | list << pushButton_19_7 << pushButton_19_6 << pushButton_19_5; |
| 886 | list << pushButton_19_4 << pushButton_19_3 << pushButton_19_2; |
| 887 | list << pushButton_19_1 << pushButton_19_0; |
| 888 | makeGroup(list, label_dec_r19); |
| 889 | |
| 890 | // register 23 |
| 891 | list.clear(); |
| 892 | list << pushButton_23_7 << pushButton_23_6 << pushButton_23_5; |
| 893 | list << pushButton_23_4 << pushButton_23_3 << pushButton_23_2; |
| 894 | list << pushButton_23_1 << pushButton_23_0; |
| 895 | makeGroup(list, label_dec_r23); |
| 896 | |
| 897 | // register 25 |
| 898 | monoGroup(pushButton_25_0, label_dec_sp2); |
| 899 | monoGroup(pushButton_25_1, label_dec_msk); |
| 900 | monoGroup(pushButton_25_2, label_dec_wte); |
| 901 | monoGroup(pushButton_25_3, label_dec_yjk); |
| 902 | monoGroup(pushButton_25_4, label_dec_yae); |
| 903 | monoGroup(pushButton_25_5, label_dec_vds); |
| 904 | monoGroup(pushButton_25_6, label_dec_cmd); |
| 905 | |
| 906 | // register 26 |
| 907 | list.clear(); |
| 908 | list << pushButton_26_7 << pushButton_26_6 << pushButton_26_5; |
| 909 | list << pushButton_26_4 << pushButton_26_3 << pushButton_26_2; |
| 910 | list << pushButton_26_1 << pushButton_26_0; |
| 911 | list << pushButton_27_7 << pushButton_27_6 << pushButton_27_5; |
| 912 | list << pushButton_27_4 << pushButton_27_3 << pushButton_27_2; |
| 913 | list << pushButton_27_1 << pushButton_27_0; |
| 914 | makeGroup(list, label_dec_r26); |
| 915 | } |
| 916 | |
| 917 | void VDPRegViewer::refresh() |
| 918 | { |
| 919 | auto& dataStore = VDPDataStore::instance(); |
| 920 | bool registerLatchAvailable = dataStore.getRegisterLatchAvailable(); |
| 921 | bool paletteLatchAvailable = dataStore.getPaletteLatchAvailable(); |
| 922 | bool dataLatchAvailable = dataStore.getDataLatchAvailable(); |
| 923 | bool vramAccessStatusAvailable = dataStore.getVramAccessStatusAvailable(); |
| 924 | |
| 925 | // three to six different requests now combined in a single one: |
| 926 | QString req = QString( |
| 927 | "debug_bin2hex " |
| 928 | "[ debug read_block {VDP regs} 0 64 ]" |
| 929 | "[ debug read_block {VDP status regs} 0 16 ]" |
| 930 | "[ debug read_block {VRAM pointer} 0 2 ]%1%2%3%4") |
| 931 | .arg(registerLatchAvailable ? "[debug read_block {VDP register latch status} 0 1]" : "") |
| 932 | .arg(paletteLatchAvailable ? "[debug read_block {VDP palette latch status} 0 1]" : "") |
| 933 | .arg(dataLatchAvailable ? "[debug read_block {VDP data latch value} 0 1]" : "") |
| 934 | .arg(vramAccessStatusAvailable ? "[debug read_block {VRAM access status} 0 1]" : ""); |
| 935 | |
| 936 | int total = sizeof(regs) - !registerLatchAvailable - !paletteLatchAvailable - !dataLatchAvailable |
| 937 | - !vramAccessStatusAvailable; |
| 938 | new SimpleHexRequest(req, total, regs, *this); |
| 939 | } |
| 940 | |
| 941 | void VDPRegViewer::DataHexRequestReceived() |
| 942 | { |
| 943 | decodeStatusVDPRegs(); |
| 944 | decodeVDPRegs(); |
| 945 | } |
| 946 | |
| 947 | void VDPRegViewer::registerBitChanged(int reg, int bit, bool state) |
| 948 | { |
| 949 | // maybe this call is the result of our own SetChecked (VDPDataStorte |
| 950 | // update event) |
| 951 | if ((state ? 1 : 0) == (regs[reg] & (1 << bit))) { |
| 952 | return; |
| 953 | } |
| 954 | |
| 955 | // state does not correspond to the current register setting so we send |
| 956 | // an update command |
| 957 | if (state) { |
| 958 | regs[reg] |= (1 << bit); |
| 959 | } else { |
| 960 | regs[reg] &= ~(1 << bit); |
| 961 | } |
| 962 | CommClient::instance().sendCommand( |
| 963 | new SimpleCommand( |
| 964 | QString("debug write {VDP regs} %1 %2").arg(reg).arg(regs[reg]))); |
| 965 | |
| 966 | // Update display without waiting for the VDPDataStore update |
| 967 | decodeVDPRegs(); |
| 968 | // and then we could request an update nevertheless since some other |
| 969 | // objects might want to see this change through the VDPDataStore also |
| 970 | // :-) |
| 971 | // VDPDataStore::instance().refresh(); |
| 972 | } |
| 973 | |
| 974 | void VDPRegViewer::on_VDPcomboBox_currentIndexChanged(int index) |
| 975 | { |
| 976 | switch (index) { |
| 977 | case 0: |
| 978 | vdpId = VDP_V9958; |
| 979 | break; |
| 980 | case 1: |
| 981 | vdpId = VDP_V9938; |
| 982 | break; |
| 983 | case 2: |
| 984 | vdpId = VDP_TMS99X8; |
| 985 | break; |
| 986 | } |
| 987 | decodeStatusVDPRegs(); |
| 988 | decodeVDPRegs(); |
| 989 | } |