From 0f67b25243ef3c88a75c69e7d6abcb8b7e941ecb Mon Sep 17 00:00:00 2001 From: Nikita Zimin Date: Wed, 8 Jan 2025 21:43:05 +0300 Subject: [PATCH] Tuning debugger views --- emulator/Common.h | 1 + emulator/qdebugview.cpp | 32 ++++++++++++++++++------ emulator/qdisasmview.cpp | 54 ++++++++++++++++++++++++++++++---------- emulator/qdisasmview.h | 1 + 4 files changed, 67 insertions(+), 21 deletions(-) diff --git a/emulator/Common.h b/emulator/Common.h index 528e7c4..2281051 100644 --- a/emulator/Common.h +++ b/emulator/Common.h @@ -111,6 +111,7 @@ const int BK_SCREEN_HEIGHT = 256; #define COLOR_JUMPNO qRgb(192,192,192) #define COLOR_JUMPHINT qRgb(40,128,160) #define COLOR_HINT qRgb(40,40,160) +#define COLOR_BREAKPOINT qRgb(255,0,0) QFont Common_GetMonospacedFont(); QColor Common_GetColorShifted(const QPalette& palette, QRgb rgb); diff --git a/emulator/qdebugview.cpp b/emulator/qdebugview.cpp index ab5858d..b5584a1 100644 --- a/emulator/qdebugview.cpp +++ b/emulator/qdebugview.cpp @@ -549,15 +549,31 @@ void QDebugMemoryMapCtrl::paintEvent(QPaintEvent * /*event*/) painter.drawRect(x1, y1, x2 - x1, y2 - y1); painter.drawText(x, ybase + 2, "000000"); - for (int i = 1; i < 8; i++) + for (int i = 0; i < 8; i++) { - int ycur = y2 - cyLine * i * 2; - if (i < 7) - painter.drawLine(x1, ycur, x1 + 8, ycur); - else - painter.drawLine(x1, ycur, x2, ycur); - quint16 addr = (quint16)i * 020000; - DrawOctalValue(painter, x, y2 - cyLine * i * 2 + cyLine / 3, addr); + int yp = y2 - cyLine * i * 2; + quint16 address = (quint16)i * 020000; + + if (i > 0) + { + painter.drawLine(x1, yp, x2, yp); + DrawOctalValue(painter, x, y2 - cyLine * i * 2 + cyLine / 3, address); + } + + int addrtype; + g_pBoard->GetWordView(address, getProc()->GetHALT(), false, &addrtype); + QString addrtypestr; + switch (addrtype & (ADDRTYPE_RAM | ADDRTYPE_ROM | ADDRTYPE_IO | ADDRTYPE_DENY)) + { + case ADDRTYPE_ROM: addrtypestr = "ROM"; break; + case ADDRTYPE_RAM: addrtypestr = "RAM"; break; + case ADDRTYPE_IO: addrtypestr = "I/O"; break; + case ADDRTYPE_DENY: addrtypestr = "N/A"; break; + default: + addrtypestr.clear(); + } + if (!addrtypestr.isEmpty()) + painter.drawText(xtype, yp - (cyLine * 2) / 3, addrtypestr); } quint16 sp = getProc()->GetSP(); diff --git a/emulator/qdisasmview.cpp b/emulator/qdisasmview.cpp index 514bdae..9eeb4d6 100644 --- a/emulator/qdisasmview.cpp +++ b/emulator/qdisasmview.cpp @@ -3,12 +3,14 @@ #include #include #include +#include "main.h" #include "qdisasmview.h" #include "Emulator.h" #include "emubase/Emubase.h" const int MAX_DISASMLINECOUNT = 50; +const int HINT_CHARPOS = 52; ////////////////////////////////////////////////////////////////////// @@ -28,6 +30,7 @@ QDisasmView::QDisasmView() this->setMinimumSize(cxChar * 55, cyLine * 10 + cyLine / 2); setFocusPolicy(Qt::ClickFocus); + setMouseTracking(true); } void QDisasmView::updateWindowText() @@ -54,6 +57,16 @@ void QDisasmView::contextMenuEvent(QContextMenuEvent *event) menu.exec(event->globalPos()); } +void QDisasmView::mouseMoveEvent(QMouseEvent * event) +{ + if (event->x() < m_cxDisasmBreakpointZone) + setCursor(QCursor(Qt::PointingHandCursor)); + else + setCursor(QCursor(Qt::ArrowCursor)); + + QWidget::mouseMoveEvent(event); +} + void QDisasmView::mousePressEvent(QMouseEvent * event) { if (event->button() == Qt::LeftButton) @@ -98,7 +111,7 @@ void QDisasmView::showHideSubtitles() else { QFileDialog dlg; - dlg.setNameFilter(tr("BKBTL subtitles (*.lst)")); + dlg.setNameFilter(tr("Disasm subtitles (*.lst)")); if (dlg.exec() == QDialog::Rejected) return; QString fileName = dlg.selectedFiles().at(0); @@ -384,7 +397,7 @@ void QDisasmView::paintEvent(QPaintEvent * /*event*/) void QDisasmView::drawBreakpoint(QPainter& painter, int x, int y, int size) { - QColor colorBreakpoint = qRgb(192, 0, 0); + QColor colorBreakpoint = Common_GetColorShifted(palette(), COLOR_BREAKPOINT); painter.setBrush(colorBreakpoint); painter.setPen(colorBreakpoint); painter.drawEllipse(x, y, size, -size); @@ -401,6 +414,8 @@ int QDisasmView::drawDisassemble(QPainter &painter, CProcessor *pProc, quint16 c int cyLine = fontmetrics.lineSpacing(); m_cxDisasmBreakpointZone = cxChar * 2; m_cyDisasmLine = cyLine; + int xHint = HINT_CHARPOS * cxChar; + QColor colorBackground = palette().color(QPalette::Base); QColor colorText = palette().color(QPalette::Text); QColor colorPrev = Common_GetColorShifted(palette(), COLOR_PREVIOUS); QColor colorChanged = Common_GetColorShifted(palette(), COLOR_VALUECHANGED); @@ -408,21 +423,24 @@ int QDisasmView::drawDisassemble(QPainter &painter, CProcessor *pProc, quint16 c QColor colorValueRom = Common_GetColorShifted(palette(), COLOR_VALUEROM); QColor colorSubtitle = Common_GetColorShifted(palette(), COLOR_SUBTITLE); QColor colorJump = Common_GetColorShifted(palette(), COLOR_JUMP); + QColor colorWindow = palette().color(QPalette::Window); quint16 proccurrent = pProc->GetPC(); + // Draw breakpoint zone + painter.fillRect(0, 0, m_cxDisasmBreakpointZone, this->height(), colorWindow); + // Draw current line background if (m_SubtitleItems.isEmpty()) //NOTE: Subtitles can move lines down { int yCurrent = (proccurrent - (current - 5)) * cyLine + fontmetrics.descent(); - QColor colorCurrent = palette().color(QPalette::Window); - painter.fillRect(0, yCurrent, this->width(), cyLine, colorCurrent); + painter.fillRect(0, yCurrent, xHint, cyLine, colorWindow); } int y = cyLine; for (int lineindex = 0; lineindex < m_DisasmLineItems.count(); lineindex++) // Draw the lines { - DisasmLineItem& lineitem = m_DisasmLineItems[lineindex]; + const DisasmLineItem& lineitem = m_DisasmLineItems[lineindex]; if (lineitem.type == LINETYPE_NONE) break; quint16 address = lineitem.address; @@ -442,11 +460,12 @@ int QDisasmView::drawDisassemble(QPainter &painter, CProcessor *pProc, quint16 c if (Emulator_IsBreakpoint(address)) // Breakpoint { - drawBreakpoint(painter, cxChar / 2, y, cxChar); + drawBreakpoint(painter, 0, y, (cxChar + cyLine) / 2); } painter.setPen(colorText); DrawOctalValue(painter, 5 * cxChar, y, address); // Address + // Value at the address quint16 value = lineitem.value; int memorytype = lineitem.addrtype; @@ -511,14 +530,23 @@ int QDisasmView::drawDisassemble(QPainter &painter, CProcessor *pProc, quint16 c } } - if (address == proccurrent && *m_strDisasmHint != 0) // For current instruction, draw "Instruction Hints" + if (address == proccurrent) { - QColor hintcolor = Common_GetColorShifted(palette(), isjump ? COLOR_JUMPHINT : COLOR_HINT); - painter.setPen(hintcolor); - painter.drawText(52 * cxChar, y, m_strDisasmHint); - if (*m_strDisasmHint2 != 0) - painter.drawText(52 * cxChar, y + cyLine, m_strDisasmHint2); - painter.setPen(colorText); + int cyHint = cyLine * (*m_strDisasmHint2 == 0 ? 1 : 2); + QLinearGradient gradient(xHint - cxChar, 0, xHint + 25 * cxChar, 0); + gradient.setColorAt(0, colorWindow); + gradient.setColorAt(1, colorBackground); + painter.fillRect(xHint - cxChar, y - cyLine + fontmetrics.descent(), 25 * cxChar, cyHint, gradient); + + if (*m_strDisasmHint != 0) // For current instruction, draw "Instruction Hints" + { + QColor hintcolor = Common_GetColorShifted(palette(), isjump ? COLOR_JUMPHINT : COLOR_HINT); + painter.setPen(hintcolor); + painter.drawText(xHint, y, m_strDisasmHint); + if (*m_strDisasmHint2 != 0) + painter.drawText(xHint, y + cyLine, m_strDisasmHint2); + painter.setPen(colorText); + } } } diff --git a/emulator/qdisasmview.h b/emulator/qdisasmview.h index 406acd7..fa63ecc 100644 --- a/emulator/qdisasmview.h +++ b/emulator/qdisasmview.h @@ -62,6 +62,7 @@ public slots: void contextMenuEvent(QContextMenuEvent *event) override; void focusInEvent(QFocusEvent *) override; void focusOutEvent(QFocusEvent *) override; + void mouseMoveEvent(QMouseEvent *) override; void mousePressEvent(QMouseEvent *) override; void parseSubtitles(QTextStream& stream);