diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-01-09 18:41:28 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-09 18:41:28 +0100 |
| commit | 653e0ccf280768e8474952767ee4da06b7e9b607 (patch) | |
| tree | 1a73b75401b7d663306159314d1bdf023736e094 /Source/Core/Common | |
| parent | 21c29bad6bcb7b3750818e0a3417b96def28c4f0 (diff) | |
| parent | 993d2ab173f0e262465b4420e5746bb55a2c9ff1 (diff) | |
Merge pull request #11365 from iwubcode/cheat_manager_freeze_value
DolphinQt: add ability to lock / freeze values in the watches window
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/Debug/MemoryPatches.cpp | 21 | ||||
| -rw-r--r-- | Source/Core/Common/Debug/MemoryPatches.h | 11 | ||||
| -rw-r--r-- | Source/Core/Common/Debug/Watches.cpp | 5 | ||||
| -rw-r--r-- | Source/Core/Common/Debug/Watches.h | 2 | ||||
| -rw-r--r-- | Source/Core/Common/DebugInterface.h | 4 |
5 files changed, 43 insertions, 0 deletions
diff --git a/Source/Core/Common/Debug/MemoryPatches.cpp b/Source/Core/Common/Debug/MemoryPatches.cpp index 8dd9b5716d..f48e6e5bb5 100644 --- a/Source/Core/Common/Debug/MemoryPatches.cpp +++ b/Source/Core/Common/Debug/MemoryPatches.cpp @@ -38,6 +38,23 @@ void MemoryPatches::SetPatch(u32 address, std::vector<u8> value) Patch(index); } +void MemoryPatches::SetFramePatch(u32 address, u32 value) +{ + const std::size_t index = m_patches.size(); + m_patches.emplace_back(address, value); + m_patches.back().type = MemoryPatch::ApplyType::EachFrame; + Patch(index); +} + +void MemoryPatches::SetFramePatch(u32 address, std::vector<u8> value) +{ + UnsetPatch(address); + const std::size_t index = m_patches.size(); + m_patches.emplace_back(address, std::move(value)); + m_patches.back().type = MemoryPatch::ApplyType::EachFrame; + Patch(index); +} + const std::vector<MemoryPatch>& MemoryPatches::GetPatches() const { return m_patches; @@ -81,6 +98,7 @@ bool MemoryPatches::HasEnabledPatch(u32 address) const void MemoryPatches::RemovePatch(std::size_t index) { DisablePatch(index); + UnPatch(index); m_patches.erase(m_patches.begin() + index); } @@ -88,7 +106,10 @@ void MemoryPatches::ClearPatches() { const std::size_t size = m_patches.size(); for (std::size_t index = 0; index < size; ++index) + { DisablePatch(index); + UnPatch(index); + } m_patches.clear(); } } // namespace Common::Debug diff --git a/Source/Core/Common/Debug/MemoryPatches.h b/Source/Core/Common/Debug/MemoryPatches.h index abf88b0499..2a4f902dcd 100644 --- a/Source/Core/Common/Debug/MemoryPatches.h +++ b/Source/Core/Common/Debug/MemoryPatches.h @@ -19,12 +19,19 @@ struct MemoryPatch Disabled }; + enum class ApplyType + { + Once, + EachFrame + }; + MemoryPatch(u32 address_, std::vector<u8> value_); MemoryPatch(u32 address_, u32 value_); u32 address; std::vector<u8> value; State is_enabled = State::Enabled; + ApplyType type = ApplyType::Once; }; class MemoryPatches @@ -35,6 +42,8 @@ public: void SetPatch(u32 address, u32 value); void SetPatch(u32 address, std::vector<u8> value); + void SetFramePatch(u32 address, u32 value); + void SetFramePatch(u32 address, std::vector<u8> value); const std::vector<MemoryPatch>& GetPatches() const; void UnsetPatch(u32 address); void EnablePatch(std::size_t index); @@ -42,9 +51,11 @@ public: bool HasEnabledPatch(u32 address) const; void RemovePatch(std::size_t index); void ClearPatches(); + virtual void ApplyExistingPatch(std::size_t index) = 0; protected: virtual void Patch(std::size_t index) = 0; + virtual void UnPatch(std::size_t index) = 0; std::vector<MemoryPatch> m_patches; }; diff --git a/Source/Core/Common/Debug/Watches.cpp b/Source/Core/Common/Debug/Watches.cpp index 0088c8f26a..dddb3f3435 100644 --- a/Source/Core/Common/Debug/Watches.cpp +++ b/Source/Core/Common/Debug/Watches.cpp @@ -62,6 +62,11 @@ void Watches::UpdateWatchName(std::size_t index, std::string name) m_watches[index].name = std::move(name); } +void Watches::UpdateWatchLockedState(std::size_t index, bool locked) +{ + m_watches[index].locked = locked; +} + void Watches::EnableWatch(std::size_t index) { m_watches[index].is_enabled = Watch::State::Enabled; diff --git a/Source/Core/Common/Debug/Watches.h b/Source/Core/Common/Debug/Watches.h index 9cb7e3e76d..fc16adb826 100644 --- a/Source/Core/Common/Debug/Watches.h +++ b/Source/Core/Common/Debug/Watches.h @@ -22,6 +22,7 @@ struct Watch u32 address; std::string name; State is_enabled; + bool locked = false; Watch(u32 address, std::string name, State is_enabled); }; @@ -36,6 +37,7 @@ public: void UpdateWatch(std::size_t index, u32 address, std::string name); void UpdateWatchAddress(std::size_t index, u32 address); void UpdateWatchName(std::size_t index, std::string name); + void UpdateWatchLockedState(std::size_t index, bool locked); void EnableWatch(std::size_t index); void DisableWatch(std::size_t index); bool HasEnabledWatch(u32 address) const; diff --git a/Source/Core/Common/DebugInterface.h b/Source/Core/Common/DebugInterface.h index a59ac79f69..17c10a1894 100644 --- a/Source/Core/Common/DebugInterface.h +++ b/Source/Core/Common/DebugInterface.h @@ -32,6 +32,7 @@ public: virtual void UpdateWatch(std::size_t index, u32 address, std::string name) = 0; virtual void UpdateWatchAddress(std::size_t index, u32 address) = 0; virtual void UpdateWatchName(std::size_t index, std::string name) = 0; + virtual void UpdateWatchLockedState(std::size_t index, bool locked) = 0; virtual void EnableWatch(std::size_t index) = 0; virtual void DisableWatch(std::size_t index) = 0; virtual bool HasEnabledWatch(u32 address) const = 0; @@ -43,6 +44,8 @@ public: // Memory Patches virtual void SetPatch(u32 address, u32 value) = 0; virtual void SetPatch(u32 address, std::vector<u8> value) = 0; + virtual void SetFramePatch(u32 address, u32 value) = 0; + virtual void SetFramePatch(u32 address, std::vector<u8> value) = 0; virtual const std::vector<Debug::MemoryPatch>& GetPatches() const = 0; virtual void UnsetPatch(u32 address) = 0; virtual void EnablePatch(std::size_t index) = 0; @@ -50,6 +53,7 @@ public: virtual bool HasEnabledPatch(u32 address) const = 0; virtual void RemovePatch(std::size_t index) = 0; virtual void ClearPatches() = 0; + virtual void ApplyExistingPatch(std::size_t index) = 0; // Threads virtual Debug::Threads GetThreads() const = 0; |
