RSP: Update VAdd code (SQV/LQV order changed as well)

This commit is contained in:
zilmar 2023-07-21 07:25:17 +09:30
parent 2cf740565e
commit 5c65bebe9e
3 changed files with 14 additions and 34 deletions

View File

@ -1188,38 +1188,20 @@ void RSP_Vector_VMADH(void)
void RSP_Vector_VADD(void) void RSP_Vector_VADD(void)
{ {
uint8_t el, del;
UWORD32 temp; UWORD32 temp;
RSPVector Result; RSPVector Result;
for (el = 0; el < 8; el++) for (uint8_t el = 0; el < 8; el++)
{ {
del = EleSpec[RSPOpC.e].B[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);
temp.W = (int)RSP_Vect[RSPOpC.vs].s16(el) + (int)RSP_Vect[RSPOpC.vt].s16(del) +
((RSP_Flags[0].UW >> (7 - el)) & 0x1);
RSP_ACCUM[el].HW[1] = temp.HW[0]; RSP_ACCUM[el].HW[1] = temp.HW[0];
if ((temp.HW[0] & 0x8000) == 0) if ((temp.HW[0] & 0x8000) == 0)
{ {
if (temp.HW[1] != 0) Result.u16(el) = temp.HW[1] != 0 ? 0x8000 : temp.UHW[0];
{
Result.u16(el) = 0x8000;
}
else
{
Result.u16(el) = temp.HW[0];
}
} }
else else
{ {
if (temp.HW[1] != -1) Result.u16(el) = temp.HW[1] != -1 ? 0x7FFF : temp.UHW[0];
{
Result.u16(el) = 0x7FFF;
}
else
{
Result.u16(el) = temp.UHW[0];
}
} }
} }
RSP_Vect[RSPOpC.vd] = Result; RSP_Vect[RSPOpC.vd] = Result;

View File

@ -714,16 +714,16 @@ void UpdateRSPRegistersScreen(void)
case Vector1: case Vector1:
for (count = 0; count < 16; count++) for (count = 0; count < 16; count++)
{ {
sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count].s32(3), sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count].s32(0),
RSP_Vect[count].s32(2), RSP_Vect[count].s32(1), RSP_Vect[count].s32(0)); RSP_Vect[count].s32(1), RSP_Vect[count].s32(2), RSP_Vect[count].s32(3));
SetWindowTextA(hVECT1[count], RegisterValue); SetWindowTextA(hVECT1[count], RegisterValue);
} }
break; break;
case Vector2: case Vector2:
for (count = 0; count < 16; count++) for (count = 0; count < 16; count++)
{ {
sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count + 16].s32(3), sprintf(RegisterValue, " 0x%08X - %08X - %08X - %08X", RSP_Vect[count + 16].s32(0),
RSP_Vect[count + 16].s32(2), RSP_Vect[count + 16].s32(1), 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); SetWindowTextA(hVECT2[count], RegisterValue);
} }
break; break;

View File

@ -232,9 +232,9 @@ void RSP_LQV_DMEM(uint32_t Addr, uint8_t vect, uint8_t element)
{ {
length = 16 - 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; 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) void RSP_SQV_DMEM(uint32_t Addr, uint8_t vect, uint8_t element)
{ {
int length, Count; uint8_t length = ((Addr + 0x10) & ~0xF) - Addr;
for (uint8_t i = element; i < (length + element); i++)
length = ((Addr + 0x10) & ~0xF) - Addr;
for (Count = element; Count < (length + element); Count++)
{ {
*(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; Addr += 1;
} }
} }