mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
[Cheats] Split gateway and AR
This commit is contained in:
parent
0904638df0
commit
ae69c8f8c4
5 changed files with 78 additions and 16 deletions
|
@ -96,7 +96,7 @@ endif()
|
||||||
set(SOURCE_FILES src/main.cpp src/emulator.cpp src/io_file.cpp src/config.cpp
|
set(SOURCE_FILES src/main.cpp src/emulator.cpp src/io_file.cpp src/config.cpp
|
||||||
src/core/CPU/cpu_dynarmic.cpp src/core/CPU/dynarmic_cycles.cpp
|
src/core/CPU/cpu_dynarmic.cpp src/core/CPU/dynarmic_cycles.cpp
|
||||||
src/core/memory.cpp src/renderer.cpp src/core/renderer_null/renderer_null.cpp
|
src/core/memory.cpp src/renderer.cpp src/core/renderer_null/renderer_null.cpp
|
||||||
src/httpserver.cpp src/stb_image_write.c src/core/cheats.cpp
|
src/httpserver.cpp src/stb_image_write.c src/core/cheats.cpp src/core/action_replay.cpp
|
||||||
)
|
)
|
||||||
set(CRYPTO_SOURCE_FILES src/core/crypto/aes_engine.cpp)
|
set(CRYPTO_SOURCE_FILES src/core/crypto/aes_engine.cpp)
|
||||||
set(KERNEL_SOURCE_FILES src/core/kernel/kernel.cpp src/core/kernel/resource_limits.cpp
|
set(KERNEL_SOURCE_FILES src/core/kernel/kernel.cpp src/core/kernel/resource_limits.cpp
|
||||||
|
@ -150,6 +150,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp
|
||||||
include/result/result_gsp.hpp include/result/result_kernel.hpp include/result/result_os.hpp
|
include/result/result_gsp.hpp include/result/result_kernel.hpp include/result/result_os.hpp
|
||||||
include/crypto/aes_engine.hpp include/metaprogramming.hpp include/PICA/pica_vertex.hpp
|
include/crypto/aes_engine.hpp include/metaprogramming.hpp include/PICA/pica_vertex.hpp
|
||||||
include/config.hpp include/services/ir_user.hpp include/httpserver.hpp include/cheats.hpp
|
include/config.hpp include/services/ir_user.hpp include/httpserver.hpp include/cheats.hpp
|
||||||
|
include/action_replay.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
||||||
|
|
22
include/action_replay.hpp
Normal file
22
include/action_replay.hpp
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#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
|
||||||
|
|
||||||
|
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 runCheat(const Cheat& cheat);
|
||||||
|
void reset();
|
||||||
|
};
|
|
@ -2,23 +2,27 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "action_replay.hpp"
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
|
|
||||||
class ActionReplay {
|
class Cheats {
|
||||||
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:
|
public:
|
||||||
ActionReplay();
|
enum class CheatType {
|
||||||
|
ActionReplay, // CTRPF cheats
|
||||||
|
Gateway,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Cheat {
|
||||||
|
CheatType type;
|
||||||
|
std::vector<u32> instructions;
|
||||||
|
};
|
||||||
|
|
||||||
|
Cheats();
|
||||||
void addCheat(const Cheat& cheat);
|
void addCheat(const Cheat& cheat);
|
||||||
void runCheats();
|
void runCheats();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ActionReplay ar; // An ActionReplay cheat machine for executing CTRPF codes
|
||||||
|
std::vector<Cheat> cheats;
|
||||||
};
|
};
|
14
src/core/action_replay.cpp
Normal file
14
src/core/action_replay.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#include "action_replay.hpp"
|
||||||
|
|
||||||
|
ActionReplay::ActionReplay() { reset(); }
|
||||||
|
|
||||||
|
void ActionReplay::reset() {
|
||||||
|
// Default value of storage regs is 0
|
||||||
|
storage1 = 0;
|
||||||
|
storage2 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActionReplay::runCheat(const Cheat& cheat) {
|
||||||
|
// Set offset and data registers to 0 at the start of a cheat
|
||||||
|
data1 = data2 = offset1 = offset2 = 0;
|
||||||
|
}
|
|
@ -1,5 +1,26 @@
|
||||||
#include "cheats.hpp"
|
#include "cheats.hpp"
|
||||||
|
|
||||||
ActionReplay::ActionReplay() { reset(); }
|
Cheats::Cheats() { reset(); }
|
||||||
|
|
||||||
void ActionReplay::reset() { cheats.clear(); }
|
void Cheats::reset() {
|
||||||
|
cheats.clear(); // Unload loaded cheats
|
||||||
|
ar.reset(); // Reset AR boi
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cheats::runCheats() {
|
||||||
|
for (const Cheat& cheat : cheats) {
|
||||||
|
switch (cheat.type) {
|
||||||
|
case CheatType::ActionReplay: {
|
||||||
|
ar.runCheat(cheat.instructions);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case CheatType::Gateway: {
|
||||||
|
Helpers::panic("Gateway cheats not supported yet! Only Action Replay is supported!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: Helpers::panic("Unknown cheat type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue