[Cheats] Add boilerplate

This commit is contained in:
wheremyfoodat 2023-07-19 20:51:45 +03:00
parent 5b4f6ef46c
commit 0904638df0
5 changed files with 42 additions and 2 deletions

24
include/cheats.hpp Normal file
View file

@ -0,0 +1,24 @@
#pragma once
#include <array>
#include <vector>
#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;
public:
ActionReplay();
void addCheat(const Cheat& cheat);
void runCheats();
void reset();
};

View file

@ -7,6 +7,7 @@
#include <optional>
#include "PICA/gpu.hpp"
#include "cheats.hpp"
#include "config.hpp"
#include "cpu.hpp"
#include "crypto/aes_engine.hpp"
@ -31,6 +32,7 @@ class Emulator {
Memory memory;
Kernel kernel;
Crypto::AESEngine aesEngine;
ActionReplay cheats;
SDL_Window* window;
@ -41,6 +43,9 @@ class Emulator {
SDL_GameController* gameController = nullptr;
int gameControllerID;
// Shows whether we've loaded any action replay codes
bool haveCheats = false;
// Variables to keep track of whether the user is controlling the 3DS analog stick with their keyboard
// This is done so when a gamepad is connected, we won't automatically override the 3DS analog stick settings with the gamepad's state
// And so the user can still use the keyboard to control the analog