mirror of https://github.com/mgba-emu/mgba.git
Qt: Memory view address jump
This commit is contained in:
parent
28f174fb66
commit
21542034d3
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue