Odamex
Setting the Standard in Multiplayer Doom
common/m_swap.h
Go to the documentation of this file.
00001 // Emacs style mode select   -*- C++ -*- 
00002 //-----------------------------------------------------------------------------
00003 //
00004 // $Id: m_swap.h 1788 2010-08-24 04:42:57Z russellrice $
00005 //
00006 // Copyright (C) 1993-1996 by id Software, Inc.
00007 // Copyright (C) 2006-2010 by The Odamex Team.
00008 //
00009 // This program is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // DESCRIPTION:
00020 //      Endianess handling, swapping 16bit and 32bit.
00021 //
00022 //-----------------------------------------------------------------------------
00023 
00024 
00025 #ifndef __M_SWAP_H__
00026 #define __M_SWAP_H__
00027 
00028 #ifdef TARGET_CPU_X86
00029 #ifdef __BIG_ENDIAN__
00030 #undef __BIG_ENDIAN__
00031 #endif
00032 #endif
00033 
00034 #ifdef TARGET_CPU_PPC
00035 #ifndef __BIG_ENDIAN__
00036 #define __BIG_ENDIAN__
00037 #endif
00038 #endif
00039 
00040 // Endianess handling.
00041 // WAD files are stored little endian.
00042 #ifdef __BIG_ENDIAN__
00043 
00044 // Swap 16bit, that is, MSB and LSB byte.
00045 // No masking with 0xFF should be necessary. 
00046 short SHORT (short x);
00047 unsigned short SHORT (unsigned short x);
00048 
00049 // Swapping 32bit.
00050 unsigned int LONG (unsigned int x);
00051 int LONG (int x);
00052 
00053 #define BESHORT(x)              (x)
00054 #define BELONG(x)               (x)
00055 
00056 #else
00057 
00058 #define SHORT(x)                (x)
00059 #define LONG(x)                 (x)
00060 
00061 short BESHORT (short x);
00062 unsigned short BESHORT (unsigned short x);
00063 
00064 unsigned int BELONG (unsigned int x);
00065 int BELONG (int x);
00066 
00067 #endif // __BIG_ENDIAN__
00068 
00069 #endif // __M_SWAP_H__
00070 
00071 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends