mirror of https://github.com/mgba-emu/mgba.git
Qt: Add shadow ROM exporting
This commit is contained in:
parent
8610147ad7
commit
c03b15944b
|
@ -8,6 +8,7 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "GBAApp.h"
|
#include "GBAApp.h"
|
||||||
|
#include "utils.h"
|
||||||
#include "VFileDevice.h"
|
#include "VFileDevice.h"
|
||||||
|
|
||||||
using namespace QGBA;
|
using namespace QGBA;
|
||||||
|
@ -19,6 +20,7 @@ MemoryAccessLogView::MemoryAccessLogView(std::shared_ptr<CoreController> control
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
connect(m_ui.browse, &QAbstractButton::clicked, this, &MemoryAccessLogView::selectFile);
|
connect(m_ui.browse, &QAbstractButton::clicked, this, &MemoryAccessLogView::selectFile);
|
||||||
|
connect(m_ui.exportButton, &QAbstractButton::clicked, this, &MemoryAccessLogView::exportFile);
|
||||||
connect(this, &MemoryAccessLogView::loggingChanged, m_ui.start, &QWidget::setDisabled);
|
connect(this, &MemoryAccessLogView::loggingChanged, m_ui.start, &QWidget::setDisabled);
|
||||||
connect(this, &MemoryAccessLogView::loggingChanged, m_ui.stop, &QWidget::setEnabled);
|
connect(this, &MemoryAccessLogView::loggingChanged, m_ui.stop, &QWidget::setEnabled);
|
||||||
connect(this, &MemoryAccessLogView::loggingChanged, m_ui.filename, &QWidget::setDisabled);
|
connect(this, &MemoryAccessLogView::loggingChanged, m_ui.filename, &QWidget::setDisabled);
|
||||||
|
@ -58,7 +60,7 @@ void MemoryAccessLogView::updateRegion(const QString& internalName, bool checked
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_regionBoxes[internalName]->setEnabled(false);
|
m_regionBoxes[internalName]->setEnabled(false);
|
||||||
mDebuggerAccessLoggerWatchMemoryBlockName(&m_logger, internalName.toUtf8().constData(), activeFlags());
|
m_regionMapping[internalName] = mDebuggerAccessLoggerWatchMemoryBlockName(&m_logger, internalName.toUtf8().constData(), activeFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryAccessLogView::start() {
|
void MemoryAccessLogView::start() {
|
||||||
|
@ -72,6 +74,7 @@ void MemoryAccessLogView::start() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mDebuggerAccessLoggerInit(&m_logger);
|
mDebuggerAccessLoggerInit(&m_logger);
|
||||||
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
m_controller->attachDebuggerModule(&m_logger.d);
|
m_controller->attachDebuggerModule(&m_logger.d);
|
||||||
if (!mDebuggerAccessLoggerOpen(&m_logger, vf, flags)) {
|
if (!mDebuggerAccessLoggerOpen(&m_logger, vf, flags)) {
|
||||||
mDebuggerAccessLoggerDeinit(&m_logger);
|
mDebuggerAccessLoggerDeinit(&m_logger);
|
||||||
|
@ -83,7 +86,12 @@ void MemoryAccessLogView::start() {
|
||||||
emit loggingChanged(true);
|
emit loggingChanged(true);
|
||||||
for (const auto& region : m_watchedRegions) {
|
for (const auto& region : m_watchedRegions) {
|
||||||
m_regionBoxes[region]->setEnabled(false);
|
m_regionBoxes[region]->setEnabled(false);
|
||||||
mDebuggerAccessLoggerWatchMemoryBlockName(&m_logger, region.toUtf8().constData(), activeFlags());
|
m_regionMapping[region] = mDebuggerAccessLoggerWatchMemoryBlockName(&m_logger, region.toUtf8().constData(), activeFlags());
|
||||||
|
}
|
||||||
|
interrupter.resume();
|
||||||
|
|
||||||
|
if (m_watchedRegions.contains(QString("cart0"))) {
|
||||||
|
m_ui.exportButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,12 +99,16 @@ void MemoryAccessLogView::stop() {
|
||||||
if (!m_active) {
|
if (!m_active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
m_controller->detachDebuggerModule(&m_logger.d);
|
m_controller->detachDebuggerModule(&m_logger.d);
|
||||||
mDebuggerAccessLoggerDeinit(&m_logger);
|
mDebuggerAccessLoggerDeinit(&m_logger);
|
||||||
emit loggingChanged(false);
|
emit loggingChanged(false);
|
||||||
|
interrupter.resume();
|
||||||
|
|
||||||
for (const auto& region : m_watchedRegions) {
|
for (const auto& region : m_watchedRegions) {
|
||||||
m_regionBoxes[region]->setEnabled(true);
|
m_regionBoxes[region]->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
m_ui.exportButton->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryAccessLogView::selectFile() {
|
void MemoryAccessLogView::selectFile() {
|
||||||
|
@ -113,3 +125,23 @@ mDebuggerAccessLogRegionFlags MemoryAccessLogView::activeFlags() const {
|
||||||
}
|
}
|
||||||
return loggerFlags;
|
return loggerFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MemoryAccessLogView::exportFile() {
|
||||||
|
if (!m_regionMapping.contains("cart0")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString filename = GBAApp::app()->getSaveFileName(this, tr("Select access log file"), romFilters(false, m_controller->platform(), true));
|
||||||
|
if (filename.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
VFile* vf = VFileDevice::open(filename, O_CREAT | O_TRUNC | O_WRONLY);
|
||||||
|
if (!vf) {
|
||||||
|
// log error
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
|
mDebuggerAccessLoggerCreateShadowFile(&m_logger, m_regionMapping[QString("cart0")], vf, 0);
|
||||||
|
vf->close(vf);
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@ private slots:
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
void exportFile();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loggingChanged(bool active);
|
void loggingChanged(bool active);
|
||||||
|
|
||||||
|
@ -41,6 +43,7 @@ private:
|
||||||
std::shared_ptr<CoreController> m_controller;
|
std::shared_ptr<CoreController> m_controller;
|
||||||
QSet<QString> m_watchedRegions;
|
QSet<QString> m_watchedRegions;
|
||||||
QHash<QString, QCheckBox*> m_regionBoxes;
|
QHash<QString, QCheckBox*> m_regionBoxes;
|
||||||
|
QHash<QString, int> m_regionMapping;
|
||||||
struct mDebuggerAccessLogger m_logger;
|
struct mDebuggerAccessLogger m_logger;
|
||||||
bool m_active = false;
|
bool m_active = false;
|
||||||
|
|
||||||
|
|
|
@ -17,29 +17,15 @@
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetFixedSize</enum>
|
<enum>QLayout::SetFixedSize</enum>
|
||||||
</property>
|
</property>
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QPushButton" name="start">
|
|
||||||
<property name="text">
|
|
||||||
<string>Start</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QPushButton" name="stop">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Stop</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Log file</string>
|
<string>Log file</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLineEdit" name="filename"/>
|
||||||
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QPushButton" name="browse">
|
<widget class="QPushButton" name="browse">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -47,9 +33,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLineEdit" name="filename"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="logExtra">
|
<widget class="QCheckBox" name="logExtra">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -78,6 +61,33 @@
|
||||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QPushButton" name="exportButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Export ROM snapshot</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QPushButton" name="start">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QPushButton" name="stop">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Stop</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
Loading…
Reference in New Issue