2009-09-08 12:08:10 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
2010-05-03 14:08:02 +00:00
|
|
|
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2009-02-09 21:15:56 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-02-09 21:15:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PrecompiledHeader.h"
|
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
|
|
|
|
/*****************************************/
|
|
|
|
|
|
|
|
|
2009-09-21 14:19:49 +00:00
|
|
|
void vuUpdateDI(VURegs * VU) {
|
2009-02-09 21:15:56 +00:00
|
|
|
// u32 Flag_S = 0;
|
|
|
|
// u32 Flag_I = 0;
|
|
|
|
// u32 Flag_D = 0;
|
|
|
|
//
|
|
|
|
// /*
|
|
|
|
// FLAG D - I
|
|
|
|
// */
|
|
|
|
// Flag_I = (VU->statusflag >> 4) & 0x1;
|
|
|
|
// Flag_D = (VU->statusflag >> 5) & 0x1;
|
|
|
|
//
|
|
|
|
// VU->statusflag|= (Flag_I | (VU0.VI[REG_STATUS_FLAG].US[0] >> 4)) << 10;
|
|
|
|
// VU->statusflag|= (Flag_D | (VU0.VI[REG_STATUS_FLAG].US[0] >> 5)) << 11;
|
|
|
|
}
|
|
|
|
|
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:
|
|
|
|
VU->macflag = (VU->macflag&~(0x0100<<shift)) | (0x1000<<shift);
|
|
|
|
return s|0x7f7fffff; /* max allowed */
|
|
|
|
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;
|
|
|
|
VU->statusflag = (VU->statusflag&0xc30)|newflag|((VU->statusflag&0xf)<<6);
|
|
|
|
}
|