emulator/cpu/buffer.h
static inline bool buffer_put(buffer_t *buffer, uint8_t b) {
  buffer->data[buffer->write_position] = b;
  size_t new_write = buffer->write_position + 1;
  if (new_write >= sizeof(buffer->data)) {
    new_write = 0;
  }
  if (new_write == buffer->read_position) {
    return false;
  }
  buffer->write_position = new_write;
  return true;
}
// returns:
//   true  if byte was saved
//   false if buffer is full and byte was rejected
true  if byte was saved
false if buffer is full and byte was rejected
true if byte was saved false if buffer is full and byte was rejected
static inline bool buffer_put(buffer_t *buffer, uint8_t b) {
  buffer->data[buffer->write_position] = b;
  size_t new_write = buffer->write_position + 1;
  if (new_write >= sizeof(buffer->data)) {
    new_write = 0;
  }
  if (new_write == buffer->read_position) {
    return false;
  }
  buffer->write_position = new_write;
  return true;
}
static inline bool buffer_put ( buffer_t * buffer , uint8_t b ) { buffer -> data [ buffer -> write_position ] = b ; size_t new_write = buffer -> write_position + 1 ; if ( new_write >= sizeof ( buffer -> data ) ) { new_write = 0 ; } if ( new_write == buffer -> read_position ) { return false ; } buffer -> write_position = new_write ; return true ; }
returns:
true  if byte was saved
false if buffer is full and byte was rejected
returns : true if byte was saved false if buffer is full and byte was rejected