mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-11 08:39:48 +12:00
Better cheat interface
This commit is contained in:
parent
9ad34dd6c9
commit
eef87da979
4 changed files with 17 additions and 8 deletions
|
@ -26,7 +26,11 @@ class Cheats {
|
|||
void reset();
|
||||
void run();
|
||||
|
||||
void clear();
|
||||
bool haveCheats() const { return cheatsLoaded; }
|
||||
|
||||
private:
|
||||
ActionReplay ar; // An ActionReplay cheat machine for executing CTRPF codes
|
||||
std::vector<Cheat> cheats;
|
||||
bool cheatsLoaded = false;
|
||||
};
|
|
@ -43,9 +43,6 @@ 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
|
||||
|
|
|
@ -3,11 +3,19 @@
|
|||
Cheats::Cheats(Memory& mem, HIDService& hid) : ar(mem, hid) { reset(); }
|
||||
|
||||
void Cheats::reset() {
|
||||
cheats.clear(); // Unload loaded cheats
|
||||
ar.reset(); // Reset ActionReplay
|
||||
clear(); // Clear loaded cheats
|
||||
ar.reset(); // Reset ActionReplay
|
||||
}
|
||||
|
||||
void Cheats::addCheat(const Cheat& cheat) { cheats.push_back(cheat); }
|
||||
void Cheats::addCheat(const Cheat& cheat) {
|
||||
cheats.push_back(cheat);
|
||||
cheatsLoaded = true;
|
||||
}
|
||||
|
||||
void Cheats::clear() {
|
||||
cheats.clear();
|
||||
cheatsLoaded = false;
|
||||
}
|
||||
|
||||
void Cheats::run() {
|
||||
for (const Cheat& cheat : cheats) {
|
||||
|
|
|
@ -93,7 +93,6 @@ void Emulator::reset(ReloadOption reload) {
|
|||
|
||||
// We're resetting without reloading the ROM, so yeet cheats
|
||||
if (reload == ReloadOption::NoReload) {
|
||||
haveCheats = false;
|
||||
cheats.reset();
|
||||
}
|
||||
|
||||
|
@ -357,7 +356,8 @@ void Emulator::runFrame() {
|
|||
srv.sendGPUInterrupt(GPUInterrupt::VBlank0);
|
||||
srv.sendGPUInterrupt(GPUInterrupt::VBlank1);
|
||||
|
||||
if (haveCheats) [[unlikely]] {
|
||||
// Run cheats if any are loaded
|
||||
if (cheats.haveCheats()) [[unlikely]] {
|
||||
cheats.run();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue