Helper.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 CalculateCrc16BE(ReadOnlySpan<byte> data, int crc = 0)
  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. return BinaryPrimitives.ReverseEndianness((ushort)crc);
  24. }
  25. public static UInt128 GetDeviceId()
  26. {
  27. // FIXME: call set:sys GetMiiAuthorId
  28. return new UInt128(0, 1);
  29. }
  30. public static ReadOnlySpan<byte> Ver3FacelineColorTable => new byte[] { 0, 1, 2, 3, 4, 5 };
  31. public static ReadOnlySpan<byte> Ver3HairColorTable => new byte[] { 8, 1, 2, 3, 4, 5, 6, 7 };
  32. public static ReadOnlySpan<byte> Ver3EyeColorTable => new byte[] { 8, 9, 10, 11, 12, 13 };
  33. public static ReadOnlySpan<byte> Ver3MouthColorTable => new byte[] { 19, 20, 21, 22, 23 };
  34. public static ReadOnlySpan<byte> Ver3GlassColorTable => new byte[] { 8, 14, 15, 16, 17, 18, 0 };
  35. }
  36. }