mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-20 14:01:44 +12:00
Get our first AR code running
This commit is contained in:
parent
ae69c8f8c4
commit
97f8ea6cfd
6 changed files with 110 additions and 23 deletions
|
@ -3,9 +3,10 @@
|
|||
#include <vector>
|
||||
|
||||
#include "helpers.hpp"
|
||||
#include "memory.hpp"
|
||||
|
||||
class ActionReplay {
|
||||
using Cheat = std::vector<u32>; // A cheat is really just a bunch of u32 opcodes
|
||||
using Cheat = std::vector<u32>; // A cheat is really just a bunch of 64-bit opcodes neatly encoded into 32-bit chunks
|
||||
|
||||
u32 offset1, offset2; // Memory offset registers. Non-persistent.
|
||||
u32 data1, data2; // Data offset registers. Non-persistent.
|
||||
|
@ -14,9 +15,29 @@ class ActionReplay {
|
|||
// 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;
|
||||
|
||||
// Program counter
|
||||
u32 pc = 0;
|
||||
Memory& mem;
|
||||
|
||||
// Has the cheat ended?
|
||||
bool running = false;
|
||||
// Run 1 AR instruction
|
||||
void runInstruction(const Cheat& cheat, u32 instruction);
|
||||
|
||||
// Action Replay has a billion D-type opcodes so this handles all of them
|
||||
void executeDType(const Cheat& cheat, u32 instruction);
|
||||
|
||||
u8 read8(u32 addr);
|
||||
u16 read16(u32 addr);
|
||||
u32 read32(u32 addr);
|
||||
|
||||
void write8(u32 addr, u8 value);
|
||||
void write16(u32 addr, u16 value);
|
||||
void write32(u32 addr, u32 value);
|
||||
|
||||
public:
|
||||
ActionReplay();
|
||||
ActionReplay(Memory& mem);
|
||||
void runCheat(const Cheat& cheat);
|
||||
void reset();
|
||||
};
|
|
@ -5,6 +5,9 @@
|
|||
#include "action_replay.hpp"
|
||||
#include "helpers.hpp"
|
||||
|
||||
// Forward-declare this since it's just passed and we don't want to include memory.hpp and increase compile time
|
||||
class Memory;
|
||||
|
||||
class Cheats {
|
||||
public:
|
||||
enum class CheatType {
|
||||
|
@ -17,10 +20,10 @@ class Cheats {
|
|||
std::vector<u32> instructions;
|
||||
};
|
||||
|
||||
Cheats();
|
||||
Cheats(Memory& mem);
|
||||
void addCheat(const Cheat& cheat);
|
||||
void runCheats();
|
||||
void reset();
|
||||
void run();
|
||||
|
||||
private:
|
||||
ActionReplay ar; // An ActionReplay cheat machine for executing CTRPF codes
|
||||
|
|
|
@ -32,7 +32,7 @@ class Emulator {
|
|||
Memory memory;
|
||||
Kernel kernel;
|
||||
Crypto::AESEngine aesEngine;
|
||||
ActionReplay cheats;
|
||||
Cheats cheats;
|
||||
|
||||
SDL_Window* window;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue