| 1252 | } |
| 1253 | |
| 1254 | void MainWindow::portModified(QTableWidgetItem *item) { |
| 1255 | if (item == Q_NULLPTR) { |
| 1256 | return; |
| 1257 | } |
| 1258 | |
| 1259 | int row = item->row(); |
| 1260 | int col = item->column(); |
| 1261 | |
| 1262 | if (col == PORT_READ_COL || col == PORT_WRITE_COL || col == PORT_FREEZE_COL) { |
| 1263 | uint16_t port = static_cast<uint16_t>(hex2int(m_ports->item(row, PORT_ADDR_COL)->text())); |
| 1264 | unsigned int mask = DBG_MASK_NONE; |
| 1265 | |
| 1266 | if (col == PORT_READ_COL) { // Break on read |
| 1267 | mask = DBG_MASK_PORT_READ; |
| 1268 | } |
| 1269 | if (col == PORT_WRITE_COL) { // Break on write |
| 1270 | mask = DBG_MASK_PORT_WRITE; |
| 1271 | } |
| 1272 | if (col == PORT_FREEZE_COL) { // Freeze |
| 1273 | mask = DBG_MASK_PORT_FREEZE; |
| 1274 | } |
| 1275 | debug_ports(port, mask, static_cast<QAbstractButton *>(m_ports->cellWidget(row, col))->isChecked()); |
| 1276 | } else if (col == PORT_ADDR_COL) { |
| 1277 | std::string s = item->text().toUpper().toStdString(); |
| 1278 | int mask; |
| 1279 | |
| 1280 | if (isNotValidHex(s) || s.length() > 4) { |
| 1281 | item->setText(m_prevPortAddr); |
| 1282 | return; |
| 1283 | } |
| 1284 | |
| 1285 | uint16_t port = static_cast<uint16_t>(hex2int(QString::fromStdString(s))); |
| 1286 | uint8_t data = port_peek_byte(port); |
| 1287 | QString portStr = int2hex(port, 4); |
| 1288 | |
| 1289 | m_ports->blockSignals(true); |
| 1290 | |
| 1291 | // return if port is already set |
| 1292 | for (int i=0; i<m_ports->rowCount(); i++) { |
| 1293 | if (m_ports->item(i, PORT_ADDR_COL)->text() == portStr && i != row) { |
| 1294 | item->setText(m_prevPortAddr); |
| 1295 | m_ports->blockSignals(false); |
| 1296 | return; |
| 1297 | } |
| 1298 | } |
| 1299 | |
| 1300 | if (m_prevPortAddr != DEBUG_UNSET_PORT) { |
| 1301 | debug_ports(hex2int(m_prevPortAddr), ~DBG_MASK_NONE, false); |
| 1302 | } |
| 1303 | |
| 1304 | mask = portGetMask(row); |
| 1305 | debug_ports(port, mask, true); |
| 1306 | item->setText(portStr); |
| 1307 | m_ports->item(row, PORT_VALUE_COL)->setText(int2hex(data, 2)); |
| 1308 | } else if (col == PORT_VALUE_COL) { |
| 1309 | if (m_ports->item(row, PORT_ADDR_COL)->text() != DEBUG_UNSET_PORT) { |
| 1310 | uint8_t pdata = static_cast<uint8_t>(hex2int(item->text())); |
| 1311 | uint16_t port = static_cast<uint16_t>(hex2int(m_ports->item(row, PORT_ADDR_COL)->text())); |
nothing calls this directly
no test coverage detected