aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/Utilities/EndianSwap.cs
blob: df08191ac610d5df57fb11bce9742d07c7a49e3e (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));
        }
    }
}