Sets the value of a concrete bit into a bitarray to 0 or 1
void cpct_setBit (void* array, u16 index, u8 value)
(2B DE) array | Pointer to the first byte of the array |
(2B HL) index | Position of the bit in the array to be modified |
(2B BC) value | New value {0, 1} for the bit at the given position. If you call from assembly, you can safely ignore B register and set only C register. |
call cpct_setBit_asm
Set the new value of the bit at the given position (index) in the specified array. This function assumes that the array elements have a size of 8 bits and also that the given index is not bigger than the number of bits in the array (size of the array multiplied by 8). The value to be set is also assumed to be 0 or 1, but other values will “work” (just the least significant bit will be used, so odd values are treated as 1, even vales as 0).
AF, BC, DE, HL
C-bindings | 39 bytes |
ASM-bindings | 35 bytes |
bitWeights | +8 bytes vector required by both bindings. Take into account that this vector is included only once if you use different functions referencing to it. |
Case | microSecs(us) | CPU Cycles ------------------------------------------- Best (1) | 55 | 220 ------------------------------------------- Worst (0) | 57 | 228 ------------------------------------------- Asm saving | -15 | -60 -------------------------------------------