/* Shows a F16 font */
/* (256 glyphs, 16 bytes each (8*16 points)) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
clrscr()
{
fprintf(stdout, "[H[2J");
}
pos_cur(int col, int row)
{
fprintf(stdout, "[%d;%dH", row, col);
}
main(int argc, char **argv)
{
FILE *f;
char s[20];
int col, row, rowbits, bit, c = 0, shift = 0, base = 0;
int dot[2] = {'-', 'X'};
if (! (f = fopen(argv[1], "r"))) {
perror("fopen");
exit(1);
}
while (1) {
clrscr();
fseek(f, c * 16, SEEK_SET);
for (row = 0; row < 16; row++) {
bit = 7;
rowbits= fgetc(f);
col = 30;
for (bit = 7; bit > -1; bit--) {
pos_cur(col+=2, row + 4);
putchar(dot[(rowbits >> bit) & 1]);
}
if (row == (15 - base)) {
pos_cur(28, row + 4);
printf("-");
}
pos_cur(col+4, row + 4);
printf("%02X", rowbits << shift);
}
pos_cur(1, 23);
printf("Enter character (now %d), s[shift] (now %d) or b[base] (now %d): ", c, shift, base);
gets(s);
if (! strlen(s)) break;
switch (s[0]) {
case 's':
shift = atoi(&s[1]);
break;
case 'b':
base = atoi(&s[1]);
break;
default:
c = atoi(s);
}
}
fclose(f);
clrscr();
}