From b691388e625c4d635f48f9a964920f4cd9608367 Mon Sep 17 00:00:00 2001 From: PugsyMAME <18102600+PugsyMAME@users.noreply.github.com> Date: Sun, 10 Nov 2024 00:07:23 +0000 Subject: [PATCH] Added Cheat Type A8 Added cheat type A8 which is the byte equivalent of the A7 cheat type as there will be a need of this type. --- src/core/cheats.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/core/cheats.cpp b/src/core/cheats.cpp index e4172aaf4..61e69b75d 100644 --- a/src/core/cheats.cpp +++ b/src/core/cheats.cpp @@ -1817,6 +1817,7 @@ private: ExtDecrement32 = 0x61, ExtConstantWriteIfMatch16 = 0xA6, ExtConstantWriteIfMatchWithRestore16 = 0xA7, + ExtConstantWriteIfMatchWithRestore8 = 0xA8, ExtConstantForceRange8 = 0xF0, ExtConstantForceRangeLimits16 = 0xF1, ExtConstantForceRangeRollRound16 = 0xF2, @@ -2359,7 +2360,19 @@ void Cheats::GamesharkCheatCode::Apply() const index++; } break; + + case InstructionCode::ExtConstantWriteIfMatchWithRestore8: + { + const u8 value = DoMemoryRead(inst.address); + const u8 comparevalue = Truncate8(inst.value16 >> 8); + const u8 newvalue = Truncate8(inst.value16 & 0xFFu); + if (value == comparevalue) + DoMemoryWrite(inst.address, newvalue); + index++; + } + break; + case InstructionCode::ExtConstantForceRange8: { const u8 value = DoMemoryRead(inst.address); @@ -3926,6 +3939,18 @@ void Cheats::GamesharkCheatCode::ApplyOnDisable() const } break; + case InstructionCode::ExtConstantWriteIfMatchWithRestore8: + { + const u8 value = DoMemoryRead(inst.address); + const u8 comparevalue = Truncate8(inst.value16 >> 8); + const u8 newvalue = Truncate8(inst.value16 & 0xFFu); + if (value == newvalue) + DoMemoryWrite(inst.address, comparevalue); + + index++; + } + break; + [[unlikely]] default: { ERROR_LOG("Unhandled instruction code 0x{:02X} ({:08X} {:08X})", static_cast(inst.code.GetValue()),