Fixed x86 build

Fixed crashes
This commit is contained in:
Nekotekina 2013-12-24 15:10:55 +04:00
parent ab2bc35b18
commit 3a82ed5dc9
2 changed files with 19 additions and 18 deletions

View File

@ -7,12 +7,12 @@
#define UNIMPLEMENTED() UNK(__FUNCTION__) #define UNIMPLEMENTED() UNK(__FUNCTION__)
typedef union _CRT_ALIGN(16) __u32x4 { /* typedef union _CRT_ALIGN(16) __u32x4 {
unsigned __int32 _u32[4]; u32 _u32[4];
__m128i m128i; __m128i m128i;
__m128 m128; __m128 m128;
__m128d m128d; __m128d m128d;
} __u32x4; } __u32x4; */
class SPUInterpreter : public SPUOpcodes class SPUInterpreter : public SPUOpcodes
{ {
@ -378,17 +378,16 @@ private:
} }
void FREST(u32 rt, u32 ra) void FREST(u32 rt, u32 ra)
{ {
//(SSE) RCPPS - Compute Reciprocals of Packed Single-Precision Floating-Point Values //CPU.GPR[rt]._m128 = _mm_rcp_ps(CPU.GPR[ra]._m128);
//rt = approximate(1/ra) for (int i = 0; i < 4; i++)
CPU.GPR[rt]._m128 = _mm_rcp_ps(CPU.GPR[ra]._m128); CPU.GPR[rt]._f[i] = 1 / CPU.GPR[ra]._f[i];
} }
void FRSQEST(u32 rt, u32 ra) void FRSQEST(u32 rt, u32 ra)
{ {
//(SSE) RSQRTPS - Compute Reciprocals of Square Roots of Packed Single-Precision Floating-Point Values //const __u32x4 FloatAbsMask = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff};
//rt = approximate(1/sqrt(abs(ra))) //CPU.GPR[rt]._m128 = _mm_rsqrt_ps(_mm_and_ps(CPU.GPR[ra]._m128, FloatAbsMask.m128));
//abs(ra) === ra & FloatAbsMask for (int i = 0; i < 4; i++)
const __u32x4 FloatAbsMask = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}; CPU.GPR[rt]._f[i] = 1 / sqrt(abs(CPU.GPR[ra]._f[i]));
CPU.GPR[rt]._m128 = _mm_rsqrt_ps(_mm_and_ps(CPU.GPR[ra]._m128, FloatAbsMask.m128));
} }
void LQX(u32 rt, u32 ra, u32 rb) void LQX(u32 rt, u32 ra, u32 rb)
{ {
@ -999,9 +998,10 @@ private:
exp = 255; exp = 255;
CPU.GPR[rt]._u32[i] = (CPU.GPR[ra]._u32[i] & 0x807fffff) | (exp << 23); CPU.GPR[rt]._u32[i] = (CPU.GPR[ra]._u32[i] & 0x807fffff) | (exp << 23);
CPU.GPR[rt]._u32[i] = (u32)CPU.GPR[rt]._f[i]; //trunc
} }
//(SSE2) CVTTPS2DQ - Convert with Truncation Packed Single FP to Packed Dword Int //CPU.GPR[rt]._m128i = _mm_cvttps_epi32(CPU.GPR[rt]._m128);
CPU.GPR[rt]._m128i = _mm_cvttps_epi32(CPU.GPR[rt]._m128);
} }
void CFLTU(u32 rt, u32 ra, s32 i8) void CFLTU(u32 rt, u32 ra, s32 i8)
{ {
@ -1028,11 +1028,12 @@ private:
} }
void CSFLT(u32 rt, u32 ra, s32 i8) void CSFLT(u32 rt, u32 ra, s32 i8)
{ {
//(SSE2) CVTDQ2PS - Convert Packed Dword Integers to Packed Single-Precision FP Values //CPU.GPR[rt]._m128 = _mm_cvtepi32_ps(CPU.GPR[ra]._m128i);
CPU.GPR[rt]._m128 = _mm_cvtepi32_ps(CPU.GPR[ra]._m128i);
const u32 scale = 155 - (i8 & 0xff); //unsigned immediate const u32 scale = 155 - (i8 & 0xff); //unsigned immediate
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
CPU.GPR[rt]._f[i] = (s32)CPU.GPR[ra]._i32[i];
u32 exp = ((CPU.GPR[rt]._u32[i] >> 23) & 0xff) - scale; u32 exp = ((CPU.GPR[rt]._u32[i] >> 23) & 0xff) - scale;
if (exp > 255) //< 0 if (exp > 255) //< 0

View File

@ -37,7 +37,7 @@ u32 LoadSpuImage(vfsStream& stream)
//156 //156
int sys_spu_image_open(mem_ptr_t<sys_spu_image> img, u32 path_addr) int sys_spu_image_open(mem_ptr_t<sys_spu_image> img, u32 path_addr)
{ {
const std::string& path = Memory.ReadString(path_addr).mb_str(); const wxString path = Memory.ReadString(path_addr).mb_str();
sc_spu.Warning("sys_spu_image_open(img_addr=0x%x, path_addr=0x%x [%s])", img.GetAddr(), path_addr, path); sc_spu.Warning("sys_spu_image_open(img_addr=0x%x, path_addr=0x%x [%s])", img.GetAddr(), path_addr, path);
if(!img.IsGood() || !Memory.IsGoodAddr(path_addr)) if(!img.IsGood() || !Memory.IsGoodAddr(path_addr))
@ -122,7 +122,7 @@ int sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t<
ConLog.Write("New SPU Thread:"); ConLog.Write("New SPU Thread:");
ConLog.Write("ls_entry = 0x%x", ls_entry); ConLog.Write("ls_entry = 0x%x", ls_entry);
ConLog.Write("name = %s", name); ConLog.Write("name = %s", wxString(name));
ConLog.Write("a1 = 0x%x", a1); ConLog.Write("a1 = 0x%x", a1);
ConLog.Write("a2 = 0x%x", a2); ConLog.Write("a2 = 0x%x", a2);
ConLog.Write("a3 = 0x%x", a3); ConLog.Write("a3 = 0x%x", a3);
@ -196,7 +196,7 @@ int sys_spu_thread_group_create(mem32_t id, u32 num, int prio, mem_ptr_t<sys_spu
ConLog.Write("*** attr.type=%d", attr->type.ToLE()); ConLog.Write("*** attr.type=%d", attr->type.ToLE());
ConLog.Write("*** attr.option.ct=%d", attr->option.ct.ToLE()); ConLog.Write("*** attr.option.ct=%d", attr->option.ct.ToLE());
const std::string& name = Memory.ReadString(attr->name_addr, attr->name_len).mb_str(); const wxString name = Memory.ReadString(attr->name_addr, attr->name_len).mb_str();
ConLog.Write("*** name='%s'", name); ConLog.Write("*** name='%s'", name);
id = Emu.GetIdManager().GetNewID(wxString::Format("sys_spu_thread_group '%s'", name), new SpuGroupInfo(*attr)); id = Emu.GetIdManager().GetNewID(wxString::Format("sys_spu_thread_group '%s'", name), new SpuGroupInfo(*attr));