Skip to content

Commit

Permalink
gui: Fix address calculation in memory visualizer context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
calc84maniac committed Feb 11, 2025
1 parent 9a3360e commit dcbf893
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
10 changes: 7 additions & 3 deletions gui/qt/debugger/visualizerdisplaywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void VisualizerDisplayWidget::setRefreshRate(int rate) {
m_refresh = rate;
}

void VisualizerDisplayWidget::setConfig(float bppstep, int w, int h, uint32_t u, uint32_t c, bool g, uint32_t *d, uint32_t *e) {
void VisualizerDisplayWidget::setConfig(uint32_t bppstep, int w, int h, uint32_t u, uint32_t c, bool g, uint32_t *d, uint32_t *e) {
m_bppstep = bppstep;
m_width = w;
m_height = h;
Expand All @@ -125,8 +125,12 @@ void VisualizerDisplayWidget::contextMenu(const QPoint& posa) {
uint32_t x = static_cast<uint32_t>(point.x());
uint32_t y = static_cast<uint32_t>(point.y());

QString addr = int2hex(m_upbase + (static_cast<uint32_t>(std::floor((static_cast<float>(x)) / m_bppstep))) +
(static_cast<unsigned int>(m_width) * y), 6);
uint32_t offset = (static_cast<unsigned int>(m_width) * y + x) * m_bppstep / 8;
if (m_control & 0x200) {
// reverse order within 32-bit word for BEBO mode
offset ^= (-m_bppstep / 8) & 3;
}
QString addr = int2hex(m_upbase + offset, 6);

coordStr += QString::number(x) + QStringLiteral("x") + QString::number(y);
copyStr += QStringLiteral(" '") + addr + QStringLiteral("'");
Expand Down
4 changes: 2 additions & 2 deletions gui/qt/debugger/visualizerdisplaywidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class VisualizerDisplayWidget : public QWidget {
explicit VisualizerDisplayWidget(QWidget *p = Q_NULLPTR);
~VisualizerDisplayWidget();
void setRefreshRate(int rate);
void setConfig(float bppstep, int w, int h, uint32_t u, uint32_t c, bool g, uint32_t *d, uint32_t *e);
void setConfig(uint32_t bppstep, int w, int h, uint32_t u, uint32_t c, bool g, uint32_t *d, uint32_t *e);

protected:
virtual void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
Expand All @@ -34,7 +34,7 @@ private slots:
bool m_grid;
uint32_t m_upbase;
uint32_t m_control;
float m_bppstep;
uint32_t m_bppstep;
uint32_t *m_data;
uint32_t *m_data_end;
};
Expand Down
18 changes: 9 additions & 9 deletions gui/qt/visualizerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,17 @@ void VisualizerWidget::forceUpdate() {

void VisualizerWidget::viewToString() {
QString bpp;
float bppstep = 1.0f;
uint32_t bppstep = 1;

switch ((m_control >> 1) & 7) {
case 0: bpp = QStringLiteral("1"); bppstep = 1.0f/0.125f; break;
case 1: bpp = QStringLiteral("2"); bppstep = 1.0f/0.25f; break;
case 2: bpp = QStringLiteral("4"); bppstep = 1.0f/0.5f; break;
case 3: bpp = QStringLiteral("8"); bppstep = 1.0f/1.0f; break;
case 4: bpp = QStringLiteral("1555"); bppstep = 1.0f/2.0f; break;
case 5: bpp = QStringLiteral("888"); bppstep = 1.0f/3.0f; break;
case 6: bpp = QStringLiteral("565"); bppstep = 1.0f/2.0f; break;
case 7: bpp = QStringLiteral("444"); bppstep = 1.0f/1.5f; break;
case 0: bpp = QStringLiteral("1"); bppstep = 1; break;
case 1: bpp = QStringLiteral("2"); bppstep = 2; break;
case 2: bpp = QStringLiteral("4"); bppstep = 4; break;
case 3: bpp = QStringLiteral("8"); bppstep = 8; break;
case 4: bpp = QStringLiteral("1555"); bppstep = 16; break;
case 5: bpp = QStringLiteral("888"); bppstep = 32; break;
case 6: bpp = QStringLiteral("565"); bppstep = 16; break;
case 7: bpp = QStringLiteral("444"); bppstep = 16; break;
default: break;
}

Expand Down

0 comments on commit dcbf893

Please sign in to comment.