Qt: Add small decoder bar at the bottom of the hex view, still needs work
Jeffrey Pfau jeffrey@endrift.com
Fri, 01 May 2015 22:47:22 -0700
5 files changed,
86 insertions(+),
1 deletions(-)
M
src/platform/qt/MemoryModel.cpp
→
src/platform/qt/MemoryModel.cpp
@@ -204,6 +204,7 @@ QPoint position(event->pos() - QPoint(m_margins.left(), m_margins.top()));
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_selection = qMakePair(m_selectionAnchor, m_selectionAnchor + m_align); + emit selectionChanged(m_selection.first, m_selection.second); viewport()->update(); }@@ -219,6 +220,7 @@ m_selection = qMakePair(address & ~(m_align - 1), m_selectionAnchor + m_align);
} else { m_selection = qMakePair(m_selectionAnchor, (address & ~(m_align - 1)) + m_align); } + emit selectionChanged(m_selection.first, m_selection.second); viewport()->update(); }
M
src/platform/qt/MemoryModel.h
→
src/platform/qt/MemoryModel.h
@@ -27,11 +27,16 @@
void setController(GameController* controller); void setRegion(uint32_t base, uint32_t size, const QString& name = QString()); + void setAlignment(int); + int alignment() const { return m_align; } public slots: void jumpToAddress(const QString& hex); void jumpToAddress(uint32_t); + +signals: + void selectionChanged(uint32_t start, uint32_t end); protected: void resizeEvent(QResizeEvent*) override;
M
src/platform/qt/MemoryView.cpp
→
src/platform/qt/MemoryView.cpp
@@ -29,6 +29,8 @@ 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(m_ui.hexfield, SIGNAL(selectionChanged(uint32_t, uint32_t)), this, SLOT(updateStatus(uint32_t, uint32_t))); + connect(controller, SIGNAL(gameStopped(GBAThread*)), this, SLOT(close())); }@@ -54,3 +56,38 @@ };
const auto& info = indexInfo[index]; 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; + } +}
M
src/platform/qt/MemoryView.h
→
src/platform/qt/MemoryView.h
@@ -22,6 +22,7 @@ MemoryView(GameController* controller, QWidget* parent = nullptr);
private slots: void setIndex(int); + void updateStatus(uint32_t start, uint32_t end); private: Ui::MemoryView m_ui;
M
src/platform/qt/MemoryView.ui
→
src/platform/qt/MemoryView.ui
@@ -7,7 +7,7 @@ <rect>
<x>0</x> <y>0</y> <width>550</width> - <height>610</height> + <height>640</height> </rect> </property> <property name="windowTitle">@@ -184,6 +184,46 @@ <verstretch>0</verstretch>
</sizepolicy> </property> </widget> + </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> </widget>