From 97fccb1c364afddac506418d5d10b336fe65478f Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 18 Jul 2023 07:36:25 +0930 Subject: [PATCH] RSP: Change EleSpec to be 16 and use .e instead of rs --- Source/Project64-rsp/Cpu.cpp | 125 +++++++------------ Source/Project64-rsp/Cpu.h | 2 +- Source/Project64-rsp/Interpreter CPU.cpp | 2 +- Source/Project64-rsp/Interpreter Ops.cpp | 92 +++++++------- Source/Project64-rsp/RSP Command.cpp | 2 +- Source/Project64-rsp/Recompiler Ops.cpp | 72 +++++------ Source/Project64-rsp/Recompiler Sections.cpp | 2 +- 7 files changed, 129 insertions(+), 168 deletions(-) diff --git a/Source/Project64-rsp/Cpu.cpp b/Source/Project64-rsp/Cpu.cpp index 8003e15ebd..fe92a8952f 100644 --- a/Source/Project64-rsp/Cpu.cpp +++ b/Source/Project64-rsp/Cpu.cpp @@ -14,7 +14,7 @@ #include #include -UDWORD EleSpec[32], Indx[32]; +UDWORD EleSpec[16], Indx[16]; RSPOpcode RSPOpC; uint32_t *PrgCount, NextInstruction, RSP_Running, RSP_MfStatusCount; @@ -51,7 +51,6 @@ void SetCPU(DWORD core) void Build_RSP(void) { - int i; extern UWORD32 Recp, RecpResult, SQroot, SQrootResult; Recp.UW = 0; @@ -62,92 +61,54 @@ void Build_RSP(void) SetCPU(CPUCore); ResetTimerList(); - EleSpec[0].DW = 0; - EleSpec[1].DW = 0; - EleSpec[2].DW = 0; - EleSpec[3].DW = 0; - EleSpec[4].DW = 0; - EleSpec[5].DW = 0; - EleSpec[6].DW = 0; - EleSpec[7].DW = 0; - EleSpec[8].DW = 0; - EleSpec[9].DW = 0; - EleSpec[10].DW = 0; - EleSpec[11].DW = 0; - EleSpec[12].DW = 0; - EleSpec[13].DW = 0; - EleSpec[14].DW = 0; - EleSpec[15].DW = 0; - EleSpec[16].DW = 0x0001020304050607; // None - EleSpec[17].DW = 0x0001020304050607; // None - EleSpec[18].DW = 0x0000020204040606; // 0q - EleSpec[19].DW = 0x0101030305050707; // 1q - EleSpec[20].DW = 0x0000000004040404; // 0h - EleSpec[21].DW = 0x0101010105050505; // 1h - EleSpec[22].DW = 0x0202020206060606; // 2h - EleSpec[23].DW = 0x0303030307070707; // 3h - EleSpec[24].DW = 0x0000000000000000; // 0 - EleSpec[25].DW = 0x0101010101010101; // 1 - EleSpec[26].DW = 0x0202020202020202; // 2 - EleSpec[27].DW = 0x0303030303030303; // 3 - EleSpec[28].DW = 0x0404040404040404; // 4 - EleSpec[29].DW = 0x0505050505050505; // 5 - EleSpec[30].DW = 0x0606060606060606; // 6 - EleSpec[31].DW = 0x0707070707070707; // 7 - - Indx[0].DW = 0; - Indx[1].DW = 0; - Indx[2].DW = 0; - Indx[3].DW = 0; - Indx[4].DW = 0; - Indx[5].DW = 0; - Indx[6].DW = 0; - Indx[7].DW = 0; - Indx[8].DW = 0; - Indx[9].DW = 0; - Indx[10].DW = 0; - Indx[11].DW = 0; - Indx[12].DW = 0; - Indx[13].DW = 0; - Indx[14].DW = 0; - Indx[15].DW = 0; - - Indx[16].DW = 0x0001020304050607; // None - Indx[17].DW = 0x0001020304050607; // None - Indx[18].DW = 0x0103050700020406; // 0q - Indx[19].DW = 0x0002040601030507; // 1q - Indx[20].DW = 0x0102030506070004; // 0h - Indx[21].DW = 0x0002030406070105; // 1h - Indx[22].DW = 0x0001030405070206; // 2h - Indx[23].DW = 0x0001020405060307; // 3h - Indx[24].DW = 0x0102030405060700; // 0 - Indx[25].DW = 0x0002030405060701; // 1 - Indx[26].DW = 0x0001030405060702; // 2 - Indx[27].DW = 0x0001020405060703; // 3 - Indx[28].DW = 0x0001020305060704; // 4 - Indx[29].DW = 0x0001020304060705; // 5 - Indx[30].DW = 0x0001020304050706; // 6 - Indx[31].DW = 0x0001020304050607; // 7 - - for (i = 16; i < 32; i++) + EleSpec[0].DW = 0x0001020304050607; // None + EleSpec[1].DW = 0x0001020304050607; // None + EleSpec[2].DW = 0x0000020204040606; // 0q + EleSpec[3].DW = 0x0101030305050707; // 1q + EleSpec[4].DW = 0x0000000004040404; // 0h + EleSpec[5].DW = 0x0101010105050505; // 1h + EleSpec[6].DW = 0x0202020206060606; // 2h + EleSpec[7].DW = 0x0303030307070707; // 3h + EleSpec[8].DW = 0x0000000000000000; // 0 + EleSpec[9].DW = 0x0101010101010101; // 1 + EleSpec[10].DW = 0x0202020202020202; // 2 + EleSpec[11].DW = 0x0303030303030303; // 3 + EleSpec[12].DW = 0x0404040404040404; // 4 + EleSpec[13].DW = 0x0505050505050505; // 5 + EleSpec[14].DW = 0x0606060606060606; // 6 + EleSpec[15].DW = 0x0707070707070707; // 7 + + Indx[0].DW = 0x0001020304050607; // None + Indx[1].DW = 0x0001020304050607; // None + Indx[2].DW = 0x0103050700020406; // 0q + Indx[3].DW = 0x0002040601030507; // 1q + Indx[4].DW = 0x0102030506070004; // 0h + Indx[5].DW = 0x0002030406070105; // 1h + Indx[6].DW = 0x0001030405070206; // 2h + Indx[7].DW = 0x0001020405060307; // 3h + Indx[8].DW = 0x0102030405060700; // 0 + Indx[9].DW = 0x0002030405060701; // 1 + Indx[10].DW = 0x0001030405060702; // 2 + Indx[11].DW = 0x0001020405060703; // 3 + Indx[12].DW = 0x0001020305060704; // 4 + Indx[13].DW = 0x0001020304060705; // 5 + Indx[14].DW = 0x0001020304050706; // 6 + Indx[15].DW = 0x0001020304050607; // 7 + + for (uint8_t i = 0, n = sizeof(EleSpec) / sizeof(EleSpec[0]); i < n; i++) { - int count; - - for (count = 0; count < 8; count++) + for (uint8_t z = 0; z < 8; z++) { - Indx[i].B[count] = 7 - Indx[i].B[count]; - EleSpec[i].B[count] = 7 - EleSpec[i].B[count]; + Indx[i].B[z] = 7 - Indx[i].B[z]; + EleSpec[i].B[z] = 7 - EleSpec[i].B[z]; } - for (count = 0; count < 4; count++) + for (uint8_t z = 0; z < 4; z++) { - BYTE Temp; - - Temp = Indx[i].B[count]; - Indx[i].B[count] = Indx[i].B[7 - count]; - Indx[i].B[7 - count] = Temp; + uint8_t Temp = Indx[i].B[z]; + Indx[i].B[z] = Indx[i].B[7 - z]; + Indx[i].B[7 - z] = Temp; } } - PrgCount = RSPInfo.SP_PC_REG; } diff --git a/Source/Project64-rsp/Cpu.h b/Source/Project64-rsp/Cpu.h index a3d1cac546..71273ab5cc 100644 --- a/Source/Project64-rsp/Cpu.h +++ b/Source/Project64-rsp/Cpu.h @@ -2,7 +2,7 @@ #include "cpu/RspTypes.h" #include -extern UDWORD EleSpec[32], Indx[32]; +extern UDWORD EleSpec[16], Indx[16]; typedef void(*p_func)(void); diff --git a/Source/Project64-rsp/Interpreter CPU.cpp b/Source/Project64-rsp/Interpreter CPU.cpp index 81bc32065e..bb2b49f51d 100644 --- a/Source/Project64-rsp/Interpreter CPU.cpp +++ b/Source/Project64-rsp/Interpreter CPU.cpp @@ -417,7 +417,7 @@ DWORD RunInterpreterCPU(DWORD Cycles) WaitingForStep = true; SetRSPCommandViewto(*PrgCount); UpdateRSPRegistersScreen(); - while (WaitingForStep == true) + while (WaitingForStep != 0) { Sleep(20); if (!Stepping_Commands) diff --git a/Source/Project64-rsp/Interpreter Ops.cpp b/Source/Project64-rsp/Interpreter Ops.cpp index 7a59cd9f94..d1b35f9a09 100644 --- a/Source/Project64-rsp/Interpreter Ops.cpp +++ b/Source/Project64-rsp/Interpreter Ops.cpp @@ -614,7 +614,7 @@ void RSP_Vector_VMULF(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if (RSP_Vect[RSPOpC.vs].u16(el) != 0x8000 || RSP_Vect[RSPOpC.vt].u16(del) != 0x8000) { @@ -644,7 +644,7 @@ void RSP_Vector_VMULU(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; RSP_ACCUM[el].DW = (int64_t)(RSP_Vect[RSPOpC.vs].s16(el) * RSP_Vect[RSPOpC.vt].s16(del)) << 17; RSP_ACCUM[el].DW += 0x80000000; if (RSP_ACCUM[el].DW < 0) @@ -671,7 +671,7 @@ void RSP_Vector_VMUDL(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; temp.UW = (uint32_t)RSP_Vect[RSPOpC.vs].u16(el) * (uint32_t)RSP_Vect[RSPOpC.vt].u16(del); RSP_ACCUM[el].W[1] = 0; @@ -689,7 +689,7 @@ void RSP_Vector_VMUDM(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; temp.UW = (uint32_t)((int32_t)RSP_Vect[RSPOpC.vs].s16(el)) * (uint32_t)RSP_Vect[RSPOpC.vt].u16(del); if (temp.W < 0) @@ -715,7 +715,7 @@ void RSP_Vector_VMUDN(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; temp.UW = (uint32_t)RSP_Vect[RSPOpC.vs].u16(el) * (uint32_t)((int32_t)RSP_Vect[RSPOpC.vt].s16(del)); if (temp.W < 0) @@ -740,7 +740,7 @@ void RSP_Vector_VMUDH(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; RSP_ACCUM[el].W[1] = (int32_t)RSP_Vect[RSPOpC.vs].s16(el) * (int32_t)RSP_Vect[RSPOpC.vt].s16(del); RSP_ACCUM[el].HW[1] = 0; @@ -792,7 +792,7 @@ void RSP_Vector_VMACF(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; /*temp.W = (long)RSP_Vect[RSPOpC.vs].s16(el) * (long)(DWORD)RSP_Vect[RSPOpC.vt].s16(del); RSP_ACCUM[el].UHW[3] += (WORD)(temp.W >> 31); @@ -852,7 +852,7 @@ void RSP_Vector_VMACU(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; temp.W = (int32_t)RSP_Vect[RSPOpC.vs].s16(el) * (int32_t)(uint32_t)RSP_Vect[RSPOpC.vt].s16(del); RSP_ACCUM[el].UHW[3] = (RSP_ACCUM[el].UHW[3] + (WORD)(temp.W >> 31)) & 0xFFFF; @@ -896,7 +896,7 @@ void RSP_Vector_VMACQ(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if (RSP_ACCUM[el].W[1] > 0x20) { @@ -961,7 +961,7 @@ void RSP_Vector_VMADL(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; temp.UW = (uint32_t)RSP_Vect[RSPOpC.vs].u16(el) * (uint32_t)RSP_Vect[RSPOpC.vt].u16(del); temp2.UW = temp.UHW[1] + RSP_ACCUM[el].UHW[1]; @@ -1017,7 +1017,7 @@ void RSP_Vector_VMADM(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; temp.UW = (uint32_t)((int32_t)RSP_Vect[RSPOpC.vs].s16(el)) * (uint32_t)RSP_Vect[RSPOpC.vt].u16(del); temp2.UW = temp.UHW[0] + RSP_ACCUM[el].UHW[1]; @@ -1078,7 +1078,7 @@ void RSP_Vector_VMADN(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; temp.UW = (uint32_t)RSP_Vect[RSPOpC.vs].u16(el) * (uint32_t)((int32_t)RSP_Vect[RSPOpC.vt].s16(del)); temp2.UW = temp.UHW[0] + RSP_ACCUM[el].UHW[1]; @@ -1137,7 +1137,7 @@ void RSP_Vector_VMADH(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; RSP_ACCUM[el].W[1] += (int32_t)RSP_Vect[RSPOpC.vs].s16(el) * (int32_t)RSP_Vect[RSPOpC.vt].s16(del); if (RSP_ACCUM[el].HW[3] < 0) @@ -1188,7 +1188,7 @@ void RSP_Vector_VADD(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; temp.W = (int)RSP_Vect[RSPOpC.vs].s16(el) + (int)RSP_Vect[RSPOpC.vt].s16(del) + ((RSP_Flags[0].UW >> (7 - el)) & 0x1); @@ -1228,7 +1228,7 @@ void RSP_Vector_VSUB(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; temp.W = (int)RSP_Vect[RSPOpC.vs].s16(el) - (int)RSP_Vect[RSPOpC.vt].s16(del) - ((RSP_Flags[0].UW >> (7 - el)) & 0x1); @@ -1266,7 +1266,7 @@ void RSP_Vector_VABS(void) RSPVector Result; for (uint8_t el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if (RSP_Vect[RSPOpC.vs].s16(el) > 0) { @@ -1294,7 +1294,7 @@ void RSP_Vector_VADDC(void) RSP_Flags[0].UW = 0; for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; temp.UW = (int)RSP_Vect[RSPOpC.vs].u16(el) + (int)RSP_Vect[RSPOpC.vt].u16(del); RSP_ACCUM[el].HW[1] = temp.HW[0]; @@ -1316,7 +1316,7 @@ void RSP_Vector_VSUBC(void) RSP_Flags[0].UW = 0x0; for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; temp.UW = (int)RSP_Vect[RSPOpC.vs].u16(el) - (int)RSP_Vect[RSPOpC.vt].u16(del); RSP_ACCUM[el].HW[1] = temp.HW[0]; @@ -1384,7 +1384,7 @@ void RSP_Vector_VLT(void) RSP_Flags[1].UW = 0; for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if (RSP_Vect[RSPOpC.vs].s16(el) < RSP_Vect[RSPOpC.vt].s16(del)) { @@ -1422,7 +1422,7 @@ void RSP_Vector_VEQ(void) RSP_Flags[1].UW = 0; for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if (RSP_Vect[RSPOpC.vs].u16(el) == RSP_Vect[RSPOpC.vt].u16(del)) { @@ -1446,7 +1446,7 @@ void RSP_Vector_VNE(void) RSP_Flags[1].UW = 0; for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if (RSP_Vect[RSPOpC.vs].u16(el) != RSP_Vect[RSPOpC.vt].u16(del)) { @@ -1474,7 +1474,7 @@ void RSP_Vector_VGE(void) RSP_Flags[1].UW = 0; for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if (RSP_Vect[RSPOpC.vs].s16(el) == RSP_Vect[RSPOpC.vt].s16(del)) { @@ -1511,7 +1511,7 @@ void RSP_Vector_VCL(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if ((RSP_Flags[0].UW & (1 << (7 - el))) != 0) { @@ -1601,7 +1601,7 @@ void RSP_Vector_VCH(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if ((RSP_Vect[RSPOpC.vs].s16(el) ^ RSP_Vect[RSPOpC.vt].s16(del)) < 0) { @@ -1669,7 +1669,7 @@ void RSP_Vector_VCR(void) RSP_Flags[2].UW = 0; for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if ((RSP_Vect[RSPOpC.vs].s16(el) ^ RSP_Vect[RSPOpC.vt].s16(del)) < 0) { @@ -1715,7 +1715,7 @@ void RSP_Vector_VMRG(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if ((RSP_Flags[1].UW & (1 << (7 - el))) != 0) { @@ -1737,7 +1737,7 @@ void RSP_Vector_VAND(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; Result.s16(el) = RSP_Vect[RSPOpC.vs].s16(el) & RSP_Vect[RSPOpC.vt].s16(del); RSP_ACCUM[el].HW[1] = Result.s16(el); } @@ -1751,7 +1751,7 @@ void RSP_Vector_VNAND(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; Result.s16(el) = ~(RSP_Vect[RSPOpC.vs].s16(el) & RSP_Vect[RSPOpC.vt].s16(del)); RSP_ACCUM[el].HW[1] = Result.s16(el); } @@ -1765,7 +1765,7 @@ void RSP_Vector_VOR(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; Result.s16(el) = RSP_Vect[RSPOpC.vs].s16(el) | RSP_Vect[RSPOpC.vt].s16(del); RSP_ACCUM[el].HW[1] = Result.s16(el); } @@ -1779,7 +1779,7 @@ void RSP_Vector_VNOR(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; Result.s16(el) = ~(RSP_Vect[RSPOpC.vs].s16(el) | RSP_Vect[RSPOpC.vt].s16(del)); RSP_ACCUM[el].HW[1] = Result.s16(el); } @@ -1793,7 +1793,7 @@ void RSP_Vector_VXOR(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; Result.s16(el) = RSP_Vect[RSPOpC.vs].s16(el) ^ RSP_Vect[RSPOpC.vt].s16(del); RSP_ACCUM[el].HW[1] = Result.s16(el); } @@ -1807,7 +1807,7 @@ void RSP_Vector_VNXOR(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; Result.s16(el) = ~(RSP_Vect[RSPOpC.vs].s16(el) ^ RSP_Vect[RSPOpC.vt].s16(del)); RSP_ACCUM[el].HW[1] = Result.s16(el); } @@ -1816,7 +1816,7 @@ void RSP_Vector_VNXOR(void) void RSP_Vector_VRCP(void) { - RecpResult.W = RSP_Vect[RSPOpC.vt].s16(EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]); + RecpResult.W = RSP_Vect[RSPOpC.vt].s16(EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]); if (RecpResult.UW == 0) { RecpResult.UW = 0x7FFFFFFF; @@ -1857,7 +1857,7 @@ void RSP_Vector_VRCP(void) } for (int count = 0; count < 8; count++) { - RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[count]); + RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[count]); } RSP_Vect[RSPOpC.vd].s16(7 - (RSPOpC.rd & 0x7)) = RecpResult.UHW[0]; } @@ -1867,7 +1867,7 @@ void RSP_Vector_VRCPL(void) int count; bool neg; - RecpResult.UW = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]) | Recp.W; + RecpResult.UW = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]) | Recp.W; if (RecpResult.UW == 0) { RecpResult.UW = 0x7FFFFFFF; @@ -1919,7 +1919,7 @@ void RSP_Vector_VRCPL(void) } for (count = 0; count < 8; count++) { - RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[count]); + RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[count]); } RSP_Vect[RSPOpC.vd].s16(7 - (RSPOpC.rd & 0x7)) = RecpResult.UHW[0]; } @@ -1928,10 +1928,10 @@ void RSP_Vector_VRCPH(void) { int count; - Recp.UHW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]); + Recp.UHW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]); for (count = 0; count < 8; count++) { - RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[count]); + RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[count]); } RSP_Vect[RSPOpC.vd].u16(7 - (RSPOpC.rd & 0x7)) = RecpResult.UHW[1]; } @@ -1942,10 +1942,10 @@ void RSP_Vector_VMOV(void) for (count = 0; count < 8; count++) { - RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[count]); + RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[count]); } RSP_Vect[RSPOpC.vd].u16(7 - (RSPOpC.rd & 0x7)) = - RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]); + RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]); } void RSP_Vector_VRSQ(void) @@ -1953,7 +1953,7 @@ void RSP_Vector_VRSQ(void) int count; bool neg; - SQrootResult.W = RSP_Vect[RSPOpC.vt].s16(EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]); + SQrootResult.W = RSP_Vect[RSPOpC.vt].s16(EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]); if (SQrootResult.UW == 0) { SQrootResult.UW = 0x7FFFFFFF; @@ -2002,7 +2002,7 @@ void RSP_Vector_VRSQ(void) } for (count = 0; count < 8; count++) { - RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[count]); + RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[count]); } RSP_Vect[RSPOpC.vd].s16(7 - (RSPOpC.rd & 0x7)) = SQrootResult.UHW[0]; } @@ -2012,7 +2012,7 @@ void RSP_Vector_VRSQL(void) int count; bool neg; - SQrootResult.UW = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]) | SQroot.W; + SQrootResult.UW = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]) | SQroot.W; if (SQrootResult.UW == 0) { SQrootResult.UW = 0x7FFFFFFF; @@ -2067,7 +2067,7 @@ void RSP_Vector_VRSQL(void) } for (count = 0; count < 8; count++) { - RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[count]); + RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[count]); } RSP_Vect[RSPOpC.vd].s16(7 - (RSPOpC.rd & 0x7)) = SQrootResult.UHW[0]; } @@ -2076,10 +2076,10 @@ void RSP_Vector_VRSQH(void) { int count; - SQroot.UHW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]); + SQroot.UHW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]); for (count = 0; count < 8; count++) { - RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[count]); + RSP_ACCUM[count].HW[1] = RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[count]); } RSP_Vect[RSPOpC.vd].u16(7 - (RSPOpC.rd & 0x7)) = SQrootResult.UHW[1]; } diff --git a/Source/Project64-rsp/RSP Command.cpp b/Source/Project64-rsp/RSP Command.cpp index 5bad20654e..741fa008e2 100644 --- a/Source/Project64-rsp/RSP Command.cpp +++ b/Source/Project64-rsp/RSP Command.cpp @@ -381,7 +381,7 @@ void DrawRSPCommand(LPARAM lParam) DT_SINGLELINE | DT_VCENTER); } - if (ResetColor == true) + if (ResetColor != 0) { SetTextColor(ditem->hDC, oldColor); } diff --git a/Source/Project64-rsp/Recompiler Ops.cpp b/Source/Project64-rsp/Recompiler Ops.cpp index 53cf7c1dbc..945c9d1f3a 100644 --- a/Source/Project64-rsp/Recompiler Ops.cpp +++ b/Source/Project64-rsp/Recompiler Ops.cpp @@ -2713,7 +2713,7 @@ void Compile_Vector_VMULF(void) CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; sprintf(Reg, "RSP_Vect[%i].HW[%i]", RSPOpC.rd, el); MoveSxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].s16(el), Reg, x86_EAX); @@ -2857,7 +2857,7 @@ void Compile_Vector_VMUDL(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; sprintf(Reg, "RSP_Vect[%i].UHW[%i]", RSPOpC.rd, el); MoveZxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].u16(el), Reg, x86_EAX); @@ -3023,7 +3023,7 @@ void Compile_Vector_VMUDM(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; /*sprintf(Reg, "RSP_Vect[%i].HW[%i]", RSPOpC.rd, el); MoveSxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].s16(el), Reg, x86_EAX);*/ @@ -3159,7 +3159,7 @@ void Compile_Vector_VMUDN(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; /*sprintf(Reg, "RSP_Vect[%i].UHW[%i]", RSPOpC.rd, el); MoveZxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].u16(el), Reg, x86_EAX);*/ @@ -3386,7 +3386,7 @@ void Compile_Vector_VMUDH(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; sprintf(Reg, "RSP_Vect[%i].HW[%i]", RSPOpC.rd, el); MoveSxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].s16(el), Reg, x86_EAX); @@ -3451,7 +3451,7 @@ void Compile_Vector_VMACF(void) for (count = 0; count < 8; count++) { el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; CPU_Message(" Iteration: %i", count); @@ -3536,7 +3536,7 @@ void Compile_Vector_VMADL(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; sprintf(Reg, "RSP_Vect[%i].HW[%i]", RSPOpC.rd, el); MoveZxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].s16(el), Reg, x86_EAX); @@ -3624,7 +3624,7 @@ void Compile_Vector_VMADM(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; /*sprintf(Reg, "RSP_Vect[%i].HW[%i]", RSPOpC.rd, el); MoveSxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].s16(el), Reg, x86_EAX);*/ @@ -3709,7 +3709,7 @@ void Compile_Vector_VMADN(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; /*sprintf(Reg, "RSP_Vect[%i].UHW[%i]", RSPOpC.rd, el); MoveZxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].u16(el), Reg, x86_EAX);*/ @@ -3854,7 +3854,7 @@ void Compile_Vector_VMADH(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; /*sprintf(Reg, "RSP_Vect[%i].HW[%i]", RSPOpC.rd, el); MoveSxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].s16(el), Reg, x86_EAX);*/ @@ -3998,7 +3998,7 @@ void Compile_Vector_VADD(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; sprintf(Reg, "RSP_Vect[%i].HW[%i]", RSPOpC.rd, el); MoveSxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].s16(el), Reg, x86_EAX); @@ -4139,7 +4139,7 @@ void Compile_Vector_VSUB(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; MoveSxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].s16(el), "RSP_Vect[RSPOpC.vs].s16(el)", x86_EAX); if (!bOptimize) @@ -4290,7 +4290,7 @@ void Compile_Vector_VABS(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; if (RSPOpC.rd == RSPOpC.rt && (RSPOpC.rs & 0xF) < 2) { @@ -4400,7 +4400,7 @@ void Compile_Vector_VADDC(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; /*sprintf(Reg, "RSP_Vect[%i].HW[%i]", RSPOpC.rd, el); MoveZxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].s16(el), Reg, x86_EAX);*/ @@ -4469,7 +4469,7 @@ void Compile_Vector_VSUBC(void) { CPU_Message(" Iteration: %i", count); el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; sprintf(Reg, "RSP_Vect[%i].HW[%i]", RSPOpC.rd, el); MoveZxVariableToX86regHalf(&RSP_Vect[RSPOpC.vs].s16(el), Reg, x86_EAX); @@ -4584,7 +4584,7 @@ void Compile_Vector_VLT(void) MoveVariableToX86reg(&RSP_Flags[0].UW, "&RSP_Flags[0].UW", x86_ESI); for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; flag = 0x101 << (7 - el); if (del != el || RSPOpC.rt != RSPOpC.rd) { @@ -4685,7 +4685,7 @@ void Compile_Vector_VEQ(void) XorConstToX86Reg(x86_EBX, 0xFFFF); for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; flag = (0x101 << (7 - el)) ^ 0xFFFF; if (del != el || RSPOpC.rt != RSPOpC.rd) { @@ -4728,7 +4728,7 @@ void Compile_Vector_VEQ(void) { for (count = 0; count < 8; count++) { - el = EleSpec[RSPOpC.rs].B[count]; + el = EleSpec[RSPOpC.e].B[count]; if (el != last) { @@ -4762,7 +4762,7 @@ void Compile_Vector_VNE(void) for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; flag = 0x101 << (7 - el); if (del != el || RSPOpC.rt != RSPOpC.rd) { @@ -4889,7 +4889,7 @@ void Compile_Vector_VGE(void) MoveVariableToX86reg(&RSP_Flags[0].UW, "&RSP_Flags[0].UW", x86_ESI); for (el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; flag = 0x101 << (7 - el); if (del != el || RSPOpC.rt != RSPOpC.rd) { @@ -5006,7 +5006,7 @@ void Compile_Vector_VMRG(void) for (count = 0; count < 8; count++) { el = Indx[RSPOpC.rs].UB[count]; - del = EleSpec[RSPOpC.rs].UB[el]; + del = EleSpec[RSPOpC.e].UB[el]; CPU_Message(" Iteration: %i", count); sprintf(Reg, "RSP_Vect[%i].HW[%i]", RSPOpC.rd, el); @@ -5105,7 +5105,7 @@ void Compile_Vector_VAND(void) for (count = 0; count < 8; count++) { el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; CPU_Message(" Iteration: %i", count); @@ -5216,7 +5216,7 @@ void Compile_Vector_VNAND(void) for (count = 0; count < 8; count++) { el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; CPU_Message(" Iteration: %i", count); @@ -5328,7 +5328,7 @@ void Compile_Vector_VOR(void) for (count = 0; count < 8; count++) { el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; CPU_Message(" Iteration: %i", count); @@ -5434,7 +5434,7 @@ void Compile_Vector_VNOR(void) for (count = 0; count < 8; count++) { el = Indx[RSPOpC.rs].B[count]; - del = EleSpec[RSPOpC.rs].B[el]; + del = EleSpec[RSPOpC.e].B[el]; CPU_Message(" Iteration: %i", count); @@ -5666,7 +5666,7 @@ void Compile_Vector_VRCP(void) CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, RSPOpC.Value).NameAndParam().c_str()); - el = EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]; + el = EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]; sprintf(Reg, "RSP_Vect[%i].UHW[%i]", RSPOpC.rt, el); MoveSxVariableToX86regHalf(&RSP_Vect[RSPOpC.vt].s16(el), Reg, x86_ESI); MoveConstToX86reg(0x7FFFFFFF, x86_EAX); @@ -5702,7 +5702,7 @@ void Compile_Vector_VRCP(void) last = (uint8_t)-1; for (count = 0; count < 8; count++) { - el = EleSpec[RSPOpC.rs].B[count]; + el = EleSpec[RSPOpC.e].B[count]; if (el != last) { @@ -5736,7 +5736,7 @@ void Compile_Vector_VRCPL(void) CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, RSPOpC.Value).NameAndParam().c_str()); - el = EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]; + el = EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]; sprintf(Reg, "RSP_Vect[%i].UHW[%i]", RSPOpC.rt, el); MoveVariableToX86reg(&Recp.W, "Recp.W", x86_ESI); OrVariableToX86regHalf(&RSP_Vect[RSPOpC.vt].s16(el), Reg, x86_ESI); @@ -5779,7 +5779,7 @@ void Compile_Vector_VRCPL(void) last = (uint8_t)-1; for (count = 0; count < 8; count++) { - el = EleSpec[RSPOpC.rs].B[count]; + el = EleSpec[RSPOpC.e].B[count]; if (el != last) { @@ -5812,7 +5812,7 @@ void Compile_Vector_VRCPH(void) CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, RSPOpC.Value).NameAndParam().c_str()); - el = EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]; + el = EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]; sprintf(Reg, "RSP_Vect[%i].UHW[%i]", RSPOpC.rt, el); MoveVariableToX86regHalf(&RSP_Vect[RSPOpC.vt].u16(el), Reg, x86_EDX); MoveX86regHalfToVariable(x86_EDX, &Recp.UHW[1], "Recp.UHW[1]"); @@ -5824,7 +5824,7 @@ void Compile_Vector_VRCPH(void) last = (uint8_t)-1; for (count = 0; count < 8; count++) { - el = EleSpec[RSPOpC.rs].B[count]; + el = EleSpec[RSPOpC.e].B[count]; if (el != last) { @@ -5859,14 +5859,14 @@ void Compile_Vector_VMOV(void) { for (count = 0; count < 8; count++) { - sprintf(Reg, "RSP_Vect[%i].UHW[%i]", RSPOpC.rt, EleSpec[RSPOpC.rs].B[count]); - MoveVariableToX86regHalf(&RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.rs].B[count]), Reg, x86_EAX); + sprintf(Reg, "RSP_Vect[%i].UHW[%i]", RSPOpC.rt, EleSpec[RSPOpC.e].B[count]); + MoveVariableToX86regHalf(&RSP_Vect[RSPOpC.vt].u16(EleSpec[RSPOpC.e].B[count]), Reg, x86_EAX); sprintf(Reg, "RSP_ACCUM[%i].HW[1]", count); MoveX86regHalfToVariable(x86_EAX, &RSP_ACCUM[count].HW[1], Reg); } } - el = EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]; + el = EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]; sprintf(Reg, "RSP_Vect[%i].UHW[%i]", RSPOpC.rt, el); MoveVariableToX86regHalf(&RSP_Vect[RSPOpC.vt].u16(el), Reg, x86_ECX); @@ -5902,7 +5902,7 @@ void Compile_Vector_VRSQH(void) CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, RSPOpC.Value).NameAndParam().c_str()); - el = EleSpec[RSPOpC.rs].B[(RSPOpC.rd & 0x7)]; + el = EleSpec[RSPOpC.e].B[(RSPOpC.rd & 0x7)]; sprintf(Reg, "RSP_Vect[%i].UHW[%i]", RSPOpC.rt, el); MoveVariableToX86regHalf(&RSP_Vect[RSPOpC.vt].u16(el), Reg, x86_EDX); MoveX86regHalfToVariable(x86_EDX, &SQroot.UHW[1], "SQroot.UHW[1]"); @@ -5914,7 +5914,7 @@ void Compile_Vector_VRSQH(void) last = (uint8_t)-1; for (count = 0; count < 8; count++) { - el = EleSpec[RSPOpC.rs].B[count]; + el = EleSpec[RSPOpC.e].B[count]; if (el != last) { diff --git a/Source/Project64-rsp/Recompiler Sections.cpp b/Source/Project64-rsp/Recompiler Sections.cpp index a677f9ea9a..82737c0f3f 100644 --- a/Source/Project64-rsp/Recompiler Sections.cpp +++ b/Source/Project64-rsp/Recompiler Sections.cpp @@ -1228,7 +1228,7 @@ static void resampler_hle() accum.DW += const3; if (accum.W[1] > 0x7FFF) { - RSP_Vect[23].s16(i) = 0xFFFF; + RSP_Vect[23].u16(i) = 0xFFFF; } else if (accum.W[1] < -0x8000) {