ActionReplay: Fix implementation of memory-copy zero codes

This fixes the implementation of the non-standard size-3 zero codes to
conform to kenobi's specification.
This commit is contained in:
Vladimir Panteleev 2017-10-06 12:32:24 +00:00
parent 5f0de43828
commit e691ec126f
No known key found for this signature in database
GPG Key ID: 5004F0FAD051576D
1 changed files with 12 additions and 6 deletions

View File

@ -586,10 +586,12 @@ static bool ZeroCode_FillAndSlide(const u32 val_last, const ARAddr& addr, const
return true;
}
// Looks like this is new?? - untested
// kenobi's "memory copy" Z-code. Requires an additional master code
// on a real AR device. Documented here:
// https://github.com/dolphin-emu/dolphin/wiki/GameCube-Action-Replay-Code-Types#type-z4-size-3--memory-copy
static bool ZeroCode_MemoryCopy(const u32 val_last, const ARAddr& addr, const u32 data)
{
const u32 addr_dest = val_last | 0x06000000;
const u32 addr_dest = val_last & ~0x06000000;
const u32 addr_src = addr.GCAddress();
const u8 num_bytes = data & 0x7FFF;
@ -598,16 +600,20 @@ static bool ZeroCode_MemoryCopy(const u32 val_last, const ARAddr& addr, const u3
LogInfo("Src Address: %08x", addr_src);
LogInfo("Size: %08x", num_bytes);
if ((data & ~0x7FFF) == 0x0000)
if ((data & 0xFF0000) == 0)
{
if ((data >> 24) != 0x0)
{ // Memory Copy With Pointers Support
LogInfo("Memory Copy With Pointers Support");
LogInfo("--------");
for (int i = 0; i < 138; ++i)
const u32 ptr_dest = PowerPC::HostRead_U32(addr_dest);
LogInfo("Resolved Dest Address to: %08x", ptr_dest);
const u32 ptr_src = PowerPC::HostRead_U32(addr_src);
LogInfo("Resolved Src Address to: %08x", ptr_src);
for (int i = 0; i < num_bytes; ++i)
{
PowerPC::HostWrite_U8(PowerPC::HostRead_U8(addr_src + i), addr_dest + i);
LogInfo("Wrote %08x to address %08x", PowerPC::HostRead_U8(addr_src + i), addr_dest + i);
PowerPC::HostWrite_U8(PowerPC::HostRead_U8(ptr_src + i), ptr_dest + i);
LogInfo("Wrote %08x to address %08x", PowerPC::HostRead_U8(ptr_src + i), ptr_dest + i);
}
LogInfo("--------");
}