- int y = ((uint8_t*)b->gi[i].data)[j];
- if (y>>7&1) {
- kputsn("./.", 3, s);
- } else {
- kputc('0' + (y>>3&7), s);
- kputc("/|"[y>>6&1], s);
- kputc('0' + (y&7), s);
- }
+ int y = ((uint8_t*)b->gi[i].data)[j];
+ if ( y>>7&1 )
+ kputsn("./.", 3, s);
+ else if ( imax==-1 )
+ {
+ kputc('0' + (y>>3&7), s);
+ kputc("/|"[y>>6&1], s);
+ kputc('0' + (y&7), s);
+ }
+ else
+ {
+ // Arguably, the while loop will be faster than two sqrts
+ int n = 0;
+ int row = 1;
+ while ( n<imax )
+ {
+ row++;
+ n += row;
+ }
+ row--;
+ kputw(imax-n+row, s);
+ kputc("/|"[y>>6&1], s);
+ kputw(row, s);
+ }