diff --git a/src/platform/qt/MemoryModel.cpp b/src/platform/qt/MemoryModel.cpp index c34f5f7a0..46dc86a86 100644 --- a/src/platform/qt/MemoryModel.cpp +++ b/src/platform/qt/MemoryModel.cpp @@ -83,6 +83,26 @@ void MemoryModel::setAlignment(int width) { viewport()->update(); } +void MemoryModel::jumpToAddress(const QString& hex) { + bool ok = false; + uint32_t i = hex.toInt(&ok, 16); + if (ok) { + jumpToAddress(i); + } +} + +void MemoryModel::jumpToAddress(uint32_t address) { + if (address >= 0x10000000) { + return; + } + if (address < m_base || address >= m_base + m_size) { + setRegion(0, 0x10000000, tr("All")); + } + m_top = (address - m_base) / 16; + boundsCheck(); + verticalScrollBar()->setValue(m_top); +} + void MemoryModel::resizeEvent(QResizeEvent*) { verticalScrollBar()->setRange(0, (m_size >> 4) + 1 - viewport()->size().height() / m_cellHeight); boundsCheck(); diff --git a/src/platform/qt/MemoryModel.h b/src/platform/qt/MemoryModel.h index 272b29833..304fbba92 100644 --- a/src/platform/qt/MemoryModel.h +++ b/src/platform/qt/MemoryModel.h @@ -29,6 +29,10 @@ public: void setRegion(uint32_t base, uint32_t size, const QString& name = QString()); void setAlignment(int); +public slots: + void jumpToAddress(const QString& hex); + void jumpToAddress(uint32_t); + protected: void resizeEvent(QResizeEvent*) override; void paintEvent(QPaintEvent*) override; diff --git a/src/platform/qt/MemoryView.cpp b/src/platform/qt/MemoryView.cpp index 195f957e3..41671c371 100644 --- a/src/platform/qt/MemoryView.cpp +++ b/src/platform/qt/MemoryView.cpp @@ -27,6 +27,7 @@ MemoryView::MemoryView(GameController* controller, QWidget* parent) connect(m_ui.width8, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(1); }); connect(m_ui.width16, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(2); }); connect(m_ui.width32, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(4); }); + connect(m_ui.setAddress, SIGNAL(valueChanged(const QString&)), m_ui.hexfield, SLOT(jumpToAddress(const QString&))); connect(controller, SIGNAL(gameStopped(GBAThread*)), this, SLOT(close())); } diff --git a/src/platform/qt/MemoryView.ui b/src/platform/qt/MemoryView.ui index 25ca12d0a..0684c41d4 100644 --- a/src/platform/qt/MemoryView.ui +++ b/src/platform/qt/MemoryView.ui @@ -90,17 +90,23 @@ <item> <widget class="QLabel" name="label"> <property name="text"> - <string>Inspect Address</string> + <string>Inspect Address:</string> </property> </widget> </item> <item> - <widget class="QLineEdit" name="lineEdit"> - <property name="enabled"> - <bool>false</bool> + <widget class="QSpinBox" name="setAddress"> + <property name="prefix"> + <string>0x</string> </property> - <property name="maxLength"> - <number>10</number> + <property name="maximum"> + <number>268435455</number> + </property> + <property name="singleStep"> + <number>16</number> + </property> + <property name="displayIntegerBase"> + <number>16</number> </property> </widget> </item>