aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/NewDialog.ui10
-rw-r--r--qtmips_gui/mainwindow.cpp11
-rw-r--r--qtmips_gui/mainwindow.h2
-rw-r--r--qtmips_gui/newdialog.cpp9
-rw-r--r--qtmips_gui/newdialog.h1
5 files changed, 29 insertions, 4 deletions
diff --git a/qtmips_gui/NewDialog.ui b/qtmips_gui/NewDialog.ui
index b494ffa..03f364f 100644
--- a/qtmips_gui/NewDialog.ui
+++ b/qtmips_gui/NewDialog.ui
@@ -420,10 +420,20 @@
</spacer>
</item>
<item>
+ <widget class="QPushButton" name="pushButton_start_empty">
+ <property name="text">
+ <string>Start empty</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="pushButton_load">
<property name="text">
<string>Load machine</string>
</property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item>
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 32bdd5b..0dc6bd5 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -139,9 +139,13 @@ void MainWindow::start() {
ndialog->show();
}
-void MainWindow::create_core(const machine::MachineConfig &config) {
+void MainWindow::create_core(const machine::MachineConfig &config, bool load_executable) {
// Create machine
- machine::QtMipsMachine *new_machine = new machine::QtMipsMachine(&config, true);
+ machine::QtMipsMachine *new_machine = new machine::QtMipsMachine(&config, true, load_executable);
+
+ if (!load_executable && (machine != nullptr)) {
+ new_machine->memory_rw()->reset(*machine->memory());
+ }
// Remove old machine
if (machine != nullptr)
@@ -233,9 +237,10 @@ void MainWindow::new_machine() {
}
void MainWindow::machine_reload() {
+ bool load_executable = machine->executable_loaded();
machine::MachineConfig cnf(&machine->config()); // We have to make local copy as create_core will delete current machine
try {
- create_core(cnf);
+ create_core(cnf, load_executable);
} catch (const machine::QtMipsExceptionInput &e) {
QMessageBox msg(this);
msg.setText(e.msg(false));
diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h
index cbbc9ec..8a63bd8 100644
--- a/qtmips_gui/mainwindow.h
+++ b/qtmips_gui/mainwindow.h
@@ -60,7 +60,7 @@ public:
~MainWindow();
void start();
- void create_core(const machine::MachineConfig &config);
+ void create_core(const machine::MachineConfig &config, bool load_executable = true);
bool configured();
diff --git a/qtmips_gui/newdialog.cpp b/qtmips_gui/newdialog.cpp
index 67d3f1d..0e1c5dc 100644
--- a/qtmips_gui/newdialog.cpp
+++ b/qtmips_gui/newdialog.cpp
@@ -52,6 +52,7 @@ NewDialog::NewDialog(QWidget *parent, QSettings *settings) : QDialog(parent) {
ui_cache_d = new Ui::NewDialogCache();
ui_cache_d->setupUi(ui->tab_cache_data);
+ connect(ui->pushButton_start_empty, SIGNAL(clicked(bool)), this, SLOT(create_empty()));
connect(ui->pushButton_load, SIGNAL(clicked(bool)), this, SLOT(create()));
connect(ui->pushButton_cancel, SIGNAL(clicked(bool)), this, SLOT(cancel()));
connect(ui->pushButton_browse, SIGNAL(clicked(bool)), this, SLOT(browse_elf()));
@@ -136,6 +137,14 @@ void NewDialog::create() {
this->close();
}
+void NewDialog::create_empty() {
+ MainWindow *prnt = (MainWindow*)parent();
+ prnt->create_core(*config, false);
+ store_settings(); // Save to settings
+ this->close();
+}
+
+
void NewDialog::browse_elf() {
QFileDialog elf_dialog(this);
elf_dialog.setFileMode(QFileDialog::ExistingFile);
diff --git a/qtmips_gui/newdialog.h b/qtmips_gui/newdialog.h
index 6e6ed8a..077b1ab 100644
--- a/qtmips_gui/newdialog.h
+++ b/qtmips_gui/newdialog.h
@@ -60,6 +60,7 @@ protected:
private slots:
void cancel();
void create();
+ void create_empty();
void browse_elf();
void elf_change(QString val);
void set_preset();