14.06.2011, 14:29
(
Последний раз редактировалось Double-O-Seven; 14.06.2011 в 15:04.
)
Quote:
There's a better argument for using the "DBIT_VAR" than the one even MrDeath537 gave, consider this code:
pawn Код:
|
Making the Bit16_Get function as a stock function could solve this.
//Edit: I've tried my luck with nibble coding.^^
pawn Код:
#define Nibbles:%0<%1> \
%0[((%1) + 8) >>> 3]
stock Nibble_Get (arr [], slot)
{
new shamt = (slot & 7) * 4; // (slot % 8) * 4
return ((arr [slot >>> 3] & (0x0F << (shamt))) >>> shamt);
}
stock Nibble_Set (arr [], slot, val)
{
new
shamt = (slot & 7) * 4, // (slot % 8) * 4
s = slot >>> 3;
arr [s] &= ~(0x0F << shamt); // Set target "cell" to 0.
//arr [s] |= (val << shamt); // Using this, you have to make sure that val < 16 or other cells may get changed.
arr [s] |= ((val & 0x0F) << shamt); // This looks more save to me.
}