[cheats] add runtime cheats toggles with master code support (#4334)

add per-cheat runtime toggles (thread-safe).
add master code handling (master code cannot be disabled, as noted in Atmosphere's implementation).
add configurable global / per-game initial states for cheat entries.
remove fixed opcode limits and do some fixes to text parsing / file loading.
do not run debug log while cheat logging is not enabled, to reduce performance impacts.
update the `Using Cheats` document to reflect the changes.

- [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions).
- [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md)
- [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability.

-------------------

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4334
Reviewed-by: lizzie <lizzie@eden-emu.dev>
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Reviewed-by: John <john@eden-emu.dev>
This commit is contained in:
Soar Qin
2026-10-30 03:47:38 +01:00
committed by crueter
parent b4d5760014
commit 69665063a9
24 changed files with 365 additions and 55 deletions
+5
View File
@@ -9,6 +9,7 @@
#include <atomic>
#include <chrono>
#include <memory>
#include <mutex>
#include <vector>
#include "common/common_types.h"
#include "core/memory/dmnt_cheat_types.h"
@@ -41,6 +42,7 @@ public:
void ResumeProcess() override;
void DebugLog(u8 id, u64 value) override;
void CommandLog(std::string_view data) override;
[[nodiscard]] bool IsCommandLogEnabled() const override;
private:
bool IsAddressInRange(VAddr address) const;
@@ -81,6 +83,8 @@ public:
void SetMainMemoryParameters(VAddr main_region_begin, u64 main_region_size);
void Reload(std::vector<CheatEntry> reload_cheats);
[[nodiscard]] std::vector<RuntimeCheatInfo> GetCheats() const;
bool SetCheatEnabled(u32 cheat_id, bool enabled);
private:
void FrameCallback(std::chrono::nanoseconds ns_late);
@@ -89,6 +93,7 @@ private:
CheatProcessMetadata metadata;
std::vector<CheatEntry> cheats;
mutable std::mutex cheats_mutex;
std::atomic_bool is_pending_reload{false};
std::shared_ptr<Core::Timing::EventType> event;