c2d/text2page.c

54 lines
1.2 KiB
C
Raw Normal View History

2017-04-09 02:58:11 +00:00
#include <stdio.h>
unsigned char holes[] = {
2017-04-16 16:38:06 +00:00
0x37, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
0xff, 0xff, 0x00, 0x17, 0xff, 0xff, 0x00, 0x00,
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0xff, 0xff, 0x00, 0xd0, 0xff, 0xff, 0x00, 0x00,
0xc6, 0xff, 0x00, 0x07, 0xff, 0xff, 0x00, 0x00
2017-04-09 02:58:11 +00:00
};
int main()
{
char c, highbit = 0x80;
2017-04-16 19:57:04 +00:00
int i, j, k, line = 0;
2017-04-09 02:58:11 +00:00
unsigned char screen[24][40];
2017-04-16 20:02:54 +00:00
// clear screen (just in case < 40x24)
2017-04-16 16:38:06 +00:00
for (i = 0; i < 24; i++)
for (j = 0; j < 40; j++)
2017-04-16 19:16:36 +00:00
screen[i][j] = ' ' | highbit;
2017-04-09 02:58:11 +00:00
2017-04-16 19:57:04 +00:00
i = j = 0;
2017-04-16 16:38:06 +00:00
while ((c = getchar()) != EOF) {
if (c == '\r') // windows trash
2017-04-09 02:58:11 +00:00
continue;
2017-04-16 16:38:06 +00:00
if (c == '\n') { // end of line
2017-04-16 19:57:04 +00:00
j = 0;
i++;
line = 3 * (i % 8) + i / 8;
2017-04-09 02:58:11 +00:00
continue;
}
2017-04-16 19:57:04 +00:00
if (j > 39) // user didn't read the docs
continue;
2017-04-16 19:57:04 +00:00
if (i > 23) // ditto
break;
2017-04-09 02:58:11 +00:00
2017-04-16 19:57:04 +00:00
screen[line][j++] = c | highbit;
2017-04-09 02:58:11 +00:00
}
// dump to stdout
2017-04-16 16:38:06 +00:00
for (i = 0; i < 24; i++) {
for (j = 0; j < 40; j++)
2017-04-09 02:58:11 +00:00
putchar(screen[i][j]);
2017-04-16 19:57:04 +00:00
if (i % 3 == 2)
2017-04-16 16:38:06 +00:00
for (k = 0; k < 8; k++)
putchar(holes[(i / 3) * 8 + k]);
2017-04-09 02:58:11 +00:00
}
return 0;
}