home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2000 January / LCD_01_2000.iso / games / doom / sndserv / src / m_swap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-16  |  1.3 KB  |  48 lines

  1. /*  Emacs style mode select   -*- C++ -*-  */
  2. /* ----------------------------------------------------------------------------- */
  3. /*  */
  4. /*  $Id:$ */
  5. /*  */
  6. /*  Copyright (C) 1993-1996 by id Software, Inc. */
  7. /*  */
  8. /*  This source is available for distribution and/or modification */
  9. /*  only under the terms of the DOOM Source Code License as */
  10. /*  published by id Software. All rights reserved. */
  11. /*  */
  12. /*  The source is distributed in the hope that it will be useful, */
  13. /*  but WITHOUT ANY WARRANTY; without even the implied warranty of */
  14. /*  FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License */
  15. /*  for more details. */
  16. /*  */
  17. /*  $Log:$ */
  18. /*  */
  19. /*  DESCRIPTION: */
  20. /*     Endianess handling, swapping 16bit and 32bit. */
  21. /*  */
  22. /* ----------------------------------------------------------------------------- */
  23.  
  24. #include "m_swap.h"
  25.  
  26.  
  27. /*  Not needed with little endian. */
  28. #ifdef __BIG_ENDIAN__
  29.  
  30. /*  Swap 16bit, that is, MSB and LSB byte. */
  31. unsigned short SwapSHORT(unsigned short x)
  32. {
  33.     /*  No masking with 0xFF should be necessary.  */
  34.     return (x>>8) | (x<<8);
  35. }
  36.  
  37. /*  Swapping 32bit. */
  38. unsigned long SwapLONG( unsigned long x)
  39. {
  40.     return
  41.     (x>>24)
  42.     | ((x>>8) & 0xff00)
  43.     | ((x<<8) & 0xff0000)
  44.     | (x<<24);
  45. }
  46.  
  47. #endif
  48.