Fixed a bug in AR cheat system, codes starting with 0x00 to 0x07 should work now as I tested this in ZTP and SA2,and most of the codes worked. One code in SA2 breaks dolphin now, and 1 code in ZTP messed up the graphics and breaks the game if trying to load a save game, else most codes work. Also SSMB codes work for me, there are some that might break dolphin, but main codes work. I still recommend more testing of this fix. I will now work on the next fix. =). Also some code cleanup.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@864 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
e26173e6fe
commit
0cab388f1c
|
@ -235,7 +235,8 @@ 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);
|
/*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 data = iter->value;
|
u32 data = iter->value;
|
||||||
|
|
||||||
if (addr >= 0x00002000 && addr < 0x00003000) {
|
if (addr >= 0x00002000 && addr < 0x00003000) {
|
||||||
|
@ -266,32 +267,72 @@ void RunActionReplayCode(const ARCode &code, bool nowIsBootup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip these weird init lines
|
// skip these weird init lines
|
||||||
if (iter == code.ops.begin() && cmd == 1)
|
if (iter == code.ops.begin() && cmd == 1) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
switch (cmd & 0xFE) {
|
// Ram write (and fill), this if for codes 0x00XXXXXXX - 0x07XXXXXXX
|
||||||
|
if((cmd & 0xFE) < 0x8)
|
||||||
|
{
|
||||||
|
//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);
|
||||||
|
switch ((new_addr >> 25) & 0x03)
|
||||||
|
{
|
||||||
case 0x00: // Byte write
|
case 0x00: // Byte write
|
||||||
{
|
{
|
||||||
u8 repeat = data >> 8;
|
u8 repeat = data >> 8;
|
||||||
for (int i = 0; i <= repeat; i++) {
|
for (int i = 0; i <= repeat; i++) {
|
||||||
Memory::Write_U8(data & 0xFF, addr + i);
|
Memory::Write_U8(data & 0xFF, new_addr + i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x02: // Short write
|
case 0x01: // Short write
|
||||||
{
|
{
|
||||||
u16 repeat = data >> 16;
|
u16 repeat = data >> 16;
|
||||||
for (int i = 0; i <= repeat; i++) {
|
for (int i = 0; i <= repeat; i++) {
|
||||||
Memory::Write_U16(data & 0xFFFF, addr + i * 2);
|
Memory::Write_U16(data & 0xFFFF, new_addr + i * 2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x04: // Dword write
|
|
||||||
Memory::Write_U32(data, addr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
case 0x02: // Dword write
|
||||||
|
{
|
||||||
|
Memory::Write_U32(data, new_addr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: break; // TODO(Omega): maybe add a PanicAlert here?
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(Omega): This commented code is here for my next fix
|
||||||
|
//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;
|
||||||
|
//}
|
||||||
|
|
||||||
|
switch (cmd & 0xFE)
|
||||||
|
{
|
||||||
case 0x80: // Byte add
|
case 0x80: // Byte add
|
||||||
Memory::Write_U8(Memory::Read_U8(addr) + (data & 0xFF), addr);
|
Memory::Write_U8(Memory::Read_U8(addr) + (data & 0xFF), addr);
|
||||||
break;
|
break;
|
||||||
|
@ -311,61 +352,63 @@ void RunActionReplayCode(const ARCode &code, bool nowIsBootup) {
|
||||||
d.u = data;
|
d.u = data;
|
||||||
fu.f += data;
|
fu.f += data;
|
||||||
Memory::Write_U32(fu.u, addr);
|
Memory::Write_U32(fu.u, addr);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 0x90: // IF 32 bit equal, exit
|
case 0x90: if (Memory::Read_U32(addr) == data) return; // IF 32 bit equal, exit
|
||||||
if (Memory::Read_U32(addr) == data)
|
|
||||||
return;
|
|
||||||
|
|
||||||
case 0x08: // IF 8 bit equal, execute next opcode
|
case 0x08: // IF 8 bit equal, execute next opcode
|
||||||
case 0x48: // (double)
|
case 0x48: // (double)
|
||||||
|
{
|
||||||
if (Memory::Read_U16(addr) != (data & 0xFFFF)) {
|
if (Memory::Read_U16(addr) != (data & 0xFFFF)) {
|
||||||
if (++iter == code.ops.end()) return;
|
if (++iter == code.ops.end()) return;
|
||||||
if (cmd == 0x48) if (++iter == code.ops.end()) return;
|
if (cmd == 0x48) if (++iter == code.ops.end()) return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 0x0A: // IF 16 bit equal, execute next opcode
|
case 0x0A: // IF 16 bit equal, execute next opcode
|
||||||
case 0x4A: // (double)
|
case 0x4A: // (double)
|
||||||
|
{
|
||||||
if (Memory::Read_U16(addr) != (data & 0xFFFF)) {
|
if (Memory::Read_U16(addr) != (data & 0xFFFF)) {
|
||||||
if (++iter == code.ops.end()) return;
|
if (++iter == code.ops.end()) return;
|
||||||
if (cmd == 0x4A) if (++iter == code.ops.end()) return;
|
if (cmd == 0x4A) if (++iter == code.ops.end()) return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 0x0C: // IF 32 bit equal, execute next opcode
|
case 0x0C: // IF 32 bit equal, execute next opcode
|
||||||
case 0x4C: // (double)
|
case 0x4C: // (double)
|
||||||
|
{
|
||||||
if (Memory::Read_U32(addr) != data) {
|
if (Memory::Read_U32(addr) != data) {
|
||||||
if (++iter == code.ops.end()) return;
|
if (++iter == code.ops.end()) return;
|
||||||
if (cmd == 0x4C) if (++iter == code.ops.end()) return;
|
if (cmd == 0x4C) if (++iter == code.ops.end()) return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 0x10: // IF NOT 8 bit equal, execute next opcode
|
case 0x10: // IF NOT 8 bit equal, execute next opcode
|
||||||
case 0x50: // (double)
|
case 0x50: // (double)
|
||||||
|
{
|
||||||
if (Memory::Read_U8(addr) == (data & 0xFF)) {
|
if (Memory::Read_U8(addr) == (data & 0xFF)) {
|
||||||
if (++iter == code.ops.end()) return;
|
if (++iter == code.ops.end()) return;
|
||||||
if (cmd == 0x50) if (++iter == code.ops.end()) return;
|
if (cmd == 0x50) if (++iter == code.ops.end()) return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 0x12: // IF NOT 16 bit equal, execute next opcode
|
case 0x12: // IF NOT 16 bit equal, execute next opcode
|
||||||
case 0x52: // (double)
|
case 0x52: // (double)
|
||||||
|
{
|
||||||
if (Memory::Read_U16(addr) == (data & 0xFFFF)) {
|
if (Memory::Read_U16(addr) == (data & 0xFFFF)) {
|
||||||
if (++iter == code.ops.end()) return;
|
if (++iter == code.ops.end()) return;
|
||||||
if (cmd == 0x52) if (++iter == code.ops.end()) return;
|
if (cmd == 0x52) if (++iter == code.ops.end()) return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 0x14: // IF NOT 32 bit equal, execute next opcode
|
case 0x14: // IF NOT 32 bit equal, execute next opcode
|
||||||
case 0x54: // (double)
|
case 0x54: // (double)
|
||||||
|
{
|
||||||
if (Memory::Read_U32(addr) == data) {
|
if (Memory::Read_U32(addr) == data) {
|
||||||
if (++iter == code.ops.end()) return;
|
if (++iter == code.ops.end()) return;
|
||||||
if (cmd == 0x54) if (++iter == code.ops.end()) return;
|
if (cmd == 0x54) if (++iter == code.ops.end()) return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 0x40: // Write byte to pointer.
|
case 0x40: // Write byte to pointer.
|
||||||
{
|
{
|
||||||
u32 ptr = Memory::Read_U32(addr);
|
u32 ptr = Memory::Read_U32(addr);
|
||||||
|
@ -374,7 +417,6 @@ void RunActionReplayCode(const ARCode &code, bool nowIsBootup) {
|
||||||
Memory::Write_U8(thebyte, ptr + offset);
|
Memory::Write_U8(thebyte, ptr + offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x42: // Write short to pointer.
|
case 0x42: // Write short to pointer.
|
||||||
{
|
{
|
||||||
u32 ptr = Memory::Read_U32(addr);
|
u32 ptr = Memory::Read_U32(addr);
|
||||||
|
@ -383,16 +425,13 @@ void RunActionReplayCode(const ARCode &code, bool nowIsBootup) {
|
||||||
Memory::Write_U16(theshort, ptr + offset);
|
Memory::Write_U16(theshort, ptr + offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x44: // Write dword to pointer.
|
case 0x44: // Write dword to pointer.
|
||||||
{
|
{
|
||||||
u32 ptr = Memory::Read_U32(addr);
|
u32 ptr = Memory::Read_U32(addr);
|
||||||
Memory::Write_U32(data, ptr);
|
Memory::Write_U32(data, ptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 0xC4: // "Master Code" - configure the AR
|
||||||
case 0xC4:
|
|
||||||
// "Master Code" - configure the AR
|
|
||||||
{
|
{
|
||||||
u8 number = data & 0xFF;
|
u8 number = data & 0xFF;
|
||||||
if (number == 0)
|
if (number == 0)
|
||||||
|
@ -403,11 +442,9 @@ void RunActionReplayCode(const ARCode &code, bool nowIsBootup) {
|
||||||
}
|
}
|
||||||
// u8 numOpsPerFrame = (data >> 8) & 0xFF;
|
// u8 numOpsPerFrame = (data >> 8) & 0xFF;
|
||||||
// Blah, we generally ignore master codes.
|
// Blah, we generally ignore master codes.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
default: PanicAlert("Unknown Action Replay command %02x (%08x %08x)", cmd, iter->cmd_addr, iter->value); break;
|
||||||
default:
|
|
||||||
PanicAlert("Unknown Action Replay command %02x (%08x %08x)", cmd, iter->cmd_addr, iter->value);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue