diff options
author | tron <tron@openttd.org> | 2005-01-07 17:40:23 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-01-07 17:40:23 +0000 |
commit | 872c51f1340d8555dd41e9f0e1fb577354d480ac (patch) | |
tree | b4a2b5890976917c6f844cc28c48a6c17d7aa234 | |
parent | 414ac3286b10b83d8f832c58f48f373f5130cb89 (diff) | |
download | openttd-872c51f1340d8555dd41e9f0e1fb577354d480ac.tar.xz |
(svn r1415) Move TILE_FROM_XY and TILE_XY to map.h and push TILE_[XY] bits from map.h into map.c.
Now the whole source except map.c is independent of TILE_[XY]_BITS!
-rw-r--r-- | landscape.c | 6 | ||||
-rw-r--r-- | macros.h | 5 | ||||
-rw-r--r-- | map.c | 3 | ||||
-rw-r--r-- | map.h | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/landscape.c b/landscape.c index 016d45854..fc085deaf 100644 --- a/landscape.c +++ b/landscape.c @@ -454,8 +454,8 @@ uint GetMapExtraBits(uint tile) #define TILELOOP_BITS 4 #define TILELOOP_SIZE (1 << TILELOOP_BITS) -#define TILELOOP_ASSERTMASK ((TILELOOP_SIZE-1) + ((TILELOOP_SIZE-1) << TILE_X_BITS)) -#define TILELOOP_CHKMASK (((1 << (TILE_X_BITS - TILELOOP_BITS))-1) << TILELOOP_BITS) +#define TILELOOP_ASSERTMASK ((TILELOOP_SIZE-1) + ((TILELOOP_SIZE-1) << MapLogX())) +#define TILELOOP_CHKMASK (((1 << (MapLogX() - TILELOOP_BITS))-1) << TILELOOP_BITS) void RunTileLoop() { @@ -538,7 +538,7 @@ static void GenerateTerrain(int type, int flag) p = GetSpritePtr((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845); x = r & MapMaxX(); - y = (r >> TILE_X_BITS) & MapMaxY(); + y = (r >> MapLogX()) & MapMaxY(); if (x < 2 || y < 2) @@ -70,9 +70,6 @@ static inline int64 BIGMULS(int32 a, int32 b) { #define LANDSCAPE_SIZE_FACTOR 1 -#define TILE_FROM_XY(x,y) (int)((((y) >> 4) << TILE_X_BITS) + ((x) >> 4)) -#define TILE_XY(x,y) (int)(((y) << TILE_X_BITS) + (x)) - #define IS_TILETYPE(_t_, _s_) (_map_type_and_height[(_t_)] >> 4 == (_s_)) #define GET_TILETYPE(_t_) (_map_type_and_height[(_t_)] >> 4) #define GET_TILEHEIGHT(_t_) ((_map_type_and_height[_t_] & 0xF) * 8) @@ -86,7 +83,7 @@ enum { extern uint SafeTileAdd(uint x, int add, const char *exp, const char *file, int line); -#if !defined(_DEBUG) || TILE_X_BITS != 8 +#if !defined(_DEBUG) # define TILE_ADD(x,y) ((x)+(y)) #else # if defined(__GNUC__) @@ -2,6 +2,9 @@ #include "ttd.h" #include "map.h" +#define TILE_X_BITS 8 +#define TILE_Y_BITS 8 + uint _map_log_x = TILE_X_BITS; uint _map_log_y = TILE_Y_BITS; @@ -1,8 +1,8 @@ #ifndef MAP_H #define MAP_H -#define TILE_X_BITS 8 -#define TILE_Y_BITS 8 +#define TILE_FROM_XY(x,y) (int)((((y) >> 4) << MapLogX()) + ((x) >> 4)) +#define TILE_XY(x,y) (int)(((y) << MapLogX()) + (x)) #define TILE_MASK(x) (int)((x) & ((1 << (MapLogX() + MapLogY())) - 1)) |