Fast line drawing algorithm
This code assumes that both x0 and x1 are inclusive endpoints, and that words are little endian (i.e. the (0,0) pixel can be set with array[0][0]|=1).

int line(word *array, int x0, int x1, int y) {
  word *line = array + (y &lt;&lt; 4);
  word *start = line + (x0 &gt;&gt; 4);
  word *end = line + (x1 &gt;&gt; 4);
  word start_mask = (word)-1 &lt;&lt; (x0 &amp; 15);
  word end_mask = (unsigned word)-1 &gt;&gt; (15 - (x1 &amp; 15));
  if (start == end) {
    *start |= start_mask &amp; end_mask;
  } else {
    *start |= start_mask;
    *end |= end_mask;
    for (word *p = start + 1; p &lt; end; p++) *p = (word)-1;
  }
}