UFO: Alien Invasion
Loading...
Searching...
No Matches
byte.h
Go to the documentation of this file.
1
5
6/*
7All original material Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9Copyright (C) 1997-2001 Id Software, Inc.
10
11This program is free software; you can redistribute it and/or
12modify it under the terms of the GNU General Public License
13as published by the Free Software Foundation; either version 2
14of the License, or (at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software
24Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26*/
27
28#pragma once
29
30#include <SDL_endian.h>
31
32typedef 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
39typedef union {
41 int32_t i;
42 uint32_t ui;
44
45static __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
63void Swap_Init(void);
static __inline__ float32_t FloatSwap(const float32_t *f)
Definition byte.h:45
void Swap_Init(void)
Definition byte.cpp:31
float float32_t
Definition byte.h:32
QGL_EXTERN GLfloat f
Definition r_gl.h:114
uint32_t ui
Definition byte.h:42
int32_t i
Definition byte.h:41
float32_t f
Definition byte.h:40