doompanning/linuxdoom-1.10/m_swap.c
oxmox 5342530c20 Squashed 'src/dp_doom/' content from commit 1909924
git-subtree-dir: src/dp_doom
git-subtree-split: 190992421c7c643afc99d7f7c511c162f65bea85
2023-02-19 01:52:56 +01:00

52 lines
1.2 KiB
C

// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// $Id:$
//
// Copyright (C) 1993-1996 by id Software, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Log:$
//
// DESCRIPTION:
// Endianess handling, swapping 16bit and 32bit.
//
//-----------------------------------------------------------------------------
#include "m_swap.h"
// Needed for big endian.
#ifdef __BIG_ENDIAN__
// Swap 16bit, that is, MSB and LSB byte.
unsigned short SwapSHORT(unsigned short x)
{
return
((x>>8) & 0xff)
| ((x<<8) & 0xff00);
}
// Swapping 32bit.
unsigned long SwapLONG( unsigned long x)
{
return
((x>>24) & 0xff)
| ((x>>8) & 0xff00)
| ((x<<8) & 0xff0000)
| ((x<<24) & 0xff000000);
}
#endif