aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/Utilities/EndianSwap.cs
blob: 5d0c8a845e3b799ebb4d9d6cfb3ba77234bf3a22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
namespace Ryujinx.HLE.Utilities
{
    static class EndianSwap
    {
        public static ushort Swap16(ushort Value) => (ushort)(((Value >> 8) & 0xff) | (Value << 8));

        public static int Swap32(int Value)
        {
            uint UintVal = (uint)Value;

            return (int)(((UintVal >> 24) & 0x000000ff) |
                         ((UintVal >>  8) & 0x0000ff00) |
                         ((UintVal <<  8) & 0x00ff0000) |
                         ((UintVal << 24) & 0xff000000));
        }
    }
}