Core: add ability to add memory patches to the patch engine that will be executed each frame

This commit is contained in:
iwubcode
2022-12-22 17:38:08 -06:00
parent 1f87bcd202
commit 2f2f906bf5
5 changed files with 60 additions and 1 deletions

View File

@ -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;
};