home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / -screenplay- / otherstuff / adoomppc_src / m_swap.c < prev    next >
C/C++ Source or Header  |  1998-04-23  |  1KB  |  58 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. static const char
  25. rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
  26.  
  27.  
  28. #ifdef __GNUG__
  29. #pragma implementation "m_swap.h"
  30. #endif
  31. #include "m_swap.h"
  32.  
  33.  
  34. // Needed with big endian.
  35. #ifdef __BIG_ENDIAN__
  36.  
  37. // Swap 16bit, that is, MSB and LSB byte.
  38. unsigned short SwapSHORT(unsigned short x)
  39. {
  40.     // No masking with 0xFF should be necessary. 
  41.     return (unsigned short)((x>>8) | (x<<8));
  42. }
  43.  
  44. // Swapping 32bit.
  45. unsigned long SwapLONG( unsigned long x)
  46. {
  47.     return
  48.     (x>>24)
  49.     | ((x>>8) & 0xff00)
  50.     | ((x<<8) & 0xff0000)
  51.     | (x<<24);
  52. }
  53.  
  54.  
  55. #endif
  56.  
  57.  
  58.