]> git.sur5r.net Git - cc65/blob - testcode/lib/conio.c
added input test
[cc65] / testcode / lib / conio.c
1
2 #include <conio.h>
3 #include <string.h>
4 #include <stdlib.h>
5
6 static char grid[5][5] = {
7     { CH_ULCORNER, CH_HLINE, CH_TTEE, CH_HLINE, CH_URCORNER },
8     { CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE },
9     { CH_LTEE, CH_HLINE, CH_CROSS, CH_HLINE, CH_RTEE },
10     { CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE },
11     { CH_LLCORNER, CH_HLINE, CH_BTEE, CH_HLINE, CH_LRCORNER },
12 };
13
14 void main(void)
15 {
16         int i, j, n;
17         unsigned char xsize, ysize, tcol, inpos = 0;
18
19         clrscr();
20         screensize(&xsize, &ysize);
21         cputs("cc65 conio test\n\rInput:[        ]");
22
23         cputsxy(0, 2, "Colors:" );
24         tcol = textcolor(0); /* remember original textcolor */
25         for (i = 0; i < 3; ++i) {
26                 gotoxy(i,3 + i);
27                 for (j = 0; j < 16; ++j) {
28                         textcolor(j);
29                         cputc('X');
30                 }
31         }
32         textcolor(tcol);
33
34         cprintf("\n\n\r Screensize is: %dx%d", xsize, ysize );
35
36         chlinexy(0,6,xsize);
37         cvlinexy(0,6,3);
38         chlinexy(0,8,xsize);
39         cvlinexy(xsize-1,6,3);
40         cputcxy(0,6,CH_ULCORNER);
41         cputcxy(xsize-1,6,CH_URCORNER);
42         cputcxy(0,8,CH_LLCORNER);
43         cputcxy(xsize-1,8,CH_LRCORNER);
44
45         for (i = 0; i < 5; ++i) {
46                 gotoxy(xsize - 5,i);
47                 for (j = 0; j < 5; ++j) {
48                         cputc(grid[i][j]);
49                 }
50         }
51
52         gotoxy(0,ysize - 2 - ((256 + xsize) / xsize));
53         revers(1);
54         for (i = 0; i < xsize; ++i) {
55                 cputc('0' + i % 10);
56         }
57         revers(0);
58         for (i = 0; i < 256; ++i) {
59             if ((i != '\n') && (i != '\r')) {
60                     cputc(i);
61             }
62         }
63         while(wherex() > 0) {
64                 cputc('#');
65         }
66         revers(1);
67         for (i = 0; i < xsize; ++i) {
68                 cputc('0' + i % 10);
69         }
70         revers(0);
71
72         cursor(1);
73         for(;;) {
74
75                 gotoxy(8, 2);
76                 j = n & 1;
77                 revers(j);
78                 cputc(j ? 'R' : ' ');
79                 revers(j ^ 1);
80                 cputs(" revers");
81                 revers(0);
82
83                 gotoxy(7 + inpos,1);
84                 cputc(cgetc());
85                 inpos = (inpos + 1) & 7;
86
87                 ++n;
88         }
89
90         for(;;);
91 }