1
0
Fork 0
forked from suyu/suyu

Qt: Clear registers widget on shutdown.

This commit is contained in:
bunnei 2015-04-29 23:26:59 -04:00
parent 43cf424907
commit ad4445c529
3 changed files with 32 additions and 9 deletions

View file

@ -7,8 +7,7 @@
#include "core/core.h"
#include "core/arm/arm_interface.h"
RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent)
{
RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent) {
cpu_regs_ui.setupUi(this);
tree = cpu_regs_ui.treeWidget;
@ -18,8 +17,7 @@ RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent)
registers->setExpanded(true);
CSPR->setExpanded(true);
for (int i = 0; i < 16; ++i)
{
for (int i = 0; i < 16; ++i) {
QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(QString("R[%1]").arg(i, 2, 10, QLatin1Char('0'))));
registers->addChild(child);
}
@ -39,12 +37,16 @@ RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent)
CSPR->addChild(new QTreeWidgetItem(QStringList("C")));
CSPR->addChild(new QTreeWidgetItem(QStringList("Z")));
CSPR->addChild(new QTreeWidgetItem(QStringList("N")));
setEnabled(false);
}
void RegistersWidget::OnDebugModeEntered()
{
void RegistersWidget::OnDebugModeEntered() {
ARM_Interface* app_core = Core::g_app_core;
if (app_core == nullptr)
return;
for (int i = 0; i < 16; ++i)
registers->child(i)->setText(1, QString("0x%1").arg(app_core->GetReg(i), 8, 16, QLatin1Char('0')));
@ -66,7 +68,22 @@ void RegistersWidget::OnDebugModeEntered()
CSPR->child(14)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 31) & 0x1)); // N - Negative/Less than
}
void RegistersWidget::OnDebugModeLeft()
{
void RegistersWidget::OnDebugModeLeft() {
}
void RegistersWidget::OnEmulationStarted(EmuThread* emu_thread) {
setEnabled(true);
}
void RegistersWidget::OnEmulationStopped() {
// Reset widget text
for (int i = 0; i < 16; ++i)
registers->child(i)->setText(1, QString(""));
for (int i = 0; i < 15; ++i)
CSPR->child(i)->setText(1, QString(""));
CSPR->setText(1, QString(""));
setEnabled(false);
}

View file

@ -8,6 +8,7 @@
#include <QTreeWidgetItem>
class QTreeWidget;
class EmuThread;
class RegistersWidget : public QDockWidget
{
@ -20,6 +21,9 @@ public slots:
void OnDebugModeEntered();
void OnDebugModeLeft();
void OnEmulationStarted(EmuThread* emu_thread);
void OnEmulationStopped();
private:
Ui::ARMRegisters cpu_regs_ui;

View file

@ -141,6 +141,8 @@ GMainWindow::GMainWindow() : emu_thread(nullptr)
connect(this, SIGNAL(EmulationStarted(EmuThread*)), disasmWidget, SLOT(OnEmulationStarted(EmuThread*)));
connect(this, SIGNAL(EmulationStopped()), disasmWidget, SLOT(OnEmulationStopped()));
connect(this, SIGNAL(EmulationStarted(EmuThread*)), registersWidget, SLOT(OnEmulationStarted(EmuThread*)));
connect(this, SIGNAL(EmulationStopped()), registersWidget, SLOT(OnEmulationStopped()));
connect(this, SIGNAL(EmulationStarted(EmuThread*)), render_window, SLOT(OnEmulationStarted(EmuThread*)));
connect(this, SIGNAL(EmulationStopped()), render_window, SLOT(OnEmulationStopped()));