# HG changeset patch # User tron # Date 1105119623 0 # Node ID 28f45a22a564d9c699645b2b4bdadc4d3e8f44b9 # Parent bd4312619522cb14be1aecbb6b23f93bfbb88b5c (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! diff -r bd4312619522 -r 28f45a22a564 landscape.c --- a/landscape.c Fri Jan 07 17:02:43 2005 +0000 +++ b/landscape.c Fri Jan 07 17:40:23 2005 +0000 @@ -454,8 +454,8 @@ #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 @@ 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) diff -r bd4312619522 -r 28f45a22a564 macros.h --- a/macros.h Fri Jan 07 17:02:43 2005 +0000 +++ b/macros.h Fri Jan 07 17:40:23 2005 +0000 @@ -70,9 +70,6 @@ #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 @@ 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__) diff -r bd4312619522 -r 28f45a22a564 map.c --- a/map.c Fri Jan 07 17:02:43 2005 +0000 +++ b/map.c Fri Jan 07 17:40:23 2005 +0000 @@ -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; diff -r bd4312619522 -r 28f45a22a564 map.h --- a/map.h Fri Jan 07 17:02:43 2005 +0000 +++ b/map.h Fri Jan 07 17:40:23 2005 +0000 @@ -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))