[Cheats] Split gateway and AR

This commit is contained in:
wheremyfoodat 2023-07-19 21:09:44 +03:00
parent 0904638df0
commit ae69c8f8c4
5 changed files with 78 additions and 16 deletions
include

View file

@ -2,23 +2,27 @@
#include <array>
#include <vector>
#include "action_replay.hpp"
#include "helpers.hpp"
class ActionReplay {
using Cheat = std::vector<u32>; // A cheat is really just a bunch of u32 opcodes
std::vector<Cheat> cheats;
u32 offset1, offset2; // Memory offset registers. Non-persistent.
u32 data1, data2; // Data offset registers. Non-persistent.
u32 storage1, storage2; // Storage registers. Persistent.
// When an instruction does not specify which offset or data register to use, we use the "active" one
// Which is by default #1 and may be changed by certain AR operations
u32 *activeOffset, *activeData;
class Cheats {
public:
ActionReplay();
enum class CheatType {
ActionReplay, // CTRPF cheats
Gateway,
};
struct Cheat {
CheatType type;
std::vector<u32> instructions;
};
Cheats();
void addCheat(const Cheat& cheat);
void runCheats();
void reset();
private:
ActionReplay ar; // An ActionReplay cheat machine for executing CTRPF codes
std::vector<Cheat> cheats;
};