mirror of https://github.com/datajerk/c2d.git
minor refactoring
This commit is contained in:
parent
baedd4edd8
commit
52db29a758
BIN
bin/c2d.exe
BIN
bin/c2d.exe
Binary file not shown.
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.
13
page2text.c
13
page2text.c
|
@ -2,24 +2,17 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
int i, j, k, linemap[24];
|
||||
int i, j, k, mask = 0x7F;
|
||||
char screen[24][40];
|
||||
|
||||
// build table
|
||||
for (i = 0; i < 8; i++) {
|
||||
linemap[0 + 3 * i] = i;
|
||||
linemap[1 + 3 * i] = i + 8;
|
||||
linemap[2 + 3 * i] = i + 16;
|
||||
}
|
||||
|
||||
// clear screen
|
||||
for (i = 0; i < 24; i++)
|
||||
for (j = 0; j < 40; j++)
|
||||
screen[linemap[i]][j] = ' ';
|
||||
screen[i][j] = ' ';
|
||||
|
||||
for (i = 0; i < 24; i++) {
|
||||
for (j = 0; j < 40; j++)
|
||||
screen[linemap[i]][j] = getchar() & 0x7F;
|
||||
screen[8 * (i % 3) + i / 3][j] = getchar() & mask;
|
||||
if ((i + 1) % 3 == 0)
|
||||
for (k = 0; k < 8; k++)
|
||||
getchar();
|
||||
|
|
13
text2page.c
13
text2page.c
|
@ -14,20 +14,13 @@ unsigned char holes[] = {
|
|||
int main()
|
||||
{
|
||||
char c, highbit = 0x80;
|
||||
int i, j, k, column = 0, line = 0, linemap[24];
|
||||
int i, j, k, column = 0, line = 0;
|
||||
unsigned char screen[24][40];
|
||||
|
||||
// build table
|
||||
for (i = 0; i < 8; i++) {
|
||||
linemap[0 + i] = 0 + 3 * i;
|
||||
linemap[8 + i] = 1 + 3 * i;
|
||||
linemap[16 + i] = 2 + 3 * i;
|
||||
}
|
||||
|
||||
// clear screen
|
||||
for (i = 0; i < 24; i++)
|
||||
for (j = 0; j < 40; j++)
|
||||
screen[linemap[i]][j] = ' ' | highbit;
|
||||
screen[i][j] = ' ' | highbit;
|
||||
|
||||
while ((c = getchar()) != EOF) {
|
||||
if (c == '\r') // windows trash
|
||||
|
@ -42,7 +35,7 @@ int main()
|
|||
if (line > 23) // ditto
|
||||
break;
|
||||
|
||||
screen[linemap[line]][column++] = c | highbit;
|
||||
screen[3 * (line % 8) + line / 8][column++] = c | highbit;
|
||||
}
|
||||
|
||||
// dump to stdout
|
||||
|
|
Loading…
Reference in New Issue