map.h
changeset 1174 27e386195965
parent 1059 c28c6be74291
child 1202 7d8b86bd8ba2
equal deleted inserted replaced
1173:b4c6bb0e16ad 1174:27e386195965
     1 #ifndef MAP_H
     1 #ifndef MAP_H
     2 #define MAP_H
     2 #define MAP_H
     3 
     3 
     4 #define TILE_FROM_XY(x,y) (int)((((y) >> 4) << MapLogX()) + ((x) >> 4))
     4 #define TILE_FROM_XY(x,y) (int)((((y) >> 4) << MapLogX()) + ((x) >> 4))
     5 #define TILE_XY(x,y) (int)(((y) << MapLogX()) + (x))
     5 #define TILE_XY(x,y) (((y) << MapLogX()) + (x))
     6 
     6 
     7 #define TILE_MASK(x) ((x) & ((1 << (MapLogX() + MapLogY())) - 1))
     7 #define TILE_MASK(x) ((x) & ((1 << (MapLogX() + MapLogY())) - 1))
     8 
     8 
     9 extern byte   _map_type_and_height[];
     9 extern byte   _map_type_and_height[];
    10 extern byte   _map5[];
    10 extern byte   _map5[];
    24 static inline uint MapMaxX(void) { return MapSizeX() - 1; }
    24 static inline uint MapMaxX(void) { return MapSizeX() - 1; }
    25 static inline uint MapMaxY(void) { return MapSizeY() - 1; }
    25 static inline uint MapMaxY(void) { return MapSizeY() - 1; }
    26 /* The number of tiles in the map */
    26 /* The number of tiles in the map */
    27 static inline uint MapSize(void) { return MapSizeX() * MapSizeY(); }
    27 static inline uint MapSize(void) { return MapSizeX() * MapSizeY(); }
    28 
    28 
       
    29 typedef uint32 TileIndex;
    29 
    30 
    30 typedef uint16 TileIndex;
       
    31 
    31 
    32 static inline uint TileX(TileIndex tile)
    32 static inline uint TileX(TileIndex tile)
    33 {
    33 {
    34 	return tile & MapMaxX();
    34 	return tile & MapMaxX();
    35 }
    35 }
    38 {
    38 {
    39 	return tile >> MapLogX();
    39 	return tile >> MapLogX();
    40 }
    40 }
    41 
    41 
    42 
    42 
    43 typedef int16 TileIndexDiff;
    43 typedef int32 TileIndexDiff;
    44 
    44 
    45 typedef struct TileIndexDiffC {
    45 typedef struct TileIndexDiffC {
    46 	int16 x;
    46 	int16 x;
    47 	int16 y;
    47 	int16 y;
    48 } TileIndexDiffC;
    48 } TileIndexDiffC;