From 77af4a7f5086813fd3d8a10195a6c599b6e879de Mon Sep 17 00:00:00 2001 From: morkt Date: Tue, 9 Feb 2016 09:56:51 +0400 Subject: [PATCH] (MMX): added PSubB, PSubW and PSubD methods. --- ArcFormats/ArcCommon.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/ArcFormats/ArcCommon.cs b/ArcFormats/ArcCommon.cs index 53e56fa1..562fd086 100644 --- a/ArcFormats/ArcCommon.cs +++ b/ArcFormats/ArcCommon.cs @@ -495,6 +495,37 @@ namespace GameRes.Formats return r | ((x & mask) + (y & mask)) & mask; } + public static ulong PSubB (ulong x, ulong y) + { + ulong r = 0; + for (ulong mask = 0xFF; mask != 0; mask <<= 8) + { + r |= ((x & mask) - (y & mask)) & mask; + } + return r; + } + + public static ulong PSubW (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 PSubD (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 ulong PSllD (ulong x, int count) { count &= 0x1F;