Helper.cs 1.4 KB

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