1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-26 05:29:30 +00:00
cc65/testcode/lib/conio.c

92 lines
2.3 KiB
C
Raw Normal View History

#include <conio.h>
#include <string.h>
#include <stdlib.h>
2015-09-28 13:29:14 +00:00
static char grid[5][5] = {
{ CH_ULCORNER, CH_HLINE, CH_TTEE, CH_HLINE, CH_URCORNER },
{ CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE },
{ CH_LTEE, CH_HLINE, CH_CROSS, CH_HLINE, CH_RTEE },
{ CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE },
{ CH_LLCORNER, CH_HLINE, CH_BTEE, CH_HLINE, CH_LRCORNER },
};
void main(void)
{
int i, j, n;
2015-09-28 15:12:33 +00:00
unsigned char xsize, ysize, tcol, inpos = 0;
clrscr();
screensize(&xsize, &ysize);
2015-09-28 15:12:33 +00:00
cputs("cc65 conio test\n\rInput:[ ]");
2015-09-28 13:29:14 +00:00
cputsxy(0, 2, "Colors:" );
tcol = textcolor(0); /* remember original textcolor */
for (i = 0; i < 3; ++i) {
gotoxy(i,3 + i);
for (j = 0; j < 16; ++j) {
textcolor(j);
cputc('X');
}
}
textcolor(tcol);
2015-09-28 13:29:14 +00:00
cprintf("\n\n\r Screensize is: %dx%d", xsize, ysize );
chlinexy(0,6,xsize);
cvlinexy(0,6,3);
chlinexy(0,8,xsize);
cvlinexy(xsize-1,6,3);
cputcxy(0,6,CH_ULCORNER);
cputcxy(xsize-1,6,CH_URCORNER);
cputcxy(0,8,CH_LLCORNER);
cputcxy(xsize-1,8,CH_LRCORNER);
2015-09-28 13:29:14 +00:00
for (i = 0; i < 5; ++i) {
gotoxy(xsize - 5,i);
for (j = 0; j < 5; ++j) {
cputc(grid[i][j]);
}
}
gotoxy(0,ysize - 2 - ((256 + xsize) / xsize));
2015-09-28 13:29:14 +00:00
revers(1);
for (i = 0; i < xsize; ++i) {
cputc('0' + i % 10);
}
2015-09-28 13:29:14 +00:00
revers(0);
for (i = 0; i < 256; ++i) {
if ((i != '\n') && (i != '\r')) {
cputc(i);
}
}
while(wherex() > 0) {
cputc('#');
}
2015-09-28 13:29:14 +00:00
revers(1);
for (i = 0; i < xsize; ++i) {
cputc('0' + i % 10);
}
2015-09-28 13:29:14 +00:00
revers(0);
2015-09-28 15:12:33 +00:00
cursor(1);
for(;;) {
2015-09-28 13:29:14 +00:00
gotoxy(8, 2);
2015-09-28 15:12:33 +00:00
j = n & 1;
revers(j);
cputc(j ? 'R' : ' ');
2015-09-28 15:12:33 +00:00
revers(j ^ 1);
cputs(" revers");
revers(0);
2015-09-28 15:12:33 +00:00
gotoxy(7 + inpos,1);
cputc(cgetc());
inpos = (inpos + 1) & 7;
++n;
}
for(;;);
}