Cheats: Implement C2/memory copy instruction

This commit is contained in:
Connor McLaughlin 2020-09-28 20:24:58 +10:00
parent 6961e645c6
commit 54e13015d8
2 changed files with 28 additions and 1 deletions

View file

@ -579,6 +579,32 @@ void CheatCode::Apply() const
}
break;
case InstructionCode::MemoryCopy:
{
if ((index + 1) >= instructions.size())
{
Log_ErrorPrintf("Incomplete memory copy instruction");
return;
}
const Instruction& inst2 = instructions[index + 1];
const u32 byte_count = inst.value16;
u32 src_address = inst.address;
u32 dst_address = inst2.address;
for (u32 i = 0; i < byte_count; i++)
{
u8 value = 0;
CPU::SafeReadMemoryByte(src_address, &value);
CPU::SafeWriteMemoryByte(dst_address, value);
src_address++;
dst_address++;
}
index += 2;
}
break;
default:
{
Log_ErrorPrintf("Unhandled instruction code 0x%02X (%08X %08X)", static_cast<u8>(inst.code.GetValue()),

View file

@ -24,7 +24,8 @@ struct CheatCode
CompareNotEqual8 = 0xE1,
CompareLess8 = 0xE2,
CompareGreater8 = 0xE3,
Slide = 0x50
Slide = 0x50,
MemoryCopy = 0xC2
};
union Instruction