Another possible AR cheat system fix.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@865 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
omegadox 2008-10-14 17:13:43 +00:00
parent 0cab388f1c
commit e1ca5de156
1 changed files with 68 additions and 72 deletions

View File

@ -235,9 +235,10 @@ void RunActionReplayCode(const ARCode &code, bool nowIsBootup) {
for (std::vector<AREntry>::const_iterator iter = code.ops.begin(); iter != code.ops.end(); ++iter) { for (std::vector<AREntry>::const_iterator iter = code.ops.begin(); iter != code.ops.end(); ++iter) {
u32 cmd_addr = iter->cmd_addr; u32 cmd_addr = iter->cmd_addr;
u8 cmd = iter->cmd_addr>>24; u8 cmd = iter->cmd_addr>>24;
/*u32 addr = (iter->cmd_addr & 0xFFFFFF);*/ // TODO:(Omega): remove this line if not needed anymore and everything works as is
u32 addr = (iter->cmd_addr & 0x01FFFFFF); u32 addr = (iter->cmd_addr & 0x01FFFFFF);
u32 data = iter->value; u32 data = iter->value;
u8 z = (cmd >> 4);
u8 w = (cmd - ((cmd >> 4) << 4));
if (addr >= 0x00002000 && addr < 0x00003000) { if (addr >= 0x00002000 && addr < 0x00003000) {
PanicAlert("This action replay simulator does not support codes that modify Action Replay itself."); PanicAlert("This action replay simulator does not support codes that modify Action Replay itself.");
@ -269,10 +270,12 @@ void RunActionReplayCode(const ARCode &code, bool nowIsBootup) {
// skip these weird init lines // skip these weird init lines
if (iter == code.ops.begin() && cmd == 1) continue; if (iter == code.ops.begin() && cmd == 1) continue;
// Ram write (and fill), this if for codes 0x00XXXXXXX - 0x07XXXXXXX // 0x4WXXXXXXX codes
if((cmd & 0xFE) < 0x8) if(z == 0x00) // Check the value Z in 0xZWXXXXXXX
{
// Ram write (and fill), this is for codes 0x00XXXXXXX - 0x07XXXXXXX
if(w < 0x8) // Check the value W in 0xZWXXXXXXX
{ {
//u32 new_addr = ((cmd_addr & 0x01FFFFFF) | 0x80000000); // TODO:(Omega): remove this line if not needed anymore and everything works as is
u32 new_addr = (addr | 0x80000000); u32 new_addr = (addr | 0x80000000);
switch ((new_addr >> 25) & 0x03) switch ((new_addr >> 25) & 0x03)
{ {
@ -304,32 +307,47 @@ void RunActionReplayCode(const ARCode &code, bool nowIsBootup) {
} }
continue; continue;
} }
}
// TODO(Omega): This commented code is here for my next fix // 0x4WXXXXXXX codes
//case 0x40: // Write byte to pointer. if(z == 0x4) // Check the value Z in 0xZWXXXXXXX
//{ {
// u32 ptr = Memory::Read_U32(addr); // Write to pointer, this is for codes 0x40XXXXXXX - 0x44XXXXXXX
// u8 thebyte = data & 0xFF; if(w < 0x8) // Check the value W in 0xZWXXXXXXX
// u32 offset = data >> 8; {
// Memory::Write_U8(thebyte, ptr + offset); u32 new_addr = (addr | 0x80000000);
// break; switch ((new_addr >> 25) & 0x03)
//} {
case 0x00: // Byte write to pointer
{
u32 ptr = Memory::Read_U32(new_addr);
u8 thebyte = data & 0xFF;
u32 offset = data >> 8;
Memory::Write_U8(thebyte, ptr + offset);
break;
}
//case 0x42: // Write short to pointer. case 0x01: // Short write to pointer
//{ {
// u32 ptr = Memory::Read_U32(addr); u32 ptr = Memory::Read_U32(new_addr);
// u16 theshort = data & 0xFFFF; u16 theshort = data & 0xFFFF;
// u32 offset = (data >> 16) << 1; u32 offset = (data >> 16) << 1;
// Memory::Write_U16(theshort, ptr + offset); Memory::Write_U16(theshort, ptr + offset);
// break; break;
//} }
//case 0x44: // Write dword to pointer.
//{ case 0x02: // Dword write to pointer
// u32 ptr = Memory::Read_U32(addr); {
// Memory::Write_U32(data, ptr); u32 ptr = Memory::Read_U32(new_addr);
// break; Memory::Write_U32(data, ptr);
//} break;
}
default: break; // TODO(Omega): maybe add a PanicAlert here?
}
continue;
}
}
switch (cmd & 0xFE) switch (cmd & 0xFE)
{ {
@ -409,28 +427,6 @@ void RunActionReplayCode(const ARCode &code, bool nowIsBootup) {
} }
break; break;
} }
case 0x40: // Write byte to pointer.
{
u32 ptr = Memory::Read_U32(addr);
u8 thebyte = data & 0xFF;
u32 offset = data >> 8;
Memory::Write_U8(thebyte, ptr + offset);
break;
}
case 0x42: // Write short to pointer.
{
u32 ptr = Memory::Read_U32(addr);
u16 theshort = data & 0xFFFF;
u32 offset = (data >> 16) << 1;
Memory::Write_U16(theshort, ptr + offset);
break;
}
case 0x44: // Write dword to pointer.
{
u32 ptr = Memory::Read_U32(addr);
Memory::Write_U32(data, ptr);
break;
}
case 0xC4: // "Master Code" - configure the AR case 0xC4: // "Master Code" - configure the AR
{ {
u8 number = data & 0xFF; u8 number = data & 0xFF;