File d2x-xl-1.18.73-byteswap.patch of Package d2x-xl
diff -Nur old/2d/bitblt.cpp new/2d/bitblt.cpp
--- old/2d/bitblt.cpp 2015-05-12 22:21:12.000000000 +0200
+++ new/2d/bitblt.cpp 2016-06-30 02:33:03.072296008 +0200
@@ -22,7 +22,7 @@
#include "grdef.h"
#include "rle.h"
#include "mono.h"
-#include "byteswap.h" // because of rle code that has int16_t for row offsets
+#include "d2x-xl-byteswap.h" // because of rle code that has int16_t for row offsets
#include "bitmap.h"
#include "ogl_defs.h"
#include "ogl_bitmap.h"
diff -Nur old/2d/font.cpp new/2d/font.cpp
--- old/2d/font.cpp 2015-06-23 00:38:53.000000000 +0200
+++ new/2d/font.cpp 2016-06-30 02:33:03.076296036 +0200
@@ -42,7 +42,7 @@
#include "error.h"
#include "cfile.h"
#include "mono.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "gamefont.h"
#include "makesig.h"
#include "ogl_defs.h"
diff -Nur old/2d/rle.cpp new/2d/rle.cpp
--- old/2d/rle.cpp 2015-05-31 13:10:34.000000000 +0200
+++ new/2d/rle.cpp 2016-06-30 02:33:03.076296036 +0200
@@ -27,7 +27,7 @@
#include "grdef.h"
#include "error.h"
#include "rle.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#define RLE_CODE 0xE0
#define NOT_RLE_CODE 31
diff -Nur old/2d/string.cpp new/2d/string.cpp
--- old/2d/string.cpp 2015-05-14 12:35:07.000000000 +0200
+++ new/2d/string.cpp 2016-06-30 02:33:03.076296036 +0200
@@ -42,7 +42,7 @@
#include "error.h"
#include "cfile.h"
#include "mono.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "gamefont.h"
#include "makesig.h"
diff -Nur old/3d/buildmodel.cpp new/3d/buildmodel.cpp
--- old/3d/buildmodel.cpp 2015-05-31 13:08:54.000000000 +0200
+++ new/3d/buildmodel.cpp 2016-06-30 02:33:03.076296036 +0200
@@ -12,7 +12,7 @@
#include "hitbox.h"
#include "globvars.h"
#include "gr.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "u_mem.h"
#include "console.h"
#include "ogl_defs.h"
diff -Nur old/3d/fastmodels.cpp new/3d/fastmodels.cpp
--- old/3d/fastmodels.cpp 2015-06-24 11:01:33.000000000 +0200
+++ new/3d/fastmodels.cpp 2016-06-30 02:33:03.076296036 +0200
@@ -12,7 +12,7 @@
#include "hitbox.h"
#include "globvars.h"
#include "gr.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "u_mem.h"
#include "console.h"
#include "ogl_defs.h"
diff -Nur old/3d/hitbox.cpp new/3d/hitbox.cpp
--- old/3d/hitbox.cpp 2015-05-31 13:08:54.000000000 +0200
+++ new/3d/hitbox.cpp 2016-06-30 02:33:03.076296036 +0200
@@ -24,7 +24,7 @@
#include "interp.h"
#include "hitbox.h"
#include "gr.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "u_mem.h"
#include "console.h"
#include "ogl_defs.h"
diff -Nur old/3d/interp.cpp new/3d/interp.cpp
--- old/3d/interp.cpp 2015-06-02 10:22:04.000000000 +0200
+++ new/3d/interp.cpp 2016-06-30 02:33:03.076296036 +0200
@@ -25,7 +25,7 @@
#include "hitbox.h"
#include "globvars.h"
#include "gr.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "u_mem.h"
#include "console.h"
#include "ogl_defs.h"
diff -Nur old/3d/shadows.cpp new/3d/shadows.cpp
--- old/3d/shadows.cpp 2015-05-31 13:14:20.000000000 +0200
+++ new/3d/shadows.cpp 2016-06-30 02:33:03.076296036 +0200
@@ -24,7 +24,7 @@
#include "shadows.h"
#include "globvars.h"
#include "gr.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "u_mem.h"
#include "console.h"
#include "ogl_defs.h"
diff -Nur old/audio/linux/hmpfile.cpp new/audio/linux/hmpfile.cpp
--- old/audio/linux/hmpfile.cpp 2014-07-03 00:13:28.000000000 +0200
+++ new/audio/linux/hmpfile.cpp 2016-06-30 02:33:03.076296036 +0200
@@ -15,7 +15,7 @@
#include "cfile.h"
#include "u_mem.h"
#include "error.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#ifdef _WIN32
extern void PumpMessages(void);
diff -Nur old/audio/win32/hmpfile.cpp new/audio/win32/hmpfile.cpp
--- old/audio/win32/hmpfile.cpp 2014-07-02 19:59:17.000000000 +0200
+++ new/audio/win32/hmpfile.cpp 2016-06-30 02:33:03.080296063 +0200
@@ -5,7 +5,7 @@
#include "descent.h"
#include "hmpfile.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "u_mem.h"
//------------------------------------------------------------------------------
diff -Nur old/gameio/createmesh.cpp new/gameio/createmesh.cpp
--- old/gameio/createmesh.cpp 2015-08-01 23:28:49.000000000 +0200
+++ new/gameio/createmesh.cpp 2016-06-30 02:33:03.080296063 +0200
@@ -38,7 +38,7 @@
#include "key.h"
#include "piggy.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "loadobjects.h"
#include "u_mem.h"
#include "vecmat.h"
diff -Nur old/gameio/facegrid.cpp new/gameio/facegrid.cpp
--- old/gameio/facegrid.cpp 2015-07-13 12:06:37.000000000 +0200
+++ new/gameio/facegrid.cpp 2016-06-30 02:33:03.080296063 +0200
@@ -13,7 +13,7 @@
#include "descent.h"
#include "error.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "vecmat.h"
#include "maths.h"
diff -Nur old/gameio/hoard.cpp new/gameio/hoard.cpp
--- old/gameio/hoard.cpp 2015-05-31 13:17:42.000000000 +0200
+++ new/gameio/hoard.cpp 2016-06-30 02:33:03.080296063 +0200
@@ -21,7 +21,7 @@
#include "kconfig.h"
#include "config.h"
#include "textures.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "sounds.h"
#include "args.h"
#include "cfile.h"
diff -Nur old/gameio/loadgamedata.cpp new/gameio/loadgamedata.cpp
--- old/gameio/loadgamedata.cpp 2015-06-08 22:33:02.000000000 +0200
+++ new/gameio/loadgamedata.cpp 2016-06-30 02:33:03.080296063 +0200
@@ -52,7 +52,7 @@
#include "makesig.h"
#include "interp.h"
#include "light.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "network.h"
#define PRINT_WEAPON_INFO 0
diff -Nur old/gameio/loadgeometry.cpp new/gameio/loadgeometry.cpp
--- old/gameio/loadgeometry.cpp 2015-06-20 10:51:56.000000000 +0200
+++ new/gameio/loadgeometry.cpp 2016-06-30 02:33:03.080296063 +0200
@@ -52,7 +52,7 @@
#include "key.h"
#include "piggy.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "loadobjects.h"
#include "u_mem.h"
#include "vecmat.h"
diff -Nur old/gameio/loadmodeldata.cpp new/gameio/loadmodeldata.cpp
--- old/gameio/loadmodeldata.cpp 2015-07-13 12:06:37.000000000 +0200
+++ new/gameio/loadmodeldata.cpp 2016-06-30 02:33:03.080296063 +0200
@@ -52,7 +52,7 @@
#include "makesig.h"
#include "interp.h"
#include "light.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
//------------------------------------------------------------------------------
//these values are the number of each item in the release of d2
diff -Nur old/gameio/loadobjects.cpp new/gameio/loadobjects.cpp
--- old/gameio/loadobjects.cpp 2015-06-27 12:12:06.000000000 +0200
+++ new/gameio/loadobjects.cpp 2016-06-30 02:33:03.080296063 +0200
@@ -53,7 +53,7 @@
#include "loadobjects.h"
#include "gamepal.h"
#include "fireweapon.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "multi.h"
#include "makesig.h"
#include "segmath.h"
diff -Nur old/gameio/loadsounds.cpp new/gameio/loadsounds.cpp
--- old/gameio/loadsounds.cpp 2015-08-16 20:45:50.000000000 +0200
+++ new/gameio/loadsounds.cpp 2016-06-30 02:33:03.080296063 +0200
@@ -51,7 +51,7 @@
#include "text.h"
#include "cfile.h"
#include "menu.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "findfile.h"
#include "makesig.h"
#include "effects.h"
diff -Nur old/gameio/loadtextures.cpp new/gameio/loadtextures.cpp
--- old/gameio/loadtextures.cpp 2016-01-03 15:03:22.000000000 +0100
+++ new/gameio/loadtextures.cpp 2016-06-30 02:33:03.084296090 +0200
@@ -52,7 +52,7 @@
#include "text.h"
#include "cfile.h"
#include "menu.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "findfile.h"
#include "makesig.h"
#include "effects.h"
diff -Nur old/gameio/piggy.cpp new/gameio/piggy.cpp
--- old/gameio/piggy.cpp 2015-06-08 22:23:16.000000000 +0200
+++ new/gameio/piggy.cpp 2016-06-30 02:33:03.084296090 +0200
@@ -49,7 +49,7 @@
#include "text.h"
#include "cfile.h"
#include "menu.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "findfile.h"
#include "makesig.h"
#include "effects.h"
diff -Nur old/gameio/playerprofile.cpp new/gameio/playerprofile.cpp
--- old/gameio/playerprofile.cpp 2015-07-16 19:19:14.000000000 +0200
+++ new/gameio/playerprofile.cpp 2016-06-30 02:33:03.084296090 +0200
@@ -52,7 +52,7 @@
#include "screens.h"
#include "powerup.h"
#include "makesig.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "escort.h"
#include "network.h"
#include "network_lib.h"
diff -Nur old/include/byteswap.h new/include/byteswap.h
--- old/include/byteswap.h 2014-07-21 13:26:41.000000000 +0200
+++ new/include/byteswap.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,282 +0,0 @@
-/*
-THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
-SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
-END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
-ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
-IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
-SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
-FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
-CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
-AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
-COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
-*/
-
-#ifndef _BYTESWAP_H
-#define _BYTESWAP_H
-
-#include <string.h>
-#include "pstypes.h"
-#include "descent.h"
-#include "vecmat.h"
-
-// ----------------------------------------------------------------------------
-
-#define SWAP(_h,_a,_b) (_h) = (_a), (_a) = (_b), (_b) = (_h)
-
-// ----------------------------------------------------------------------------
-
-typedef union dSwap {
- double d;
- char b [8];
-} dSwap;
-
-#define DSWAP(_d) (reinterpret_cast<dSwap *> (&(_d)))
-
-static inline double SWAPDOUBLE (double i)
-{
-char h;
-#if 0
-dSwap s;
-
-s.i = i;
-h = s[BA][0];
-s[BA][0] = s[BA][7];
-s[BA][7] = h;
-h = s[BA][1];
-s[BA][1] = s[BA][6];
-s[BA][6] = h;
-h = s[BA][2];
-s[BA][2] = s[BA][5];
-s[BA][5] = h;
-h = s[BA][3];
-s[BA][3] = s[BA][4];
-s[BA][4] = h;
-return s.d;
-#else
-SWAP (h, DSWAP (i)->b [0], DSWAP (i)->b [7]);
-SWAP (h, DSWAP (i)->b [1], DSWAP (i)->b [6]);
-SWAP (h, DSWAP (i)->b [2], DSWAP (i)->b [5]);
-SWAP (h, DSWAP (i)->b [3], DSWAP (i)->b [4]);
-return DSWAP (i)->d;
-#endif
-}
-
-static inline double SwapDouble (double i, int32_t bEndian)
-{
-if (gameStates.app.bLittleEndian == bEndian)
- return i;
-return SWAPDOUBLE (i);
-}
-
-// ----------------------------------------------------------------------------
-
-typedef union fSwap {
- float f;
- char b [4];
-} fSwap;
-
-#define FSWAP(_f) (reinterpret_cast<fSwap *> (&(_f)))
-
-static inline float SWAPFLOAT (float i)
-{
-char h;
-#if 0
-fSwap s;
-
-s.i = i;
-h = s[BA][0];
-s[BA][0] = s[BA][3];
-s[BA][3] = h;
-h = s[BA][1];
-s[BA][1] = s[BA][2];
-s[BA][2] = h;
-return s.i;
-#else
-SWAP (h, FSWAP (i)->b [0], FSWAP (i)->b [3]);
-SWAP (h, FSWAP (i)->b [1], FSWAP (i)->b [2]);
-return FSWAP (i)->f;
-#endif
-}
-
-static inline float SwapFloat (float i, int32_t bEndian)
-{
-if (gameStates.app.bLittleEndian == bEndian)
- return i;
-return SWAPFLOAT (i);
-}
-
-// ----------------------------------------------------------------------------
-
-typedef union iSwap {
- int32_t i;
- char b [4];
-} iSwap;
-
-#define ISWAP(_i) (reinterpret_cast<iSwap *> (&(_i)))
-
-static inline int32_t SWAPINT (int32_t i)
-{
-char h;
-SWAP (h, ISWAP (i)->b [0], ISWAP (i)->b [3]);
-SWAP (h, ISWAP (i)->b [1], ISWAP (i)->b [2]);
-return ISWAP (i)->i;
-}
-
-static inline int32_t SwapInt (int32_t i, int32_t bEndian)
-{
-if (gameStates.app.bLittleEndian == bEndian)
- return i;
-return SWAPINT (i);
-}
-
-// ----------------------------------------------------------------------------
-
-typedef union sSwap {
- int16_t s;
- char b [2];
-} sSwap;
-
-#define SSWAP(_s) (reinterpret_cast<sSwap *> (&(_s)))
-
-static inline int16_t SWAPSHORT (int16_t i)
-{
-char h;
-SWAP (h, SSWAP (i)->b [0], SSWAP (i)->b [1]);
-return SSWAP (i)->s;
-}
-
-static inline int32_t SwapShort (int16_t i, int32_t bEndian)
-{
-if (gameStates.app.bLittleEndian == bEndian)
- return i;
-return SWAPSHORT (i);
-}
-
-// ----------------------------------------------------------------------------
-
-typedef union usSwap {
- uint16_t s;
- uint8_t b [2];
-} usSwap;
-
-#define USSWAP(_s) (reinterpret_cast<usSwap *> (&(_s)))
-
-static inline int16_t SWAPUSHORT (uint16_t i)
-{
-uint8_t h;
-SWAP (h, USSWAP (i)->b [0], USSWAP (i)->b [1]);
-return USSWAP (i)->s;
-}
-
-static inline int32_t SwapUShort (uint16_t i, int32_t bEndian)
-{
-if (gameStates.app.bLittleEndian == bEndian)
- return i;
-return SWAPUSHORT (i);
-}
-
-// ----------------------------------------------------------------------------
-
-static inline CFixVector& SwapVector (CFixVector& v, int32_t bEndian)
-{
-if (gameStates.app.bLittleEndian != bEndian) {
- v.v.coord.x = (fix) SWAPINT ((int32_t) v.v.coord.x);
- v.v.coord.y = (fix) SWAPINT ((int32_t) v.v.coord.y);
- v.v.coord.z = (fix) SWAPINT ((int32_t) v.v.coord.z);
- }
-return v;
-}
-
-// ----------------------------------------------------------------------------
-
-static inline CAngleVector& SwapAngVec (CAngleVector& v, int32_t bEndian)
-{
-if (gameStates.app.bLittleEndian != bEndian) {
- v.v.coord.p = (fixang) SWAPSHORT ((int16_t) v.v.coord.p);
- v.v.coord.b = (fixang) SWAPSHORT ((int16_t) v.v.coord.b);
- v.v.coord.h = (fixang) SWAPSHORT ((int16_t) v.v.coord.h);
- }
-return v;
-}
-
-// ----------------------------------------------------------------------------
-
-static inline CFixMatrix& SwapMatrix (CFixMatrix& m, int32_t bEndian)
-{
-if (gameStates.app.bLittleEndian != bEndian) {
- SwapVector (m.m.dir.r, bEndian);
- SwapVector (m.m.dir.u, bEndian);
- SwapVector (m.m.dir.f, bEndian);
- }
-return m;
-}
-
-// ----------------------------------------------------------------------------
-
-#define INTEL_INT(_x) SwapInt(_x,1)
-#define INTEL_SHORT(_x) SwapShort(_x,1)
-#define INTEL_FLOAT(_x) SwapFloat(_x,1)
-#define INTEL_DOUBLE(_x) SwapDouble(_x,1)
-#define INTEL_VECTOR(_v) SwapVector(_v,1)
-#define INTEL_ANGVEC(_v) SwapAngVec(_v,1)
-#define INTEL_MATRIX(_m) SwapMatrix(_m,1)
-#define BE_INT(_x) SwapInt(_x,0)
-#define BE_SHORT(_x) SwapShort(_x,0)
-
-#ifndef WORDS_NEED_ALIGNMENT
-
-#if 0
-
-// this causes dereferencing type punned pointer warnings from g++
-#define GET_INTEL_INT(s) INTEL_INT(*reinterpret_cast<uint32_t *>(s))
-#define GET_INTEL_SHORT(s) INTEL_SHORT(*reinterpret_cast<uint16_t *>(s))
-#define PUT_INTEL_INT(d, s) { *reinterpret_cast<uint32_t *>(d) = INTEL_INT((uint32_t)(s)); }
-#define PUT_INTEL_SHORT(d, s) { *reinterpret_cast<uint16_t *>(d) = INTEL_SHORT((uint16_t)(s)); }
-
-#else
-
-static inline uint32_t GET_INTEL_INT (void *s)
-{
-return INTEL_INT (*reinterpret_cast<uint32_t*> (s));
-}
-
-static inline uint16_t GET_INTEL_SHORT (void *s)
-{
-return INTEL_SHORT (*reinterpret_cast<uint16_t*> (s));
-}
-
-static inline void PUT_INTEL_INT (void *d, uint32_t s)
-{
-*reinterpret_cast<uint32_t*> (d) = INTEL_INT (s);
-}
-
-static inline void PUT_INTEL_SHORT (void *d, uint16_t s)
-{
-*reinterpret_cast<uint16_t*> (d) = INTEL_SHORT (s);
-}
-
-#endif
-
-#else // ! WORDS_NEED_ALIGNMENT
-
-static inline uint32_t GET_INTEL_INT(void *s)
-{
-uint32_t tmp;
-memcpy (reinterpret_cast<void *>&tmp, s, 4);
-return INTEL_INT (tmp);
-}
-
-static inline uint32_t GET_INTEL_SHORT (void *s)
-{
-uint16_t tmp;
-memcpy (reinterpret_cast<void *>&tmp, s, 2);
-return INTEL_SHORT (tmp);
-}
-
-#define PUT_INTEL_INT(d, s) { uint32_t tmp = INTEL_INT(s); memcpy(reinterpret_cast<void *>(d), reinterpret_cast<void *>&tmp, 4); }
-
-#define PUT_INTEL_SHORT(d, s) { uint16_t tmp = INTEL_SHORT(s); memcpy(reinterpret_cast<void *>(d), reinterpret_cast<void *>&tmp, 2); }
-
-#endif // ! WORDS_NEED_ALIGNMENT
-
-#endif // ! _BYTESWAP_H
diff -Nur old/include/d2x-xl-byteswap.h new/include/d2x-xl-byteswap.h
--- old/include/d2x-xl-byteswap.h 1970-01-01 01:00:00.000000000 +0100
+++ new/include/d2x-xl-byteswap.h 2016-06-30 02:38:51.818608830 +0200
@@ -0,0 +1,282 @@
+/*
+THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
+SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
+END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
+ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
+IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
+SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
+FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
+CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
+AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
+COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
+*/
+
+#ifndef _D2X_BYTESWAP_H
+#define _D2X_BYTESWAP_H
+
+#include <string.h>
+#include "pstypes.h"
+#include "descent.h"
+#include "vecmat.h"
+
+// ----------------------------------------------------------------------------
+
+#define SWAP(_h,_a,_b) (_h) = (_a), (_a) = (_b), (_b) = (_h)
+
+// ----------------------------------------------------------------------------
+
+typedef union dSwap {
+ double d;
+ char b [8];
+} dSwap;
+
+#define DSWAP(_d) (reinterpret_cast<dSwap *> (&(_d)))
+
+static inline double SWAPDOUBLE (double i)
+{
+char h;
+#if 0
+dSwap s;
+
+s.i = i;
+h = s[BA][0];
+s[BA][0] = s[BA][7];
+s[BA][7] = h;
+h = s[BA][1];
+s[BA][1] = s[BA][6];
+s[BA][6] = h;
+h = s[BA][2];
+s[BA][2] = s[BA][5];
+s[BA][5] = h;
+h = s[BA][3];
+s[BA][3] = s[BA][4];
+s[BA][4] = h;
+return s.d;
+#else
+SWAP (h, DSWAP (i)->b [0], DSWAP (i)->b [7]);
+SWAP (h, DSWAP (i)->b [1], DSWAP (i)->b [6]);
+SWAP (h, DSWAP (i)->b [2], DSWAP (i)->b [5]);
+SWAP (h, DSWAP (i)->b [3], DSWAP (i)->b [4]);
+return DSWAP (i)->d;
+#endif
+}
+
+static inline double SwapDouble (double i, int32_t bEndian)
+{
+if (gameStates.app.bLittleEndian == bEndian)
+ return i;
+return SWAPDOUBLE (i);
+}
+
+// ----------------------------------------------------------------------------
+
+typedef union fSwap {
+ float f;
+ char b [4];
+} fSwap;
+
+#define FSWAP(_f) (reinterpret_cast<fSwap *> (&(_f)))
+
+static inline float SWAPFLOAT (float i)
+{
+char h;
+#if 0
+fSwap s;
+
+s.i = i;
+h = s[BA][0];
+s[BA][0] = s[BA][3];
+s[BA][3] = h;
+h = s[BA][1];
+s[BA][1] = s[BA][2];
+s[BA][2] = h;
+return s.i;
+#else
+SWAP (h, FSWAP (i)->b [0], FSWAP (i)->b [3]);
+SWAP (h, FSWAP (i)->b [1], FSWAP (i)->b [2]);
+return FSWAP (i)->f;
+#endif
+}
+
+static inline float SwapFloat (float i, int32_t bEndian)
+{
+if (gameStates.app.bLittleEndian == bEndian)
+ return i;
+return SWAPFLOAT (i);
+}
+
+// ----------------------------------------------------------------------------
+
+typedef union iSwap {
+ int32_t i;
+ char b [4];
+} iSwap;
+
+#define ISWAP(_i) (reinterpret_cast<iSwap *> (&(_i)))
+
+static inline int32_t SWAPINT (int32_t i)
+{
+char h;
+SWAP (h, ISWAP (i)->b [0], ISWAP (i)->b [3]);
+SWAP (h, ISWAP (i)->b [1], ISWAP (i)->b [2]);
+return ISWAP (i)->i;
+}
+
+static inline int32_t SwapInt (int32_t i, int32_t bEndian)
+{
+if (gameStates.app.bLittleEndian == bEndian)
+ return i;
+return SWAPINT (i);
+}
+
+// ----------------------------------------------------------------------------
+
+typedef union sSwap {
+ int16_t s;
+ char b [2];
+} sSwap;
+
+#define SSWAP(_s) (reinterpret_cast<sSwap *> (&(_s)))
+
+static inline int16_t SWAPSHORT (int16_t i)
+{
+char h;
+SWAP (h, SSWAP (i)->b [0], SSWAP (i)->b [1]);
+return SSWAP (i)->s;
+}
+
+static inline int32_t SwapShort (int16_t i, int32_t bEndian)
+{
+if (gameStates.app.bLittleEndian == bEndian)
+ return i;
+return SWAPSHORT (i);
+}
+
+// ----------------------------------------------------------------------------
+
+typedef union usSwap {
+ uint16_t s;
+ uint8_t b [2];
+} usSwap;
+
+#define USSWAP(_s) (reinterpret_cast<usSwap *> (&(_s)))
+
+static inline int16_t SWAPUSHORT (uint16_t i)
+{
+uint8_t h;
+SWAP (h, USSWAP (i)->b [0], USSWAP (i)->b [1]);
+return USSWAP (i)->s;
+}
+
+static inline int32_t SwapUShort (uint16_t i, int32_t bEndian)
+{
+if (gameStates.app.bLittleEndian == bEndian)
+ return i;
+return SWAPUSHORT (i);
+}
+
+// ----------------------------------------------------------------------------
+
+static inline CFixVector& SwapVector (CFixVector& v, int32_t bEndian)
+{
+if (gameStates.app.bLittleEndian != bEndian) {
+ v.v.coord.x = (fix) SWAPINT ((int32_t) v.v.coord.x);
+ v.v.coord.y = (fix) SWAPINT ((int32_t) v.v.coord.y);
+ v.v.coord.z = (fix) SWAPINT ((int32_t) v.v.coord.z);
+ }
+return v;
+}
+
+// ----------------------------------------------------------------------------
+
+static inline CAngleVector& SwapAngVec (CAngleVector& v, int32_t bEndian)
+{
+if (gameStates.app.bLittleEndian != bEndian) {
+ v.v.coord.p = (fixang) SWAPSHORT ((int16_t) v.v.coord.p);
+ v.v.coord.b = (fixang) SWAPSHORT ((int16_t) v.v.coord.b);
+ v.v.coord.h = (fixang) SWAPSHORT ((int16_t) v.v.coord.h);
+ }
+return v;
+}
+
+// ----------------------------------------------------------------------------
+
+static inline CFixMatrix& SwapMatrix (CFixMatrix& m, int32_t bEndian)
+{
+if (gameStates.app.bLittleEndian != bEndian) {
+ SwapVector (m.m.dir.r, bEndian);
+ SwapVector (m.m.dir.u, bEndian);
+ SwapVector (m.m.dir.f, bEndian);
+ }
+return m;
+}
+
+// ----------------------------------------------------------------------------
+
+#define INTEL_INT(_x) SwapInt(_x,1)
+#define INTEL_SHORT(_x) SwapShort(_x,1)
+#define INTEL_FLOAT(_x) SwapFloat(_x,1)
+#define INTEL_DOUBLE(_x) SwapDouble(_x,1)
+#define INTEL_VECTOR(_v) SwapVector(_v,1)
+#define INTEL_ANGVEC(_v) SwapAngVec(_v,1)
+#define INTEL_MATRIX(_m) SwapMatrix(_m,1)
+#define BE_INT(_x) SwapInt(_x,0)
+#define BE_SHORT(_x) SwapShort(_x,0)
+
+#ifndef WORDS_NEED_ALIGNMENT
+
+#if 0
+
+// this causes dereferencing type punned pointer warnings from g++
+#define GET_INTEL_INT(s) INTEL_INT(*reinterpret_cast<uint32_t *>(s))
+#define GET_INTEL_SHORT(s) INTEL_SHORT(*reinterpret_cast<uint16_t *>(s))
+#define PUT_INTEL_INT(d, s) { *reinterpret_cast<uint32_t *>(d) = INTEL_INT((uint32_t)(s)); }
+#define PUT_INTEL_SHORT(d, s) { *reinterpret_cast<uint16_t *>(d) = INTEL_SHORT((uint16_t)(s)); }
+
+#else
+
+static inline uint32_t GET_INTEL_INT (void *s)
+{
+return INTEL_INT (*reinterpret_cast<uint32_t*> (s));
+}
+
+static inline uint16_t GET_INTEL_SHORT (void *s)
+{
+return INTEL_SHORT (*reinterpret_cast<uint16_t*> (s));
+}
+
+static inline void PUT_INTEL_INT (void *d, uint32_t s)
+{
+*reinterpret_cast<uint32_t*> (d) = INTEL_INT (s);
+}
+
+static inline void PUT_INTEL_SHORT (void *d, uint16_t s)
+{
+*reinterpret_cast<uint16_t*> (d) = INTEL_SHORT (s);
+}
+
+#endif
+
+#else // ! WORDS_NEED_ALIGNMENT
+
+static inline uint32_t GET_INTEL_INT(void *s)
+{
+uint32_t tmp;
+memcpy (reinterpret_cast<void *>&tmp, s, 4);
+return INTEL_INT (tmp);
+}
+
+static inline uint32_t GET_INTEL_SHORT (void *s)
+{
+uint16_t tmp;
+memcpy (reinterpret_cast<void *>&tmp, s, 2);
+return INTEL_SHORT (tmp);
+}
+
+#define PUT_INTEL_INT(d, s) { uint32_t tmp = INTEL_INT(s); memcpy(reinterpret_cast<void *>(d), reinterpret_cast<void *>&tmp, 4); }
+
+#define PUT_INTEL_SHORT(d, s) { uint16_t tmp = INTEL_SHORT(s); memcpy(reinterpret_cast<void *>(d), reinterpret_cast<void *>&tmp, 2); }
+
+#endif // ! WORDS_NEED_ALIGNMENT
+
+#endif // ! _BYTESWAP_H
diff -Nur old/include/interp.h new/include/interp.h
--- old/include/interp.h 2015-05-31 13:08:54.000000000 +0200
+++ new/include/interp.h 2016-06-30 02:33:03.084296090 +0200
@@ -135,7 +135,7 @@
//------------------------------------------------------------------------------
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
static inline void ShortSwap (int16_t *s)
{
diff -Nur old/include/ipx_udp_lib.h new/include/ipx_udp_lib.h
--- old/include/ipx_udp_lib.h 2012-03-11 15:45:47.000000000 +0100
+++ new/include/ipx_udp_lib.h 2016-06-30 02:33:03.084296090 +0200
@@ -32,7 +32,7 @@
#include "error.h"
#include "args.h"
#include "u_mem.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#define MSGHDR "IPX_udp: "
diff -Nur old/io/cfile.cpp new/io/cfile.cpp
--- old/io/cfile.cpp 2015-05-09 19:56:27.000000000 +0200
+++ new/io/cfile.cpp 2016-06-30 02:33:03.084296090 +0200
@@ -32,7 +32,7 @@
#include "error.h"
#include "cfile.h"
#include "hogfile.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "mission.h"
#include "console.h"
#include "findfile.h"
diff -Nur old/io/hogfile.cpp new/io/hogfile.cpp
--- old/io/hogfile.cpp 2015-05-12 22:29:14.000000000 +0200
+++ new/io/hogfile.cpp 2016-06-30 02:33:03.084296090 +0200
@@ -31,7 +31,7 @@
#include "error.h"
#include "cfile.h"
#include "hogfile.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "mission.h"
#include "console.h"
#include "findfile.h"
diff -Nur old/main/findpath.cpp new/main/findpath.cpp
--- old/main/findpath.cpp 2015-06-17 01:10:52.000000000 +0200
+++ new/main/findpath.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -24,7 +24,7 @@
#include "segment.h"
#include "segmath.h"
#include "findpath.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#define USE_DACS 0
#define USE_FCD_CACHE 1
diff -Nur old/main/findsegment.cpp new/main/findsegment.cpp
--- old/main/findsegment.cpp 2015-06-12 15:56:37.000000000 +0200
+++ new/main/findsegment.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -24,7 +24,7 @@
#include "error.h"
#include "mono.h"
#include "segmath.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "light.h"
#include "segment.h"
diff -Nur old/main/gameseg.cpp new/main/gameseg.cpp
--- old/main/gameseg.cpp 2009-12-22 10:34:38.000000000 +0100
+++ new/main/gameseg.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -24,7 +24,7 @@
#include "error.h"
#include "mono.h"
#include "gameseg.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "light.h"
#include "segment.h"
diff -Nur old/main/meshedge.cpp new/main/meshedge.cpp
--- old/main/meshedge.cpp 2015-09-03 11:54:42.000000000 +0200
+++ new/main/meshedge.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -13,7 +13,7 @@
#include "descent.h"
#include "error.h"
#include "segment.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "vecmat.h"
#include "maths.h"
diff -Nur old/main/movie.cpp new/main/movie.cpp
--- old/main/movie.cpp 2015-05-31 13:08:15.000000000 +0200
+++ new/main/movie.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -32,7 +32,7 @@
#include "strutil.h"
#include "error.h"
#include "u_mem.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "ogl_render.h"
#include "ogl_bitmap.h"
#include "gamefont.h"
diff -Nur old/main/segmath.cpp new/main/segmath.cpp
--- old/main/segmath.cpp 2015-05-09 19:10:41.000000000 +0200
+++ new/main/segmath.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -24,7 +24,7 @@
#include "error.h"
#include "mono.h"
#include "segmath.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "light.h"
#include "segment.h"
diff -Nur old/main/side.cpp new/main/side.cpp
--- old/main/side.cpp 2015-07-04 21:14:07.000000000 +0200
+++ new/main/side.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -24,7 +24,7 @@
#include "error.h"
#include "mono.h"
#include "segmath.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "light.h"
#include "segment.h"
#include "renderlib.h"
diff -Nur old/menus/entropymenu.cpp new/menus/entropymenu.cpp
--- old/menus/entropymenu.cpp 2014-07-02 19:59:15.000000000 +0200
+++ new/menus/entropymenu.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -26,7 +26,7 @@
#include "network_lib.h"
#include "menu.h"
#include "text.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "netmisc.h"
#include "kconfig.h"
#include "autodl.h"
diff -Nur old/menus/monsterballmenu.cpp new/menus/monsterballmenu.cpp
--- old/menus/monsterballmenu.cpp 2014-07-02 19:59:15.000000000 +0200
+++ new/menus/monsterballmenu.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -26,7 +26,7 @@
#include "network_lib.h"
#include "menu.h"
#include "text.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "netmisc.h"
#include "kconfig.h"
#include "autodl.h"
diff -Nur old/menus/netgamebrowser.cpp new/menus/netgamebrowser.cpp
--- old/menus/netgamebrowser.cpp 2014-07-25 23:01:57.000000000 +0200
+++ new/menus/netgamebrowser.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -26,7 +26,7 @@
#include "network_lib.h"
#include "menu.h"
#include "text.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "netmisc.h"
#include "kconfig.h"
#include "autodl.h"
diff -Nur old/menus/netgamehelp.cpp new/menus/netgamehelp.cpp
--- old/menus/netgamehelp.cpp 2015-05-31 13:16:49.000000000 +0200
+++ new/menus/netgamehelp.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -26,7 +26,7 @@
#include "network_lib.h"
#include "menu.h"
#include "text.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "netmisc.h"
#include "kconfig.h"
#include "autodl.h"
diff -Nur old/menus/netgameinfo.cpp new/menus/netgameinfo.cpp
--- old/menus/netgameinfo.cpp 2015-06-07 02:17:59.000000000 +0200
+++ new/menus/netgameinfo.cpp 2016-06-30 02:33:03.088296117 +0200
@@ -26,7 +26,7 @@
#include "network_lib.h"
#include "menu.h"
#include "text.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "netmisc.h"
#include "kconfig.h"
#include "autodl.h"
diff -Nur old/menus/netmenu.cpp new/menus/netmenu.cpp
--- old/menus/netmenu.cpp 2015-05-31 13:17:42.000000000 +0200
+++ new/menus/netmenu.cpp 2016-06-30 02:33:03.092296144 +0200
@@ -26,7 +26,7 @@
#include "network_lib.h"
#include "menu.h"
#include "text.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "netmisc.h"
#include "kconfig.h"
#include "autodl.h"
diff -Nur old/menus/netplayerbrowser.cpp new/menus/netplayerbrowser.cpp
--- old/menus/netplayerbrowser.cpp 2015-05-09 20:21:37.000000000 +0200
+++ new/menus/netplayerbrowser.cpp 2016-06-30 02:33:03.092296144 +0200
@@ -26,7 +26,7 @@
#include "network_lib.h"
#include "menu.h"
#include "text.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "netmisc.h"
#include "kconfig.h"
#include "autodl.h"
diff -Nur old/network/autodl.cpp new/network/autodl.cpp
--- old/network/autodl.cpp 2015-05-29 23:57:53.000000000 +0200
+++ new/network/autodl.cpp 2016-06-30 02:33:03.092296144 +0200
@@ -28,7 +28,7 @@
#include "key.h"
#include "menu.h"
#include "menu.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "text.h"
#include "strutil.h"
#include "error.h"
diff -Nur old/network/linux/linuxnet.cpp new/network/linux/linuxnet.cpp
--- old/network/linux/linuxnet.cpp 2014-07-15 17:43:44.000000000 +0200
+++ new/network/linux/linuxnet.cpp 2016-06-30 02:33:03.092296144 +0200
@@ -53,7 +53,7 @@
//added 05/17/99 Matt Mueller - needed to redefine FD_* so that no asm is used
//#include "checker.h"
//end addition -MM
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "network.h"
#include "network_lib.h"
#include "player.h" /* for gameData.multiplayer.players */
diff -Nur old/network/multibot.cpp new/network/multibot.cpp
--- old/network/multibot.cpp 2015-05-31 13:17:42.000000000 +0200
+++ new/network/multibot.cpp 2016-06-30 02:33:03.092296144 +0200
@@ -30,7 +30,7 @@
#include "dropobject.h"
#include "fireball.h"
#include "physics.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "segmath.h"
int32_t MultiAddControlledRobot (int32_t nObject, int32_t agitation);
diff -Nur old/network/multi.cpp new/network/multi.cpp
--- old/network/multi.cpp 2015-06-10 22:58:14.000000000 +0200
+++ new/network/multi.cpp 2016-06-30 02:33:03.092296144 +0200
@@ -44,7 +44,7 @@
#include "segmath.h"
#include "physics.h"
#include "savegame.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "rendermine.h"
#include "multimsg.h"
#include "entropy.h"
diff -Nur old/network/multimsg.cpp new/network/multimsg.cpp
--- old/network/multimsg.cpp 2015-05-31 13:17:42.000000000 +0200
+++ new/network/multimsg.cpp 2016-06-30 02:33:03.092296144 +0200
@@ -14,7 +14,7 @@
#include "strutil.h"
#include "network.h"
#include "error.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "key.h"
#include "banlist.h"
#include "text.h"
diff -Nur old/network/netmisc-new.cpp new/network/netmisc-new.cpp
--- old/network/netmisc-new.cpp 2015-04-09 23:22:26.000000000 +0200
+++ new/network/netmisc-new.cpp 2016-06-30 02:33:03.096296172 +0200
@@ -22,7 +22,7 @@
#include "descent.h"
#include "pstypes.h"
#include "mono.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#if defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__)
diff -Nur old/network/netmisc-old.cpp new/network/netmisc-old.cpp
--- old/network/netmisc-old.cpp 2014-06-09 13:15:35.000000000 +0200
+++ new/network/netmisc-old.cpp 2016-06-30 02:33:03.096296172 +0200
@@ -27,7 +27,7 @@
#if 1 //defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__)
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "segment.h"
#include "gameseg.h"
#include "network.h"
diff -Nur old/network/network.cpp new/network/network.cpp
--- old/network/network.cpp 2015-06-02 10:21:56.000000000 +0200
+++ new/network/network.cpp 2016-06-30 02:33:03.096296172 +0200
@@ -29,7 +29,7 @@
#endif
#include "descent.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "timer.h"
#include "error.h"
#include "objeffects.h"
diff -Nur old/network/network_handshake.cpp new/network/network_handshake.cpp
--- old/network/network_handshake.cpp 2014-07-17 16:08:08.000000000 +0200
+++ new/network/network_handshake.cpp 2016-06-30 02:33:03.096296172 +0200
@@ -9,7 +9,7 @@
#include "descent.h"
#include "timer.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "strutil.h"
#include "ipx.h"
#include "error.h"
diff -Nur old/network/network_read.cpp new/network/network_read.cpp
--- old/network/network_read.cpp 2015-05-31 13:26:00.000000000 +0200
+++ new/network/network_read.cpp 2016-06-30 02:33:03.096296172 +0200
@@ -21,7 +21,7 @@
#endif
#include "descent.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "error.h"
#include "timer.h"
#include "strutil.h"
diff -Nur old/network/network_send.cpp new/network/network_send.cpp
--- old/network/network_send.cpp 2015-05-31 13:26:00.000000000 +0200
+++ new/network/network_send.cpp 2016-06-30 02:33:03.096296172 +0200
@@ -22,7 +22,7 @@
#include "descent.h"
#include "timer.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "strutil.h"
#include "ipx.h"
#include "error.h"
diff -Nur old/network/network_sync.cpp new/network/network_sync.cpp
--- old/network/network_sync.cpp 2015-05-31 13:17:42.000000000 +0200
+++ new/network/network_sync.cpp 2016-06-30 02:33:03.096296172 +0200
@@ -24,7 +24,7 @@
#include "descent.h"
#include "timer.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "strutil.h"
#include "ipx.h"
#include "error.h"
diff -Nur old/network/network_thread.cpp new/network/network_thread.cpp
--- old/network/network_thread.cpp 2015-06-16 09:50:06.000000000 +0200
+++ new/network/network_thread.cpp 2016-06-30 02:33:03.096296172 +0200
@@ -17,7 +17,7 @@
#include "descent.h"
#include "ipx.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
#include "timer.h"
#include "error.h"
#include "network.h"
diff -Nur old/network/udp_interface.cpp new/network/udp_interface.cpp
--- old/network/udp_interface.cpp 2015-05-09 19:56:44.000000000 +0200
+++ new/network/udp_interface.cpp 2016-06-30 02:33:03.096296172 +0200
@@ -105,7 +105,7 @@
#include "error.h"
#include "args.h"
#include "u_mem.h"
-#include "byteswap.h"
+#include "d2x-xl-byteswap.h"
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------