Guest User

Untitled

a guest
Jan 12th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1.  
  2. public static class OpCodeUtility
  3. {
  4. // Values in sync with 4.1.0.13850.
  5.  
  6. public const int MaxOpCode = ushort.MaxValue;
  7.  
  8. public static int? GetJamOpcode(int fullOpCode)
  9. {
  10. if (IsJamOpCode(fullOpCode))
  11. return ((fullOpCode & 0x8000) >> 8) | fullOpCode & 3 | ((fullOpCode & 0x3800) >> 7) | ((fullOpCode & 0x180) >> 5);
  12.  
  13. return null;
  14. }
  15.  
  16. public static int? CompressOpcode(int opCode)
  17. {
  18. if ((opCode & 0x4C9) == 0x440)
  19. return (((opCode & 0xF800) >> 5) | ((opCode & 0x300) >> 4) | ((opCode & 0x6) >> 1) | ((opCode & 0x30) >> 2));
  20.  
  21. return null;
  22. }
  23.  
  24. public static bool IsJamOpCode(int fullOpCode)
  25. {
  26. return (fullOpCode & 0x467C) == 0x608;
  27. }
  28.  
  29. public static IEnumerable<int> GetCondensedOpCodes(int opCode)
  30. {
  31. for (var i = 1; i < MaxOpCode; i++)
  32. if (CompressOpcode(i) == opCode)
  33. yield return i;
  34. }
  35. }
Add Comment
Please, Sign In to add comment