tron@679: #ifndef MAP_H tron@679: #define MAP_H tron@679: tron@679: #define TILE_X_BITS 8 tron@679: #define TILE_Y_BITS 8 tron@679: truelight@817: extern byte _map_type_and_height[]; truelight@817: extern byte _map5[]; truelight@817: extern byte _map3_lo[]; truelight@817: extern byte _map3_hi[]; truelight@817: extern byte _map_owner[]; truelight@817: extern uint16 _map2[]; truelight@817: extern byte _map_extra_bits[]; tron@679: tron@689: // binary logarithm of the map size, try to avoid using this one tron@689: static inline uint MapLogX(void) { extern uint _map_log_x; return _map_log_x; } tron@689: static inline uint MapLogY(void) { extern uint _map_log_y; return _map_log_y; } tron@689: /* The size of the map */ tron@689: static inline uint MapSizeX(void) { return 1 << MapLogX(); } tron@689: static inline uint MapSizeY(void) { return 1 << MapLogY(); } tron@689: /* The maximum coordinates */ tron@689: static inline uint MapMaxX(void) { return MapSizeX() - 1; } tron@689: static inline uint MapMaxY(void) { return MapSizeY() - 1; } tron@689: /* The number of tiles in the map */ tron@689: static inline uint MapSize(void) { return MapSizeX() * MapSizeY(); } tron@689: tron@900: typedef int16 TileIndexDiff; tron@900: tron@909: typedef struct TileIndexDiffC { tron@909: int16 x; tron@909: int16 y; tron@909: } TileIndexDiffC; tron@909: tron@909: static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc) tron@909: { tron@909: return (tidc.y << MapLogX()) + tidc.x; tron@909: } tron@900: tron@900: static inline TileIndexDiff TileOffsByDir(uint dir) tron@900: { tron@909: extern const TileIndexDiffC _tileoffs_by_dir[4]; tron@900: tron@900: assert(dir < lengthof(_tileoffs_by_dir)); tron@909: return ToTileIndexDiff(_tileoffs_by_dir[dir]); tron@900: } tron@900: tron@679: #endif