diff options
| author | iwubcode <iwubcode@users.noreply.github.com> | 2022-12-22 17:38:08 -0600 |
|---|---|---|
| committer | iwubcode <iwubcode@users.noreply.github.com> | 2022-12-23 03:13:03 -0600 |
| commit | 2f2f906bf567ab6d89e10161c62404a1dcd8ee1e (patch) | |
| tree | 77b12d8f1e41da6d104e69db8802f01e8cd2913a /Source/Core/Common/Debug | |
| parent | 1f87bcd202697299d6ca9a2e17a6ce633bffbb6d (diff) | |
Core: add ability to add memory patches to the patch engine that will be executed each frame
Diffstat (limited to 'Source/Core/Common/Debug')
| -rw-r--r-- | Source/Core/Common/Debug/MemoryPatches.cpp | 21 | ||||
| -rw-r--r-- | Source/Core/Common/Debug/MemoryPatches.h | 10 |
2 files changed, 31 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 634382f3b3..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); @@ -46,6 +55,7 @@ public: protected: virtual void Patch(std::size_t index) = 0; + virtual void UnPatch(std::size_t index) = 0; std::vector<MemoryPatch> m_patches; }; |
