(svn r2358) Add macros for getting (GB) and setting (SB) a range of bits

Use them exemplarily to prettify (Get|Set)Tile(Type|Height)
This commit is contained in:
tron
2005-05-22 07:12:09 +00:00
parent 27dee01623
commit 870127fd30
2 changed files with 9 additions and 6 deletions

View File

@@ -151,4 +151,9 @@ static inline void swap_tile(TileIndex *a, TileIndex *b) { TileIndex t = *a; *a
}
#endif
// Fetch count bits starting at bit start from value
#define GB(value, start, count) (((value) >> (start)) & ((1 << (count)) - 1))
// Set count bits in value starting at bit start to data
#define SB(value, start, count, data) ((value) = ((value) & ~(((1 << (count)) - 1) << (start))) | ((data) << (start)))
#endif /* MACROS_H */