1 //********************************************************************************************
2 //*
3 //*    This file is part of Egoboo.
4 //*
5 //*    Egoboo is free software: you can redistribute it and/or modify it
6 //*    under the terms of the GNU General Public License as published by
7 //*    the Free Software Foundation, either version 3 of the License, or
8 //*    (at your option) any later version.
9 //*
10 //*    Egoboo is distributed in the hope that it will be useful, but
11 //*    WITHOUT ANY WARRANTY; without even the implied warranty of
12 //*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 //*    General Public License for more details.
14 //*
15 //*    You should have received a copy of the GNU General Public License
16 //*    along with Egoboo.  If not, see <http://www.gnu.org/licenses/>.
17 //*
18 //********************************************************************************************
19 
20 /// @file egoboo_endian.c
21 /// @brief Implementation of endian conversion routines
22 /// @details
23 
24 #include "egoboo_endian.h"
25 
26 //--------------------------------------------------------------------------------------------
27 //--------------------------------------------------------------------------------------------
28 
29 #if SDL_BYTEORDER != SDL_LIL_ENDIAN
30 
31 union u_convert {float f; Uint32 i;};
32 
33 typedef union u_convert convert_t;
34 
35 //--------------------------------------------------------------------------------------------
ENDIAN_FLOAT(float X)36 float ENDIAN_FLOAT( float X )
37 {
38     convert_t utmp;
39 
40     utmp.f = X;
41 
42     utmp.i = SDL_SwapLE32( utmp.i );
43 
44     return utmp.f;
45 }
46 
47 #endif
48