mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-02-18 11:55:38 +00:00
Cheats: Implement C2/memory copy instruction
This commit is contained in:
parent
6961e645c6
commit
54e13015d8
|
@ -579,6 +579,32 @@ void CheatCode::Apply() const
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
{
|
{
|
||||||
Log_ErrorPrintf("Unhandled instruction code 0x%02X (%08X %08X)", static_cast<u8>(inst.code.GetValue()),
|
Log_ErrorPrintf("Unhandled instruction code 0x%02X (%08X %08X)", static_cast<u8>(inst.code.GetValue()),
|
||||||
|
|
|
@ -24,7 +24,8 @@ struct CheatCode
|
||||||
CompareNotEqual8 = 0xE1,
|
CompareNotEqual8 = 0xE1,
|
||||||
CompareLess8 = 0xE2,
|
CompareLess8 = 0xE2,
|
||||||
CompareGreater8 = 0xE3,
|
CompareGreater8 = 0xE3,
|
||||||
Slide = 0x50
|
Slide = 0x50,
|
||||||
|
MemoryCopy = 0xC2
|
||||||
};
|
};
|
||||||
|
|
||||||
union Instruction
|
union Instruction
|
||||||
|
|
Loading…
Reference in a new issue