mirror of https://github.com/mgba-emu/mgba.git
Qt: Add small decoder bar at the bottom of the hex view, still needs work
This commit is contained in:
parent
a977ecb491
commit
63071d9bc2
|
@ -204,6 +204,7 @@ void MemoryModel::mousePressEvent(QMouseEvent* event) {
|
||||||
uint32_t address = int(position.x() / m_cellSize.width()) + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base;
|
uint32_t address = int(position.x() / m_cellSize.width()) + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base;
|
||||||
m_selectionAnchor = address & ~(m_align - 1);
|
m_selectionAnchor = address & ~(m_align - 1);
|
||||||
m_selection = qMakePair(m_selectionAnchor, m_selectionAnchor + m_align);
|
m_selection = qMakePair(m_selectionAnchor, m_selectionAnchor + m_align);
|
||||||
|
emit selectionChanged(m_selection.first, m_selection.second);
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +220,7 @@ void MemoryModel::mouseMoveEvent(QMouseEvent* event) {
|
||||||
} else {
|
} else {
|
||||||
m_selection = qMakePair(m_selectionAnchor, (address & ~(m_align - 1)) + m_align);
|
m_selection = qMakePair(m_selectionAnchor, (address & ~(m_align - 1)) + m_align);
|
||||||
}
|
}
|
||||||
|
emit selectionChanged(m_selection.first, m_selection.second);
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,17 @@ public:
|
||||||
void setController(GameController* controller);
|
void setController(GameController* controller);
|
||||||
|
|
||||||
void setRegion(uint32_t base, uint32_t size, const QString& name = QString());
|
void setRegion(uint32_t base, uint32_t size, const QString& name = QString());
|
||||||
|
|
||||||
void setAlignment(int);
|
void setAlignment(int);
|
||||||
|
int alignment() const { return m_align; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void jumpToAddress(const QString& hex);
|
void jumpToAddress(const QString& hex);
|
||||||
void jumpToAddress(uint32_t);
|
void jumpToAddress(uint32_t);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void selectionChanged(uint32_t start, uint32_t end);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent*) override;
|
void resizeEvent(QResizeEvent*) override;
|
||||||
void paintEvent(QPaintEvent*) override;
|
void paintEvent(QPaintEvent*) override;
|
||||||
|
|
|
@ -29,6 +29,8 @@ MemoryView::MemoryView(GameController* controller, QWidget* parent)
|
||||||
connect(m_ui.width32, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(4); });
|
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(m_ui.setAddress, SIGNAL(valueChanged(const QString&)), m_ui.hexfield, SLOT(jumpToAddress(const QString&)));
|
||||||
|
|
||||||
|
connect(m_ui.hexfield, SIGNAL(selectionChanged(uint32_t, uint32_t)), this, SLOT(updateStatus(uint32_t, uint32_t)));
|
||||||
|
|
||||||
connect(controller, SIGNAL(gameStopped(GBAThread*)), this, SLOT(close()));
|
connect(controller, SIGNAL(gameStopped(GBAThread*)), this, SLOT(close()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,3 +56,38 @@ void MemoryView::setIndex(int index) {
|
||||||
const auto& info = indexInfo[index];
|
const auto& info = indexInfo[index];
|
||||||
m_ui.hexfield->setRegion(info.base, info.size, info.name);
|
m_ui.hexfield->setRegion(info.base, info.size, info.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MemoryView::updateStatus(uint32_t start, uint32_t end) {
|
||||||
|
int align = m_ui.hexfield->alignment();
|
||||||
|
if (start & (align - 1) || end - start != align) {
|
||||||
|
m_ui.sintVal->clear();
|
||||||
|
m_ui.uintVal->clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ARMCore* cpu = m_controller->thread()->cpu;
|
||||||
|
union {
|
||||||
|
uint32_t u32;
|
||||||
|
int32_t i32;
|
||||||
|
uint16_t u16;
|
||||||
|
int16_t i16;
|
||||||
|
uint8_t u8;
|
||||||
|
int8_t i8;
|
||||||
|
} value;
|
||||||
|
switch (align) {
|
||||||
|
case 1:
|
||||||
|
value.u8 = cpu->memory.load8(cpu, start, nullptr);
|
||||||
|
m_ui.sintVal->setText(QString::number(value.i8));
|
||||||
|
m_ui.uintVal->setText(QString::number(value.u8));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
value.u16 = cpu->memory.load16(cpu, start, nullptr);
|
||||||
|
m_ui.sintVal->setText(QString::number(value.i16));
|
||||||
|
m_ui.uintVal->setText(QString::number(value.u16));
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
value.u32 = cpu->memory.load32(cpu, start, nullptr);
|
||||||
|
m_ui.sintVal->setText(QString::number(value.i32));
|
||||||
|
m_ui.uintVal->setText(QString::number(value.u32));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setIndex(int);
|
void setIndex(int);
|
||||||
|
void updateStatus(uint32_t start, uint32_t end);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MemoryView m_ui;
|
Ui::MemoryView m_ui;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>550</width>
|
<width>550</width>
|
||||||
<height>610</height>
|
<height>640</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -185,6 +185,46 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Signed Integer:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="sintVal">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="formLayout_4">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unsigned Integer:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="uintVal">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|
Loading…
Reference in New Issue