From 448b0ed6beeb24861c2098c782e7fe150a69616b Mon Sep 17 00:00:00 2001 From: LegendOfDragoon Date: Thu, 22 Jan 2015 14:05:34 -0800 Subject: [PATCH] Correct a mistake I made in LDV in RSP recompiler I totally forgot that LDV handles elements differently than SDV. I added a fallback to deal with unusual elements and added an alert to notify that it exists in a particular game. I removed the & 0xF since that's not needed. My previous change caused Stunt Racer 64 to have audio issues. It should now be fixed. --- Source/RSP/Recompiler Ops.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/Source/RSP/Recompiler Ops.c b/Source/RSP/Recompiler Ops.c index b10e37726..d284e6f78 100644 --- a/Source/RSP/Recompiler Ops.c +++ b/Source/RSP/Recompiler Ops.c @@ -4445,7 +4445,7 @@ void Compile_Opcode_LLV ( void ) { void Compile_Opcode_LDV ( void ) { char Reg[256]; - int offset = (RSPOpC.voffset << 3); + int offset = (RSPOpC.voffset << 3), length; BYTE * Jump[2], * LoopEntry; #ifndef CompileLdv @@ -4459,6 +4459,11 @@ void Compile_Opcode_LDV ( void ) { // rsp_UnknownOpcode(); // return; //} + if ((RSPOpC.del & 0x3) != 0) { + CompilerWarning("LDV's element = %X, PC = %04X", RSPOpC.del, CompilePC); + Cheat_r4300iOpcodeNoMessage(RSP_Opcode_LDV,"RSP_Opcode_LDV"); + return; + } if (IsRegConst(RSPOpC.base) == TRUE) { DWORD Addr = (MipsRegConst(RSPOpC.base) + offset) & 0xfff; @@ -4474,10 +4479,12 @@ void Compile_Opcode_LDV ( void ) { sprintf(Reg, "Dmem + %Xh", Addr + 4); MoveVariableToX86reg(RSPInfo.DMEM + Addr + 4, Reg, x86_ECX); - sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, (16 - RSPOpC.del - 4) & 0xF); - MoveX86regToVariable(x86_EAX, &RSP_Vect[RSPOpC.rt].B[(16 - RSPOpC.del - 4) & 0xF], Reg); - sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, (16 - RSPOpC.del - 8) & 0xF); - MoveX86regToVariable(x86_ECX, &RSP_Vect[RSPOpC.rt].B[(16 - RSPOpC.del - 8) & 0xF], Reg); + sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 16 - RSPOpC.del - 4); + MoveX86regToVariable(x86_EAX, &RSP_Vect[RSPOpC.rt].B[16 - RSPOpC.del - 4], Reg); + if(RSPOpC.del != 12){ + sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 16 - RSPOpC.del - 8); + MoveX86regToVariable(x86_ECX, &RSP_Vect[RSPOpC.rt].B[16 - RSPOpC.del - 8], Reg); + } return; } @@ -4495,7 +4502,11 @@ void Compile_Opcode_LDV ( void ) { x86_SetBranch32b(Jump[0], RecompPos); sprintf(Reg, "RSP_Vect[%i].UB[%i]", RSPOpC.rt, 15 - RSPOpC.del); MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rt].UB[15 - RSPOpC.del], Reg, x86_EDI); - MoveConstToX86reg(8, x86_ECX); + length = 8; + if(RSPOpC.del == 12){ + length = 4; + } + MoveConstToX86reg(length, x86_ECX); /* mov eax, ebx dec edi @@ -4526,11 +4537,12 @@ void Compile_Opcode_LDV ( void ) { MoveN64MemDispToX86reg(x86_ECX, x86_EBX, 4); /* Because of byte swapping this swizzle works nicely */ - sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, (16 - RSPOpC.del - 4) & 0xF); - MoveX86regToVariable(x86_EAX, &RSP_Vect[RSPOpC.rt].B[(16 - RSPOpC.del - 4) & 0xF], Reg); - sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, (16 - RSPOpC.del - 8) & 0xF); - MoveX86regToVariable(x86_ECX, &RSP_Vect[RSPOpC.rt].B[(16 - RSPOpC.del - 8) & 0xF], Reg); - + sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 16 - RSPOpC.del - 4); + MoveX86regToVariable(x86_EAX, &RSP_Vect[RSPOpC.rt].B[16 - RSPOpC.del - 4], Reg); + if(RSPOpC.del != 12){ + sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 16 - RSPOpC.del - 8); + MoveX86regToVariable(x86_ECX, &RSP_Vect[RSPOpC.rt].B[16 - RSPOpC.del - 8], Reg); + } CPU_Message(" Done:"); x86_SetBranch32b(Jump[1], RecompPos); }