UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
byte.h
Go to the documentation of this file.
1 
6 /*
7 All original material Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 Copyright (C) 1997-2001 Id Software, Inc.
10 
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 
20 See the GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 
26 */
27 
28 #pragma once
29 
30 #include <SDL_endian.h>
31 
32 typedef float float32_t;
33 
34 #define BigShort(X) (short)SDL_SwapBE16(X)
35 #define LittleShort(X) (short)SDL_SwapLE16(X)
36 #define BigLong(X) (int)SDL_SwapBE32(X)
37 #define LittleLong(X) (int)SDL_SwapLE32(X)
38 
39 typedef union {
41  int32_t i;
42  uint32_t ui;
43 } floatint_t;
44 
45 static __inline__ float32_t FloatSwap (const float32_t* f)
46 {
47  floatint_t out;
48 
49  out.f = *f;
50  out.ui = SDL_SwapLE32(out.ui);
51 
52  return out.f;
53 }
54 
55 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
56 #define BigFloat(X) FloatSwap(&(X))
57 #define LittleFloat(X) (X)
58 #else
59 #define BigFloat(X) (X)
60 #define LittleFloat(X) FloatSwap(&(X))
61 #endif
62 
63 void Swap_Init(void);
uint32_t ui
Definition: byte.h:42
float float32_t
Definition: byte.h:32
int32_t i
Definition: byte.h:41
static __inline__ float32_t FloatSwap(const float32_t *f)
Definition: byte.h:45
QGL_EXTERN GLfloat f
Definition: r_gl.h:114
float32_t f
Definition: byte.h:40
void Swap_Init(void)
Definition: byte.cpp:31