mirror of
https://github.com/datajerk/c2d.git
synced 2025-01-14 23:30:34 +00:00
more minor refactoring
This commit is contained in:
parent
52db29a758
commit
b5b24d2486
BIN
bin/page2text
BIN
bin/page2text
Binary file not shown.
Binary file not shown.
BIN
bin/text2page
BIN
bin/text2page
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
int i, j, k, mask = 0x7F;
|
||||
int i, j, k, line, mask = 0x7F;
|
||||
char screen[24][40];
|
||||
|
||||
// clear screen
|
||||
@ -11,9 +11,10 @@ int main()
|
||||
screen[i][j] = ' ';
|
||||
|
||||
for (i = 0; i < 24; i++) {
|
||||
line = 8 * (i % 3) + i / 3;
|
||||
for (j = 0; j < 40; j++)
|
||||
screen[8 * (i % 3) + i / 3][j] = getchar() & mask;
|
||||
if ((i + 1) % 3 == 0)
|
||||
screen[line][j] = getchar() & mask;
|
||||
if (i % 3 == 2)
|
||||
for (k = 0; k < 8; k++)
|
||||
getchar();
|
||||
}
|
||||
|
16
text2page.c
16
text2page.c
@ -14,7 +14,7 @@ unsigned char holes[] = {
|
||||
int main()
|
||||
{
|
||||
char c, highbit = 0x80;
|
||||
int i, j, k, column = 0, line = 0;
|
||||
int i, j, k, line = 0;
|
||||
unsigned char screen[24][40];
|
||||
|
||||
// clear screen
|
||||
@ -22,27 +22,29 @@ int main()
|
||||
for (j = 0; j < 40; j++)
|
||||
screen[i][j] = ' ' | highbit;
|
||||
|
||||
i = j = 0;
|
||||
while ((c = getchar()) != EOF) {
|
||||
if (c == '\r') // windows trash
|
||||
continue;
|
||||
if (c == '\n') { // end of line
|
||||
column = 0;
|
||||
line++;
|
||||
j = 0;
|
||||
i++;
|
||||
line = 3 * (i % 8) + i / 8;
|
||||
continue;
|
||||
}
|
||||
if (column > 39) // user didn't read the docs
|
||||
if (j > 39) // user didn't read the docs
|
||||
continue;
|
||||
if (line > 23) // ditto
|
||||
if (i > 23) // ditto
|
||||
break;
|
||||
|
||||
screen[3 * (line % 8) + line / 8][column++] = c | highbit;
|
||||
screen[line][j++] = c | highbit;
|
||||
}
|
||||
|
||||
// dump to stdout
|
||||
for (i = 0; i < 24; i++) {
|
||||
for (j = 0; j < 40; j++)
|
||||
putchar(screen[i][j]);
|
||||
if ((i + 1) % 3 == 0)
|
||||
if (i % 3 == 2)
|
||||
for (k = 0; k < 8; k++)
|
||||
putchar(holes[(i / 3) * 8 + k]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user