mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
[Cheats] Add boilerplate
This commit is contained in:
parent
5b4f6ef46c
commit
0904638df0
5 changed files with 42 additions and 2 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/httpserver.cpp src/stb_image_write.c src/core/cheats.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
|
||||||
|
@ -149,7 +149,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp
|
||||||
include/result/result_common.hpp include/result/result_fs.hpp include/result/result_fnd.hpp
|
include/result/result_common.hpp include/result/result_fs.hpp include/result/result_fnd.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/config.hpp include/services/ir_user.hpp include/httpserver.hpp include/cheats.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
||||||
|
|
24
include/cheats.hpp
Normal file
24
include/cheats.hpp
Normal 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();
|
||||||
|
};
|
|
@ -7,6 +7,7 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "PICA/gpu.hpp"
|
#include "PICA/gpu.hpp"
|
||||||
|
#include "cheats.hpp"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "cpu.hpp"
|
#include "cpu.hpp"
|
||||||
#include "crypto/aes_engine.hpp"
|
#include "crypto/aes_engine.hpp"
|
||||||
|
@ -31,6 +32,7 @@ class Emulator {
|
||||||
Memory memory;
|
Memory memory;
|
||||||
Kernel kernel;
|
Kernel kernel;
|
||||||
Crypto::AESEngine aesEngine;
|
Crypto::AESEngine aesEngine;
|
||||||
|
ActionReplay cheats;
|
||||||
|
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
|
|
||||||
|
@ -41,6 +43,9 @@ class Emulator {
|
||||||
SDL_GameController* gameController = nullptr;
|
SDL_GameController* gameController = nullptr;
|
||||||
int gameControllerID;
|
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
|
// 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
|
// 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
|
// And so the user can still use the keyboard to control the analog
|
||||||
|
|
5
src/core/cheats.cpp
Normal file
5
src/core/cheats.cpp
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#include "cheats.hpp"
|
||||||
|
|
||||||
|
ActionReplay::ActionReplay() { reset(); }
|
||||||
|
|
||||||
|
void ActionReplay::reset() { cheats.clear(); }
|
|
@ -76,6 +76,12 @@ void Emulator::reset(ReloadOption reload) {
|
||||||
// Otherwise resetting the kernel or cpu might nuke them
|
// Otherwise resetting the kernel or cpu might nuke them
|
||||||
cpu.setReg(13, VirtualAddrs::StackTop); // Set initial SP
|
cpu.setReg(13, VirtualAddrs::StackTop); // Set initial SP
|
||||||
|
|
||||||
|
// We're resetting without reloading the ROM, so yeet cheats
|
||||||
|
if (reload == ReloadOption::NoReload) {
|
||||||
|
haveCheats = false;
|
||||||
|
cheats.reset();
|
||||||
|
}
|
||||||
|
|
||||||
// If a ROM is active and we reset, with the reload option enabled then reload it.
|
// If a ROM is active and we reset, with the reload option enabled then reload it.
|
||||||
// This is necessary to set up stack, executable memory, .data/.rodata/.bss all over again
|
// This is necessary to set up stack, executable memory, .data/.rodata/.bss all over again
|
||||||
if (reload == ReloadOption::Reload && romType != ROMType::None && romPath.has_value()) {
|
if (reload == ReloadOption::Reload && romType != ROMType::None && romPath.has_value()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue