diff --git a/Source/Project64-rsp/Interpreter Ops.cpp b/Source/Project64-rsp/Interpreter Ops.cpp index 2ea83f494..27f17c5ee 100644 --- a/Source/Project64-rsp/Interpreter Ops.cpp +++ b/Source/Project64-rsp/Interpreter Ops.cpp @@ -1188,38 +1188,20 @@ void RSP_Vector_VMADH(void) void RSP_Vector_VADD(void) { - uint8_t el, del; UWORD32 temp; RSPVector Result; - for (el = 0; el < 8; 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); + for (uint8_t el = 0; el < 8; el++) + { + temp.W = (int32_t)RSP_Vect[RSPOpC.vs].s16(el) + (int32_t)RSP_Vect[RSPOpC.vt].se(el, RSPOpC.e) + ((RSP_Flags[0].UW >> (7 - el)) & 0x1); RSP_ACCUM[el].HW[1] = temp.HW[0]; if ((temp.HW[0] & 0x8000) == 0) { - if (temp.HW[1] != 0) - { - Result.u16(el) = 0x8000; - } - else - { - Result.u16(el) = temp.HW[0]; - } + Result.u16(el) = temp.HW[1] != 0 ? 0x8000 : temp.UHW[0]; } else { - if (temp.HW[1] != -1) - { - Result.u16(el) = 0x7FFF; - } - else - { - Result.u16(el) = temp.UHW[0]; - } + Result.u16(el) = temp.HW[1] != -1 ? 0x7FFF : temp.UHW[0]; } } RSP_Vect[RSPOpC.vd] = Result; diff --git a/Source/Project64-rsp/RSP Register.cpp b/Source/Project64-rsp/RSP Register.cpp index 491db9fdb..d96b6d0ff 100644 --- a/Source/Project64-rsp/RSP Register.cpp +++ b/Source/Project64-rsp/RSP Register.cpp @@ -714,16 +714,16 @@ void UpdateRSPRegistersScreen(void) case Vector1: for (count = 0; count < 16; count++) { - sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count].s32(3), - RSP_Vect[count].s32(2), RSP_Vect[count].s32(1), RSP_Vect[count].s32(0)); + sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count].s32(0), + RSP_Vect[count].s32(1), RSP_Vect[count].s32(2), RSP_Vect[count].s32(3)); SetWindowTextA(hVECT1[count], RegisterValue); } break; case Vector2: for (count = 0; count < 16; count++) { - sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count + 16].s32(3), - RSP_Vect[count + 16].s32(2), RSP_Vect[count + 16].s32(1), RSP_Vect[count + 16].s32(0)); + sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count + 16].s32(0), + RSP_Vect[count + 16].s32(1), RSP_Vect[count + 16].s32(2), RSP_Vect[count + 16].s32(3)); SetWindowTextA(hVECT2[count], RegisterValue); } break; diff --git a/Source/Project64-rsp/memory.cpp b/Source/Project64-rsp/memory.cpp index 9285c6cfb..aebd392f7 100644 --- a/Source/Project64-rsp/memory.cpp +++ b/Source/Project64-rsp/memory.cpp @@ -232,9 +232,9 @@ void RSP_LQV_DMEM(uint32_t Addr, uint8_t vect, uint8_t element) { length = 16 - element; } - for (uint8_t Count = element; Count < (length + element); Count++) + for (uint8_t i = element; i < (length + element); i++) { - RSP_Vect[vect].s8(15 - Count) = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)); + RSP_Vect[vect].s8(i) = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)); Addr += 1; } } @@ -501,12 +501,10 @@ void RSP_SPV_DMEM(uint32_t Addr, uint8_t vect, uint8_t element) void RSP_SQV_DMEM(uint32_t Addr, uint8_t vect, uint8_t element) { - int length, Count; - - length = ((Addr + 0x10) & ~0xF) - Addr; - for (Count = element; Count < (length + element); Count++) + uint8_t length = ((Addr + 0x10) & ~0xF) - Addr; + for (uint8_t i = element; i < (length + element); i++) { - *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].s8(15 - (Count & 0xF)); + *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].s8(i & 0xF); Addr += 1; } }