Implement mii:u and mii:e entirely (#955)
* Implement mii:u and mii:e entirely Co-authored-by: AcK77 <Acoustik666@gmail.com> This commit implement the mii service accurately. This is based on Ac_k work but was polished and updated to 7.x. Please note that the following calls are partially implemented: - Convert: Used to convert from old console format (Wii/Wii U/3ds) - Import and Export: this is shouldn't be accesible in production mode. * Remove some debug leftovers * Make it possible to load an arbitrary mii database from a Switch * Address gdk's comments * Reduce visibility of all the Mii code * Address Ac_K's comments * Remove the StructLayout of DatabaseSessionMetadata * Add a missing line return in DatabaseSessionMetadata * Misc fixes and style changes * Fix some issues from last commit * Fix database server metadata UpdateCounter in MarkDirty (Thanks Moose for the catch) * MountCounter should only be incremented when no error is reported * Fix FixDatabase Co-authored-by: Alex Barney <thealexbarney@gmail.com>
This commit is contained in:
parent
7d1a294eae
commit
3b531de670
49 changed files with 6728 additions and 15 deletions
67
Ryujinx.HLE/HOS/Services/Mii/UtilityImpl.cs
Normal file
67
Ryujinx.HLE/HOS/Services/Mii/UtilityImpl.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
using Ryujinx.HLE.HOS.Services.Mii.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Time;
|
||||
using Ryujinx.HLE.HOS.Services.Time.Clock;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Mii
|
||||
{
|
||||
class UtilityImpl
|
||||
{
|
||||
private uint _x;
|
||||
private uint _y;
|
||||
private uint _z;
|
||||
private uint _w;
|
||||
|
||||
public UtilityImpl()
|
||||
{
|
||||
_x = 123456789;
|
||||
_y = 362436069;
|
||||
|
||||
TimeSpanType time = TimeManager.Instance.TickBasedSteadyClock.GetCurrentRawTimePoint(null);
|
||||
|
||||
_w = (uint)(time.NanoSeconds & uint.MaxValue);
|
||||
_z = (uint)((time.NanoSeconds >> 32) & uint.MaxValue);
|
||||
}
|
||||
|
||||
private uint GetRandom()
|
||||
{
|
||||
uint t = (_x ^ (_x << 11));
|
||||
|
||||
_x = _y;
|
||||
_y = _z;
|
||||
_z = _w;
|
||||
_w = (_w ^ (_w >> 19)) ^ (t ^ (t >> 8));
|
||||
|
||||
return _w;
|
||||
}
|
||||
|
||||
public int GetRandom(int end)
|
||||
{
|
||||
return (int)GetRandom((uint)end);
|
||||
}
|
||||
|
||||
public uint GetRandom(uint end)
|
||||
{
|
||||
uint random = GetRandom();
|
||||
|
||||
return random - random / end * end;
|
||||
}
|
||||
|
||||
public uint GetRandom(uint start, uint end)
|
||||
{
|
||||
uint random = GetRandom();
|
||||
|
||||
return random - random / (1 - start + end) * (1 - start + end) + start;
|
||||
}
|
||||
|
||||
public int GetRandom(int start, int end)
|
||||
{
|
||||
return (int)GetRandom((uint)start, (uint)end);
|
||||
}
|
||||
|
||||
public CreateId MakeCreateId()
|
||||
{
|
||||
return new CreateId(Guid.NewGuid().ToByteArray());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue