2018-08-16 16:47:36 -07:00
|
|
|
|
namespace Ryujinx.HLE.Utilities
|
2018-03-11 18:05:39 -07:00
|
|
|
|
{
|
|
|
|
|
static class EndianSwap
|
|
|
|
|
{
|
2018-12-06 03:16:24 -08:00
|
|
|
|
public static ushort Swap16(ushort value) => (ushort)(((value >> 8) & 0xff) | (value << 8));
|
2018-08-16 16:47:36 -07:00
|
|
|
|
|
2018-12-06 03:16:24 -08:00
|
|
|
|
public static int Swap32(int value)
|
2018-06-17 19:28:11 -07:00
|
|
|
|
{
|
2018-12-06 03:16:24 -08:00
|
|
|
|
uint uintVal = (uint)value;
|
2018-06-17 19:28:11 -07:00
|
|
|
|
|
2018-12-06 03:16:24 -08:00
|
|
|
|
return (int)(((uintVal >> 24) & 0x000000ff) |
|
|
|
|
|
((uintVal >> 8) & 0x0000ff00) |
|
|
|
|
|
((uintVal << 8) & 0x00ff0000) |
|
|
|
|
|
((uintVal << 24) & 0xff000000));
|
2018-06-17 19:28:11 -07:00
|
|
|
|
}
|
2018-03-11 18:05:39 -07:00
|
|
|
|
}
|
|
|
|
|
}
|