Better cheat interface
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user