Ryujinx/Ryujinx.HLE/Utilities/EndianSwap.cs

18 lines
518 B
C#
Raw Normal View History

namespace Ryujinx.HLE.Utilities
{
static class EndianSwap
{
2018-12-01 21:01:59 +01:00
public static ushort Swap16(ushort value) => (ushort)(((value >> 8) & 0xff) | (value << 8));
2018-12-01 21:01:59 +01:00
public static int Swap32(int value)
{
2018-12-01 21:01:59 +01:00
uint uintVal = (uint)value;
2018-12-01 21:01:59 +01:00
return (int)(((uintVal >> 24) & 0x000000ff) |
((uintVal >> 8) & 0x0000ff00) |
((uintVal << 8) & 0x00ff0000) |
((uintVal << 24) & 0xff000000));
}
}
}