diff --git a/Source/Project64-rsp/Interpreter Ops.cpp b/Source/Project64-rsp/Interpreter Ops.cpp index d1b35f9a0..1f7cd61db 100644 --- a/Source/Project64-rsp/Interpreter Ops.cpp +++ b/Source/Project64-rsp/Interpreter Ops.cpp @@ -1262,19 +1262,16 @@ void RSP_Vector_VSUB(void) void RSP_Vector_VABS(void) { - uint8_t del; RSPVector Result; for (uint8_t el = 0; el < 8; el++) { - del = EleSpec[RSPOpC.e].B[el]; - if (RSP_Vect[RSPOpC.vs].s16(el) > 0) { - Result.s16(el) = RSP_Vect[RSPOpC.vt].u16(del); + Result.s16(el) = RSP_Vect[RSPOpC.vt].ue(el, RSPOpC.e); } else if (RSP_Vect[RSPOpC.vs].s16(el) < 0) { - Result.u16(el) = RSP_Vect[RSPOpC.vt].u16(del) == 0x8000 ? 0x7FFF : RSP_Vect[RSPOpC.vt].s16(del) * -1; + Result.u16(el) = RSP_Vect[RSPOpC.vt].ue(el, RSPOpC.e) == 0x8000 ? 0x7FFF : RSP_Vect[RSPOpC.vt].se(el, RSPOpC.e) * -1; } else { diff --git a/Source/Project64-rsp/cpu/RspTypes.cpp b/Source/Project64-rsp/cpu/RspTypes.cpp index b879f1605..b96d9dc16 100644 --- a/Source/Project64-rsp/cpu/RspTypes.cpp +++ b/Source/Project64-rsp/cpu/RspTypes.cpp @@ -1,11 +1,25 @@ #include "RspTypes.h" +extern UDWORD EleSpec[16]; + RSPVector::RSPVector() { m_Reg[0] = 0; m_Reg[1] = 0; } +uint16_t & RSPVector::ue(uint8_t Index, uint8_t Element) +{ + Index = EleSpec[Element].B[Index]; + return ((uint16_t*)&m_Reg)[7 - Index]; +} + +int16_t & RSPVector::se(uint8_t Index, uint8_t Element) +{ + Index = EleSpec[Element].B[Index]; + return ((int16_t*)&m_Reg)[7 - Index]; +} + int8_t & RSPVector::s8(uint8_t Index) { return ((int8_t*)&m_Reg)[15 - Index]; diff --git a/Source/Project64-rsp/cpu/RspTypes.h b/Source/Project64-rsp/cpu/RspTypes.h index 6b6627d83..92e749593 100644 --- a/Source/Project64-rsp/cpu/RspTypes.h +++ b/Source/Project64-rsp/cpu/RspTypes.h @@ -29,6 +29,9 @@ class RSPVector public: RSPVector(); + uint16_t & ue(uint8_t Index, uint8_t Element); + int16_t & se(uint8_t Index, uint8_t Element); + int8_t & s8(uint8_t Index); uint8_t & u8(uint8_t Index); int16_t & s16(uint8_t Index);