2022-11-09 19:22:43 +00:00
|
|
|
|
using Ryujinx.Common.Utilities;
|
2020-03-01 22:56:02 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Buffers.Binary;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Mii
|
|
|
|
|
{
|
|
|
|
|
static class Helper
|
|
|
|
|
{
|
2021-06-23 21:24:16 +01:00
|
|
|
|
public static ushort CalculateCrc16(ReadOnlySpan<byte> data, int crc, bool reverseEndianess)
|
2020-03-01 22:56:02 +00:00
|
|
|
|
{
|
|
|
|
|
const ushort poly = 0x1021;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < data.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
crc ^= data[i] << 8;
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < 8; j++)
|
|
|
|
|
{
|
|
|
|
|
crc <<= 1;
|
|
|
|
|
|
|
|
|
|
if ((crc & 0x10000) != 0)
|
|
|
|
|
{
|
|
|
|
|
crc = (crc ^ poly) & 0xFFFF;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-23 21:24:16 +01:00
|
|
|
|
if (reverseEndianess)
|
|
|
|
|
{
|
|
|
|
|
return (ushort)(BinaryPrimitives.ReverseEndianness(crc) >> 16);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (ushort)crc;
|
2020-03-01 22:56:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static UInt128 GetDeviceId()
|
|
|
|
|
{
|
|
|
|
|
// FIXME: call set:sys GetMiiAuthorId
|
2022-11-09 19:22:43 +00:00
|
|
|
|
return UInt128Utils.FromHex("5279754d69694e780000000000000000"); // RyuMiiNx
|
2020-03-01 22:56:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ReadOnlySpan<byte> Ver3FacelineColorTable => new byte[] { 0, 1, 2, 3, 4, 5 };
|
|
|
|
|
public static ReadOnlySpan<byte> Ver3HairColorTable => new byte[] { 8, 1, 2, 3, 4, 5, 6, 7 };
|
|
|
|
|
public static ReadOnlySpan<byte> Ver3EyeColorTable => new byte[] { 8, 9, 10, 11, 12, 13 };
|
|
|
|
|
public static ReadOnlySpan<byte> Ver3MouthColorTable => new byte[] { 19, 20, 21, 22, 23 };
|
|
|
|
|
public static ReadOnlySpan<byte> Ver3GlassColorTable => new byte[] { 8, 14, 15, 16, 17, 18, 0 };
|
|
|
|
|
}
|
|
|
|
|
}
|