Last change
on this file since 9437 was
9324,
checked in by ponder, 18 years ago
|
Added byte_order.h to
Added binary_file.h binary_file.cc
Changed the bsp code to work on big endian machines.
|
File size:
578 bytes
|
Line | |
---|
1 | #ifndef _BYTE_ORDER_H |
---|
2 | #define _BYTE_ORDER_H |
---|
3 | |
---|
4 | enum ByteOrder { LittleEndian = 1, BigEndian = 2 }; |
---|
5 | |
---|
6 | #ifdef HAVE_SDL_SDL_H |
---|
7 | #include <SDL/SDL_byteorder.h> |
---|
8 | #else |
---|
9 | #include <SDL_byteorder.h> |
---|
10 | #endif |
---|
11 | |
---|
12 | |
---|
13 | #if SDL_BYTEORDER == SDL_LIL_ENDIAN |
---|
14 | #define NATIVE_BYTEORDER LittleEndian |
---|
15 | #else |
---|
16 | #define NATIVE_BYTEORDER BigEndian |
---|
17 | #endif |
---|
18 | |
---|
19 | |
---|
20 | inline void swap16( short *_s ) |
---|
21 | { |
---|
22 | char *ci = (char*)_s, tmp; |
---|
23 | tmp = ci[0]; ci[0] = ci[1]; ci[1] = tmp; |
---|
24 | } |
---|
25 | |
---|
26 | inline void swap32( int *_i ) |
---|
27 | { |
---|
28 | char *ci = (char*)_i, tmp; |
---|
29 | tmp = ci[0]; ci[0] = ci[3]; ci[3] = tmp; |
---|
30 | tmp = ci[2]; ci[2] = ci[1]; ci[1] = tmp; |
---|
31 | } |
---|
32 | |
---|
33 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.