mirror of
https://github.com/ARMSX2/ARMSX2.git
synced 2026-08-24 16:50:16 -07:00
VU_STAT_UPDATE assigned the bare ZSUO cause nibble to statusflag, throwing the sticky field away, and _vuFMACflush re-derived the stickies from that cause nibble on every pipeline entry it retired. That is idempotent right up until an FSSET clears the sticky field: the stale cause then regenerates the bit FSSET just cleared. Traced on VUSTICKY_MICRO_FSSET_ASSIGNS_NOT_ORS. The FSSET merge itself is correct -- it produces VI=801 -- and the bit comes back one entry later: [FSSET] imm=800 sf 001 -> 801 [FLUSH] pipe[2] flagreg=10000 entry.sf=801 VI=041 -> VI=801 (FSSET arm) [ADD] pipe[3] lower VIwrite=8 snap.sf=801 [FLUSH] pipe[3] flagreg=8 entry.sf=801 VI=801 -> VI=841 (FMAC arm) pipe[3] is not an FMAC at all; flagreg=8 is a lower op writing integer register VI[3]. It took the non-FSSET arm only because every retired entry rewrites STATUS, and (sf & 0xF) << 6 turned the long-dead Z cause back into sticky Z. So the sticky OR moves to VU_STAT_UPDATE, where the flags are produced, and both flush sites take the sticky field from the snapshot instead of re-deriving it. statusflag is seeded from the whole STATUS register in vu0ExecMicro, so carrying the sticky field in it is the documented intent -- VU_STAT_UPDATE's original comment claimed exactly this preservation while the code did the opposite. Both halves are load-bearing: reverting VU_STAT_UPDATE alone fails the Vu0AluUpper suite, reverting the flush arms alone leaves the FSSET rows diverging. Graduates VUSTICKY_MICRO_FSSET_CLEARS and VUSTICKY_MICRO_FSSET_ASSIGNS_NOT_ORS from kMicroDivergences, which no longer holds any interp-only row. Idea by pstef.
109 lines
2.6 KiB
C++
109 lines
2.6 KiB
C++
// SPDX-FileCopyrightText: 2002-2026 PCSX2 Dev Team
|
|
// SPDX-License-Identifier: GPL-3.0+
|
|
|
|
#include "Common.h"
|
|
|
|
#include <cmath>
|
|
#include <float.h>
|
|
|
|
#include "VUmicro.h"
|
|
|
|
/*****************************************/
|
|
/* NEW FLAGS */ //By asadr. Thnkx F|RES :p
|
|
/*****************************************/
|
|
|
|
static __ri u32 VU_MAC_UPDATE( int shift, VURegs * VU, float f )
|
|
{
|
|
u32 v = *(u32*)&f;
|
|
int exp = (v >> 23) & 0xff;
|
|
u32 s = v & 0x80000000;
|
|
|
|
if (s)
|
|
VU->macflag |= 0x0010<<shift;
|
|
else
|
|
VU->macflag &= ~(0x0010<<shift);
|
|
|
|
if( f == 0 )
|
|
{
|
|
VU->macflag = (VU->macflag & ~(0x1100<<shift)) | (0x0001<<shift);
|
|
return v;
|
|
}
|
|
|
|
switch(exp)
|
|
{
|
|
case 0:
|
|
VU->macflag = (VU->macflag&~(0x1000<<shift)) | (0x0101<<shift);
|
|
return s;
|
|
case 255:
|
|
VU->macflag = (VU->macflag&~(0x0101<<shift)) | (0x1000<<shift);
|
|
if (CHECK_VU_OVERFLOW((VU == &VU1) ? 1 : 0))
|
|
return s | 0x7f7fffff; /* max allowed */
|
|
else
|
|
return v;
|
|
default:
|
|
VU->macflag = (VU->macflag & ~(0x1101<<shift));
|
|
return v;
|
|
}
|
|
}
|
|
|
|
__fi u32 VU_MACx_UPDATE(VURegs * VU, float x)
|
|
{
|
|
return VU_MAC_UPDATE(3, VU, x);
|
|
}
|
|
|
|
__fi u32 VU_MACy_UPDATE(VURegs * VU, float y)
|
|
{
|
|
return VU_MAC_UPDATE(2, VU, y);
|
|
}
|
|
|
|
__fi u32 VU_MACz_UPDATE(VURegs * VU, float z)
|
|
{
|
|
return VU_MAC_UPDATE(1, VU, z);
|
|
}
|
|
|
|
__fi u32 VU_MACw_UPDATE(VURegs * VU, float w)
|
|
{
|
|
return VU_MAC_UPDATE(0, VU, w);
|
|
}
|
|
|
|
__fi void VU_MACx_CLEAR(VURegs * VU)
|
|
{
|
|
VU->macflag&= ~(0x1111<<3);
|
|
}
|
|
|
|
__fi void VU_MACy_CLEAR(VURegs * VU)
|
|
{
|
|
VU->macflag&= ~(0x1111<<2);
|
|
}
|
|
|
|
__fi void VU_MACz_CLEAR(VURegs * VU)
|
|
{
|
|
VU->macflag&= ~(0x1111<<1);
|
|
}
|
|
|
|
__fi void VU_MACw_CLEAR(VURegs * VU)
|
|
{
|
|
VU->macflag&= ~(0x1111<<0);
|
|
}
|
|
|
|
__ri void VU_STAT_UPDATE(VURegs * VU) {
|
|
int newflag = 0 ;
|
|
if (VU->macflag & 0x000F) newflag = 0x1;
|
|
if (VU->macflag & 0x00F0) newflag |= 0x2;
|
|
if (VU->macflag & 0x0F00) newflag |= 0x4;
|
|
if (VU->macflag & 0xF000) newflag |= 0x8;
|
|
// Replace the ZSUO cause nibble and OR the matching sticky bits in, keeping
|
|
// the sticky field this op did not touch. The sticky OR has to happen HERE,
|
|
// at the point the flags are produced -- statusflag is seeded from the whole
|
|
// STATUS register (vu0ExecMicro), not from a bare cause nibble.
|
|
//
|
|
// Assigning `newflag` outright instead left the sticky field to be
|
|
// re-derived from the cause nibble by whoever consumed statusflag later.
|
|
// That is idempotent right up until an FSSET clears the sticky field, at
|
|
// which point the stale cause regenerates the bit FSSET just cleared.
|
|
//
|
|
// The D/I pair is deliberately not carried here: it belongs to the div unit,
|
|
// which maintains it in statusflag independently (VU_STICKY_DI).
|
|
VU->statusflag = (VU->statusflag & 0xFC0) | newflag | (newflag << 6);
|
|
}
|