Helper.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using Ryujinx.HLE.Utilities;
  2. using System;
  3. using System.Buffers.Binary;
  4. namespace Ryujinx.HLE.HOS.Services.Mii
  5. {
  6. static class Helper
  7. {
  8. public static ushort CalculateCrc16(ReadOnlySpan<byte> data, int crc, bool reverseEndianess)
  9. {
  10. const ushort poly = 0x1021;
  11. for (int i = 0; i < data.Length; i++)
  12. {
  13. crc ^= data[i] << 8;
  14. for (int j = 0; j < 8; j++)
  15. {
  16. crc <<= 1;
  17. if ((crc & 0x10000) != 0)
  18. {
  19. crc = (crc ^ poly) & 0xFFFF;
  20. }
  21. }
  22. }
  23. if (reverseEndianess)
  24. {
  25. return (ushort)(BinaryPrimitives.ReverseEndianness(crc) >> 16);
  26. }
  27. return (ushort)crc;
  28. }
  29. public static UInt128 GetDeviceId()
  30. {
  31. // FIXME: call set:sys GetMiiAuthorId
  32. return new UInt128("5279754d69694e780000000000000000"); // RyuMiiNx
  33. }
  34. public static ReadOnlySpan<byte> Ver3FacelineColorTable => new byte[] { 0, 1, 2, 3, 4, 5 };
  35. public static ReadOnlySpan<byte> Ver3HairColorTable => new byte[] { 8, 1, 2, 3, 4, 5, 6, 7 };
  36. public static ReadOnlySpan<byte> Ver3EyeColorTable => new byte[] { 8, 9, 10, 11, 12, 13 };
  37. public static ReadOnlySpan<byte> Ver3MouthColorTable => new byte[] { 19, 20, 21, 22, 23 };
  38. public static ReadOnlySpan<byte> Ver3GlassColorTable => new byte[] { 8, 14, 15, 16, 17, 18, 0 };
  39. }
  40. }