2026-01-12 05:18:12 -05:00
|
|
|
// SPDX-FileCopyrightText: 2002-2026 PCSX2 Dev Team
|
2024-07-30 13:42:36 +02:00
|
|
|
// SPDX-License-Identifier: GPL-3.0+
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-11-14 12:02:56 +00:00
|
|
|
#include "Common.h"
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#include <float.h>
|
|
|
|
|
|
|
|
|
|
#include "VUmicro.h"
|
2009-11-14 12:02:56 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
/*****************************************/
|
|
|
|
|
/* NEW FLAGS */ //By asadr. Thnkx F|RES :p
|
|
|
|
|
/*****************************************/
|
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
static __ri u32 VU_MAC_UPDATE( int shift, VURegs * VU, float f )
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2010-04-25 00:31:27 +00:00
|
|
|
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:
|
2021-09-03 00:04:55 +01:00
|
|
|
VU->macflag = (VU->macflag&~(0x0101<<shift)) | (0x1000<<shift);
|
2022-12-28 14:44:34 +10:00
|
|
|
if (CHECK_VU_OVERFLOW((VU == &VU1) ? 1 : 0))
|
2021-09-12 15:20:50 +01:00
|
|
|
return s | 0x7f7fffff; /* max allowed */
|
|
|
|
|
else
|
|
|
|
|
return v;
|
2010-04-25 00:31:27 +00:00
|
|
|
default:
|
|
|
|
|
VU->macflag = (VU->macflag & ~(0x1101<<shift));
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__fi u32 VU_MACx_UPDATE(VURegs * VU, float x)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
|
return VU_MAC_UPDATE(3, VU, x);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__fi u32 VU_MACy_UPDATE(VURegs * VU, float y)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
|
return VU_MAC_UPDATE(2, VU, y);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__fi u32 VU_MACz_UPDATE(VURegs * VU, float z)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
|
return VU_MAC_UPDATE(1, VU, z);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__fi u32 VU_MACw_UPDATE(VURegs * VU, float w)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
|
return VU_MAC_UPDATE(0, VU, w);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__fi void VU_MACx_CLEAR(VURegs * VU)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
|
VU->macflag&= ~(0x1111<<3);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__fi void VU_MACy_CLEAR(VURegs * VU)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
|
VU->macflag&= ~(0x1111<<2);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__fi void VU_MACz_CLEAR(VURegs * VU)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
|
VU->macflag&= ~(0x1111<<1);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__fi void VU_MACw_CLEAR(VURegs * VU)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
|
VU->macflag&= ~(0x1111<<0);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__ri void VU_STAT_UPDATE(VURegs * VU) {
|
2009-02-09 21:15:56 +00:00
|
|
|
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;
|
2026-07-26 14:21:14 +02:00
|
|
|
// 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);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|