1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-11 21:52:02 +00:00
Ryujinx/Ryujinx.HLE/HOS/Services/Mii/Helper.cs
Ac_K 7344dee475
account: Adds AccountManager (#2184)
* account: Adds Account Manager

In a way to have Custom User Profiles merged in master faster, this PR adds a `AccountManager` class (based on `AccountUtils` class) and the following changes have been made:
- Adds a "default profile values" which were the old hardcoded ones.
- The image profile is moved to the Account service folder.
- The hardcoded UserId for the savedata is now using the `AccountManager` last opened one.
- The DeviceId in Mii service is changed to the right value (checked by REd sys:set call).

* Fix csproj

* Addresses gdkchan's comments

* Fix UserProfile fields

* Fix mii GetDeviceId()

* Update Ryujinx.HLE.csproj
2021-04-13 03:16:43 +02:00

43 lines
1.4 KiB
C#

using Ryujinx.HLE.Utilities;
using System;
using System.Buffers.Binary;
namespace Ryujinx.HLE.HOS.Services.Mii
{
static class Helper
{
public static ushort CalculateCrc16BE(ReadOnlySpan<byte> data, int crc = 0)
{
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;
}
}
}
return BinaryPrimitives.ReverseEndianness((ushort)crc);
}
public static UInt128 GetDeviceId()
{
// FIXME: call set:sys GetMiiAuthorId
return new UInt128(0, 1);
}
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 };
}
}