equal
deleted
inserted
replaced
1 #ifndef MACROS_H |
1 #ifndef MACROS_H |
2 #define MACROS_H |
2 #define MACROS_H |
3 |
3 |
4 #define MAX_INT 0x7FFFFFFF |
4 #define MAX_INT 0x7FFFFFFF |
5 |
5 |
6 #ifdef min |
6 #ifdef min |
7 #undef min |
7 #undef min |
8 #endif |
8 #endif |
9 |
9 |
10 #ifdef max |
10 #ifdef max |
11 #undef max |
11 #undef max |
33 } |
33 } |
34 return false; |
34 return false; |
35 } |
35 } |
36 |
36 |
37 // Will crash if strings are equal |
37 // Will crash if strings are equal |
38 static INLINE bool str_is_below(byte *a, byte *b) { |
38 static INLINE bool str_is_below(byte *a, byte *b) { |
39 while (*a <= *b) { |
39 while (*a <= *b) { |
40 if (*a < *b) return true; |
40 if (*a < *b) return true; |
41 a++; |
41 a++; |
42 b++; |
42 b++; |
43 } |
43 } |
150 return i + FIND_FIRST_BIT(value & 0x3F); |
150 return i + FIND_FIRST_BIT(value & 0x3F); |
151 } |
151 } |
152 |
152 |
153 |
153 |
154 #if TILE_X_BITS + TILE_Y_BITS <= 16 |
154 #if TILE_X_BITS + TILE_Y_BITS <= 16 |
155 typedef uint16 TileIndex; |
155 typedef uint16 TileIndex; |
156 typedef int16 TileIndexDiff; |
156 typedef int16 TileIndexDiff; |
157 #else |
157 #else |
158 typedef uint32 TileIndex; |
158 typedef uint32 TileIndex; |
159 typedef int32 TileIndexDiff; |
159 typedef int32 TileIndexDiff; |
160 #endif |
160 #endif |
208 # define ADD_DWORD(x) (x)&0xFF, ((x) >> 8)&0xFF, ((x) >> 16)&0xFF, ((x) >> 24)&0xFF |
208 # define ADD_DWORD(x) (x)&0xFF, ((x) >> 8)&0xFF, ((x) >> 16)&0xFF, ((x) >> 24)&0xFF |
209 #elif defined(TTD_BIG_ENDIAN) |
209 #elif defined(TTD_BIG_ENDIAN) |
210 static INLINE uint16 READ_LE_UINT16(const void *b) { |
210 static INLINE uint16 READ_LE_UINT16(const void *b) { |
211 return ((byte*)b)[0] + (((byte*)b)[1] << 8); |
211 return ((byte*)b)[0] + (((byte*)b)[1] << 8); |
212 } |
212 } |
213 # define ADD_WORD(x) ((x) >> 8)&0xFF, (x)&0xFF |
213 # define ADD_WORD(x) ((x) >> 8)&0xFF, (x)&0xFF |
214 # define ADD_DWORD(x) ((x) >> 24)&0xFF, ((x) >> 16)&0xFF, ((x) >> 8)&0xFF, (x)&0xFF |
214 # define ADD_DWORD(x) ((x) >> 24)&0xFF, ((x) >> 16)&0xFF, ((x) >> 8)&0xFF, (x)&0xFF |
215 #endif |
215 #endif |
216 |
216 |
217 static INLINE void WRITE_LE_UINT16(const void *b, uint16 x) { |
217 static INLINE void WRITE_LE_UINT16(const void *b, uint16 x) { |
218 ((byte*)b)[0] = (byte)x; |
218 ((byte*)b)[0] = (byte)x; |