Last change
on this file since 732 was
732,
checked in by Sam Hocevar, 8 years ago
|
build: SDL2 compilation fixes.
|
-
Property svn:keywords set to
Id
|
File size:
1.0 KB
|
Line | |
---|
1 | /* |
---|
2 | * Abuse - dark 2D side-scrolling platform game |
---|
3 | * Copyright (c) 1995 Crack dot Com |
---|
4 | * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net> |
---|
5 | * |
---|
6 | * This software was released into the Public Domain. As with most public |
---|
7 | * domain software, no warranty is made or implied by Crack dot Com, by |
---|
8 | * Jonathan Clark, or by Sam Hocevar. |
---|
9 | */ |
---|
10 | |
---|
11 | #ifndef __COMMON_H__ |
---|
12 | #define __COMMON_H__ |
---|
13 | |
---|
14 | // |
---|
15 | // Globally required headers |
---|
16 | // |
---|
17 | #include <stdint.h> |
---|
18 | #include <stdio.h> |
---|
19 | |
---|
20 | // |
---|
21 | // Lol Engine |
---|
22 | // |
---|
23 | #include <lol/engine.h> |
---|
24 | using namespace lol; |
---|
25 | |
---|
26 | // |
---|
27 | // Byte swapping |
---|
28 | // |
---|
29 | static inline int BigEndian() |
---|
30 | { |
---|
31 | union { uint32_t const x; uint8_t t[4]; } const u = { 0x01ffff00 }; |
---|
32 | return u.t[0]; |
---|
33 | } |
---|
34 | |
---|
35 | static inline uint16_t lstl(uint16_t x) |
---|
36 | { |
---|
37 | if (BigEndian()) |
---|
38 | return ((uint16_t)x << 8 ) | ((uint16_t)x >> 8); |
---|
39 | return x; |
---|
40 | } |
---|
41 | |
---|
42 | static inline uint32_t lltl(uint32_t x) |
---|
43 | { |
---|
44 | if (BigEndian()) |
---|
45 | return ((uint32_t)x >> 24) | (((uint32_t)x & 0x00ff0000) >> 8) |
---|
46 | | (((uint32_t)x & 0x0000ff00) << 8) | ((uint32_t)x << 24); |
---|
47 | return x; |
---|
48 | } |
---|
49 | |
---|
50 | #endif // __COMMON_H__ |
---|
51 | |
---|
Note: See
TracBrowser
for help on using the repository browser.