diff --git a/src/core/cpu_core.cpp b/src/core/cpu_core.cpp index 4338816d1..743878f5c 100644 --- a/src/core/cpu_core.cpp +++ b/src/core/cpu_core.cpp @@ -825,7 +825,6 @@ const std::array g_debugger_register_list; } // namespace CPU diff --git a/src/duckstation-qt/debuggermodels.cpp b/src/duckstation-qt/debuggermodels.cpp index c8b3f3c51..c429df2ed 100644 --- a/src/duckstation-qt/debuggermodels.cpp +++ b/src/duckstation-qt/debuggermodels.cpp @@ -333,11 +333,11 @@ QVariant DebuggerRegistersModel::data(const QModelIndex& index, int role /*= Qt: { if (role == Qt::DisplayRole) { - return QString::asprintf("0x%08X", *CPU::g_debugger_register_list[reg_index].value_ptr); + return QString::asprintf("0x%08X", m_reg_values[reg_index]); } else if (role == Qt::ForegroundRole) { - if (*CPU::g_debugger_register_list[reg_index].value_ptr != m_old_reg_values[reg_index]) + if (m_reg_values[reg_index] != m_old_reg_values[reg_index]) return QColor(255, 50, 50); } } @@ -370,16 +370,19 @@ QVariant DebuggerRegistersModel::headerData(int section, Qt::Orientation orienta } } -void DebuggerRegistersModel::invalidateView() +void DebuggerRegistersModel::updateValues() { beginResetModel(); + + for (u32 i = 0; i < CPU::NUM_DEBUGGER_REGISTER_LIST_ENTRIES; i++) + m_reg_values[i] = *CPU::g_debugger_register_list[i].value_ptr; + endResetModel(); } void DebuggerRegistersModel::saveCurrentValues() { - for (u32 i = 0; i < static_cast(CPU::Reg::count); i++) - m_old_reg_values[i] = CPU::g_state.regs.r[i]; + m_old_reg_values = m_reg_values; } DebuggerStackModel::DebuggerStackModel(QObject* parent /*= nullptr*/) : QAbstractListModel(parent) diff --git a/src/duckstation-qt/debuggermodels.h b/src/duckstation-qt/debuggermodels.h index 2836b5497..b3ab07d8a 100644 --- a/src/duckstation-qt/debuggermodels.h +++ b/src/duckstation-qt/debuggermodels.h @@ -64,11 +64,12 @@ public: virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - void invalidateView(); + void updateValues(); void saveCurrentValues(); private: - u32 m_old_reg_values[CPU::NUM_DEBUGGER_REGISTER_LIST_ENTRIES] = {}; + std::array m_reg_values = {}; + std::array m_old_reg_values = {}; }; class DebuggerStackModel : public QAbstractListModel diff --git a/src/duckstation-qt/debuggerwindow.cpp b/src/duckstation-qt/debuggerwindow.cpp index 2b08d86a2..f6bec4822 100644 --- a/src/duckstation-qt/debuggerwindow.cpp +++ b/src/duckstation-qt/debuggerwindow.cpp @@ -66,7 +66,7 @@ void DebuggerWindow::onDebuggerMessageReported(const QString& message) void DebuggerWindow::refreshAll() { - m_registers_model->invalidateView(); + m_registers_model->updateValues(); m_stack_model->invalidateView(); m_ui.memoryView->repaint(); @@ -196,7 +196,6 @@ void DebuggerWindow::onStepIntoActionTriggered() Assert(System::IsPaused()); m_registers_model->saveCurrentValues(); g_emu_thread->singleStepCPU(); - refreshAll(); } void DebuggerWindow::onStepOverActionTriggered()