diff --git a/bin/page2text b/bin/page2text index afd4443..2fe7b65 100755 Binary files a/bin/page2text and b/bin/page2text differ diff --git a/bin/page2text.exe b/bin/page2text.exe index 9e96335..0e3595e 100755 Binary files a/bin/page2text.exe and b/bin/page2text.exe differ diff --git a/bin/text2page b/bin/text2page index 7f8dce4..8420445 100755 Binary files a/bin/text2page and b/bin/text2page differ diff --git a/bin/text2page.exe b/bin/text2page.exe index e2deaa1..ce9b518 100755 Binary files a/bin/text2page.exe and b/bin/text2page.exe differ diff --git a/page2text.c b/page2text.c index d53fe6b..f7b5097 100644 --- a/page2text.c +++ b/page2text.c @@ -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(); } diff --git a/text2page.c b/text2page.c index f4a54a1..f4e7041 100644 --- a/text2page.c +++ b/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]); }