16 extern uint _map_size; |
16 extern uint _map_size; |
17 |
17 |
18 #define TILE_MASK(x) ((x) & _map_tile_mask) |
18 #define TILE_MASK(x) ((x) & _map_tile_mask) |
19 #define TILE_ASSERT(x) assert(TILE_MASK(x) == (x)); |
19 #define TILE_ASSERT(x) assert(TILE_MASK(x) == (x)); |
20 |
20 |
21 typedef struct Tile { |
21 struct Tile { |
22 byte type_height; |
22 byte type_height; |
23 byte m1; |
23 byte m1; |
24 uint16 m2; |
24 uint16 m2; |
25 byte m3; |
25 byte m3; |
26 byte m4; |
26 byte m4; |
27 byte m5; |
27 byte m5; |
28 byte m6; |
28 byte m6; |
29 } Tile; |
29 }; |
30 |
30 |
31 extern Tile* _m; |
31 extern Tile* _m; |
32 |
32 |
33 void AllocateMap(uint size_x, uint size_y); |
33 void AllocateMap(uint size_x, uint size_y); |
34 |
34 |
35 /* binary logarithm of the map size, try to avoid using this one */ |
35 /* binary logarithm of the map size, try to avoid using this one */ |
36 static inline uint MapLogX(void) { return _map_log_x; } |
36 static inline uint MapLogX() { return _map_log_x; } |
37 /* The size of the map */ |
37 /* The size of the map */ |
38 static inline uint MapSizeX(void) { return _map_size_x; } |
38 static inline uint MapSizeX() { return _map_size_x; } |
39 static inline uint MapSizeY(void) { return _map_size_y; } |
39 static inline uint MapSizeY() { return _map_size_y; } |
40 /* The maximum coordinates */ |
40 /* The maximum coordinates */ |
41 static inline uint MapMaxX(void) { return _map_size_x - 1; } |
41 static inline uint MapMaxX() { return _map_size_x - 1; } |
42 static inline uint MapMaxY(void) { return _map_size_y - 1; } |
42 static inline uint MapMaxY() { return _map_size_y - 1; } |
43 /* The number of tiles in the map */ |
43 /* The number of tiles in the map */ |
44 static inline uint MapSize(void) { return _map_size; } |
44 static inline uint MapSize() { return _map_size; } |
45 |
45 |
46 /* Scale a number relative to the map size */ |
46 /* Scale a number relative to the map size */ |
47 uint ScaleByMapSize(uint); // Scale relative to the number of tiles |
47 uint ScaleByMapSize(uint); // Scale relative to the number of tiles |
48 uint ScaleByMapSize1D(uint); // Scale relative to the circumference of the map |
48 uint ScaleByMapSize1D(uint); // Scale relative to the circumference of the map |
49 |
49 |