|
@@ -79,15 +79,15 @@ template<typename T> static inline T TOG
|
|
|
{
|
|
|
return x ^= (T)1 << y;
|
|
|
}
|
|
|
|
|
|
|
|
|
/* checking more bits. Maybe unneccessary, but easy to use */
|
|
|
#define HASBITS(x,y) ((x) & (y))
|
|
|
#define SETBITS(x,y) ((x) |= (y))
|
|
|
#define CLRBITS(x,y) ((x) &= ~(y))
|
|
|
#define HASBITS(x, y) ((x) & (y))
|
|
|
#define SETBITS(x, y) ((x) |= (y))
|
|
|
#define CLRBITS(x, y) ((x) &= ~(y))
|
|
|
|
|
|
#define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START)
|
|
|
#define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner]))
|
|
|
|
|
|
extern const byte _ffb_64[128];
|
|
|
/* Returns the position of the first bit that is not zero, counted from the
|
|
@@ -95,13 +95,13 @@ extern const byte _ffb_64[128];
|
|
|
* 0.
|
|
|
*/
|
|
|
#define FIND_FIRST_BIT(x) _ffb_64[(x)]
|
|
|
/* Returns x with the first bit that is not zero, counted from the left, set
|
|
|
* to zero. So, 10110100 returns 10110000, 00000001 returns 00000000, etc.
|
|
|
*/
|
|
|
#define KILL_FIRST_BIT(x) _ffb_64[(x)+64]
|
|
|
#define KILL_FIRST_BIT(x) _ffb_64[(x) + 64]
|
|
|
|
|
|
static inline int FindFirstBit2x64(int value)
|
|
|
{
|
|
|
/*
|
|
|
int i = 0;
|
|
|
if ( (byte) value == 0) {
|
|
@@ -130,19 +130,19 @@ static inline int KillFirstBit2x64(int v
|
|
|
}
|
|
|
|
|
|
/** returns true if value a has only one bit set to 1 */
|
|
|
#define HAS_SINGLE_BIT(a) ( ((a) & ((a) - 1)) == 0)
|
|
|
|
|
|
/* [min,max), strictly less than */
|
|
|
#define IS_BYTE_INSIDE(a,min,max) ((byte)((a)-(min)) < (byte)((max)-(min)))
|
|
|
#define IS_INT_INSIDE(a,min,max) ((uint)((a)-(min)) < (uint)((max)-(min)))
|
|
|
#define IS_BYTE_INSIDE(a, min, max) ((byte)((a) - (min)) < (byte)((max) - (min)))
|
|
|
#define IS_INT_INSIDE(a, min, max) ((uint)((a) - (min)) < (uint)((max) - (min)))
|
|
|
|
|
|
|
|
|
#define CHANCE16(a,b) ((uint16)Random() <= (uint16)((65536 * (a)) / (b)))
|
|
|
#define CHANCE16R(a,b,r) ((uint16)(r=Random()) <= (uint16)((65536 * (a)) / (b)))
|
|
|
#define CHANCE16I(a,b,v) ((uint16)(v) <= (uint16)((65536 * (a)) / (b)))
|
|
|
#define CHANCE16(a, b) ((uint16)Random() <= (uint16)((65536 * (a)) / (b)))
|
|
|
#define CHANCE16R(a, b, r) ((uint16)(r = Random()) <= (uint16)((65536 * (a)) / (b)))
|
|
|
#define CHANCE16I(a, b, v) ((uint16)(v) <= (uint16)((65536 * (a)) / (b)))
|
|
|
|
|
|
|
|
|
#define for_each_bit(_i, _b) \
|
|
|
for (_i = 0; _b != 0; _i++, _b >>= 1) \
|
|
|
if (_b & 1)
|
|
|
|