added 'padd' MMX instructions emulation.

This commit is contained in:
morkt 2015-10-28 00:51:55 +04:00
parent d1fa630f3d
commit 9e5990b118
2 changed files with 25 additions and 14 deletions

View File

@ -405,6 +405,30 @@ namespace GameRes.Formats
}
}
public static class MMX
{
public static ulong PAddW (ulong x, ulong y)
{
ulong mask = 0xffff;
ulong r = ((x & mask) + (y & mask)) & mask;
mask <<= 16;
r |= ((x & mask) + (y & mask)) & mask;
mask <<= 16;
r |= ((x & mask) + (y & mask)) & mask;
mask <<= 16;
r |= ((x & mask) + (y & mask)) & mask;
return r;
}
public static ulong PAddD (ulong x, ulong y)
{
ulong mask = 0xffffffff;
ulong r = ((x & mask) + (y & mask)) & mask;
mask <<= 32;
return r | ((x & mask) + (y & mask)) & mask;
}
}
public static class Dump
{
public static string DirectoryName = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);

View File

@ -201,7 +201,7 @@ namespace GameRes.Formats.Neko
while (first != last)
{
ulong v = *first ^ key;
key = _m_paddw (key, v);
key = MMX.PAddW (key, v);
*first++ = v;
}
return key;
@ -209,19 +209,6 @@ namespace GameRes.Formats.Neko
}
}
static ulong _m_paddw (ulong x, ulong y)
{
ulong mask = 0xffff;
ulong r = ((x & mask) + (y & mask)) & mask;
mask <<= 16;
r |= ((x & mask) + (y & mask)) & mask;
mask <<= 16;
r |= ((x & mask) + (y & mask)) & mask;
mask <<= 16;
r |= ((x & mask) + (y & mask)) & mask;
return r;
}
static byte[] ReadBlock (ArcView.Frame view, uint id, long offset, out int length)
{
uint hash = view.ReadUInt32 (offset);