Given a write frame, set its cursor's cell to 'bit' and advance the cursor by one cell. * Cells in front of the cursor's final position may be overwritten. * * The function returns the same value as bit. This facilitates using 'writeBit' within an 'if' statement * * if (writeBit(frame, bit)) { ... } else { ... } * * so that one can both decide conditions based on a Boolean value while
| 78 | * Precondition: '*frame' is a valid write frame for 1 more cell. |
| 79 | */ |
| 80 | static inline bool writeBit(frameItem* frame, bool bit) { |
| 81 | simplicity_debug_assert(0 < frame->offset); |
| 82 | frame->offset--; |
| 83 | UWORD* dst_ptr = frame->edge + frame->offset / UWORD_BIT; |
| 84 | if (bit) { |
| 85 | *dst_ptr |= (UWORD)((UWORD)1 << (frame->offset % UWORD_BIT)); |
| 86 | } else { |
| 87 | *dst_ptr = LSBclear(*dst_ptr, frame->offset % UWORD_BIT + 1); |
| 88 | } |
| 89 | return bit; |
| 90 | } |
| 91 | |
| 92 | /* Given a read frame, advance the cursor by 'n' cells. |
| 93 | * |
no test coverage detected