Skip to content

Commit

Permalink
RSP: Update VAdd code (SQV/LQV order changed as well)
Browse files Browse the repository at this point in the history
  • Loading branch information
project64 committed Jul 20, 2023
1 parent 2cf7405 commit 5c65beb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 34 deletions.
28 changes: 5 additions & 23 deletions Source/Project64-rsp/Interpreter Ops.cpp
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions Source/Project64-rsp/RSP Register.cpp
Expand Up @@ -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;
Expand Down
12 changes: 5 additions & 7 deletions Source/Project64-rsp/memory.cpp
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 5c65beb

Please sign in to comment.