diff options
author | tron <tron@openttd.org> | 2005-05-22 07:12:09 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-05-22 07:12:09 +0000 |
commit | 870127fd307c1ac46c55cea2bd28a7301c54ca96 (patch) | |
tree | 59a88830232c0d1934e46187ce49269b371795a6 /macros.h | |
parent | 27dee01623e386ff08907c8507aa84be815d1d5f (diff) | |
download | openttd-870127fd307c1ac46c55cea2bd28a7301c54ca96.tar.xz |
(svn r2358) Add macros for getting (GB) and setting (SB) a range of bits
Use them exemplarily to prettify (Get|Set)Tile(Type|Height)
Diffstat (limited to 'macros.h')
-rw-r--r-- | macros.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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 */ |