diff --git a/Source/Core/Common/DebugInterface.h b/Source/Core/Common/DebugInterface.h index 4ae5fd4174..0540003c39 100644 --- a/Source/Core/Common/DebugInterface.h +++ b/Source/Core/Common/DebugInterface.h @@ -74,7 +74,7 @@ public: virtual void SetPC(u32 /*address*/) {} virtual void Step() {} virtual void RunToBreakpoint() {} - virtual int GetColor(u32 /*address*/) { return 0xFFFFFFFF; } + virtual u32 GetColor(u32 /*address*/) { return 0xFFFFFFFF; } virtual std::string GetDescription(u32 /*address*/) = 0; virtual void Clear() = 0; }; diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp index 473509a67c..245e26cf77 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp @@ -4,6 +4,7 @@ #include "Core/Debugger/PPCDebugInterface.h" +#include #include #include @@ -300,13 +301,20 @@ void PPCDebugInterface::ToggleMemCheck(u32 address, bool read, bool write, bool // ======================================================= // Separate the blocks with colors. // ------------- -int PPCDebugInterface::GetColor(u32 address) +u32 PPCDebugInterface::GetColor(u32 address) { if (!IsAlive()) return 0xFFFFFF; if (!PowerPC::HostIsRAMAddress(address)) return 0xeeeeee; - static const int colors[6] = { + + Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address); + if (!symbol) + return 0xFFFFFF; + if (symbol->type != Common::Symbol::Type::Function) + return 0xEEEEFF; + + static constexpr std::array colors{ 0xd0FFFF, // light cyan 0xFFd0d0, // light red 0xd8d8FF, // light blue @@ -314,12 +322,7 @@ int PPCDebugInterface::GetColor(u32 address) 0xd0FFd0, // light green 0xFFFFd0, // light yellow }; - Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address); - if (!symbol) - return 0xFFFFFF; - if (symbol->type != Common::Symbol::Type::Function) - return 0xEEEEFF; - return colors[symbol->index % 6]; + return colors[symbol->index % colors.size()]; } // ============= diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h index b0536a4c6c..07d7d057d8 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.h +++ b/Source/Core/Core/Debugger/PPCDebugInterface.h @@ -77,7 +77,7 @@ public: void SetPC(u32 address) override; void Step() override {} void RunToBreakpoint() override; - int GetColor(u32 address) override; + u32 GetColor(u32 address) override; std::string GetDescription(u32 address) override; void Clear() override; diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp index 8ea752fddd..1f9e4f6e2c 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp @@ -4,6 +4,7 @@ #include "Core/HW/DSPLLE/DSPDebugInterface.h" +#include #include #include @@ -257,17 +258,8 @@ void DSPDebugInterface::ToggleMemCheck(u32 address, bool read, bool write, bool // ======================================================= // Separate the blocks with colors. // ------------- -int DSPDebugInterface::GetColor(u32 address) +u32 DSPDebugInterface::GetColor(u32 address) { - static const int colors[6] = { - 0xd0FFFF, // light cyan - 0xFFd0d0, // light red - 0xd8d8FF, // light blue - 0xFFd0FF, // light purple - 0xd0FFd0, // light green - 0xFFFFd0, // light yellow - }; - // Scan backwards so we don't miss it. Hm, actually, let's not - it looks pretty good. int addr = -1; for (int i = 0; i < 1; i++) @@ -284,7 +276,16 @@ int DSPDebugInterface::GetColor(u32 address) return 0xFFFFFF; if (symbol->type != Common::Symbol::Type::Function) return 0xEEEEFF; - return colors[symbol->index % 6]; + + static constexpr std::array colors{ + 0xd0FFFF, // light cyan + 0xFFd0d0, // light red + 0xd8d8FF, // light blue + 0xFFd0FF, // light purple + 0xd0FFd0, // light green + 0xFFFFd0, // light yellow + }; + return colors[symbol->index % colors.size()]; } // ============= diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h index ab02f342bc..0988abef11 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h @@ -71,7 +71,7 @@ public: void SetPC(u32 address) override; void Step() override {} void RunToBreakpoint() override; - int GetColor(u32 address) override; + u32 GetColor(u32 address) override; std::string GetDescription(u32 address) override; void Clear() override; diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp index 2427101cb7..d8e8fc83d4 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp @@ -121,8 +121,8 @@ void CodeViewWidget::Update() for (int i = 0; i < rowCount(); i++) { - u32 addr = m_address - ((rowCount() / 2) * 4) + i * 4; - u32 color = PowerPC::debug_interface.GetColor(addr); + const u32 addr = m_address - ((rowCount() / 2) * 4) + i * 4; + const u32 color = PowerPC::debug_interface.GetColor(addr); auto* bp_item = new QTableWidgetItem; auto* addr_item = new QTableWidgetItem(QStringLiteral("%1").arg(addr, 8, 16, QLatin1Char('0')));