Added more source-code improvements to the conio test program.
Also, made the f6/f5 function keys change the border color instead of the background color.
This commit is contained in:
parent
13790bdbf0
commit
9fee605e65
1 changed files with 44 additions and 37 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* conio api test program
|
* conio API test program
|
||||||
*
|
*
|
||||||
* keys:
|
* keys:
|
||||||
*
|
*
|
||||||
|
@ -34,7 +34,7 @@ static char grid[5][5] = {
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
int i, j, n;
|
unsigned int i, j, n;
|
||||||
unsigned char xsize, ysize, tcol, bgcol, bcol, inpos = 0;
|
unsigned char xsize, ysize, tcol, bgcol, bcol, inpos = 0;
|
||||||
#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__)
|
#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__)
|
||||||
unsigned char joy;
|
unsigned char joy;
|
||||||
|
@ -44,14 +44,15 @@ void main(void)
|
||||||
clrscr();
|
clrscr();
|
||||||
screensize(&xsize, &ysize);
|
screensize(&xsize, &ysize);
|
||||||
cputs("cc65 conio test\n\r");
|
cputs("cc65 conio test\n\r");
|
||||||
cputs("Input:[ ]");
|
cputs("Input:[ ]"); /* 8 spaces */
|
||||||
|
|
||||||
|
tcol = textcolor(0); /* memorize original textcolor */
|
||||||
|
bgcol = bgcolor(0); /* memorize original background color */
|
||||||
|
bcol = bordercolor(0); /* memorize original border color */
|
||||||
|
(void)bordercolor(bcol);
|
||||||
|
(void)bgcolor(bgcol);
|
||||||
|
|
||||||
cputsxy(0, 2, "Colors:" );
|
cputsxy(0, 2, "Colors:" );
|
||||||
tcol = textcolor(0); /* remember original textcolor */
|
|
||||||
bgcol = bgcolor(0); /* remember original background color */
|
|
||||||
bcol = bordercolor(0); /* remember original border color */
|
|
||||||
(void)bgcolor(bgcol);
|
|
||||||
(void)bordercolor(bcol);
|
|
||||||
for (i = 0; i < 3; ++i) {
|
for (i = 0; i < 3; ++i) {
|
||||||
gotoxy(i, 3 + i);
|
gotoxy(i, 3 + i);
|
||||||
for (j = 0; j < NUMCOLS; ++j) {
|
for (j = 0; j < NUMCOLS; ++j) {
|
||||||
|
@ -61,7 +62,7 @@ void main(void)
|
||||||
}
|
}
|
||||||
(void)textcolor(tcol);
|
(void)textcolor(tcol);
|
||||||
|
|
||||||
cprintf("\n\n\r Screensize: %dx%d", xsize, ysize);
|
cprintf("\n\n\r Screensize: %ux%u", xsize, ysize);
|
||||||
|
|
||||||
chlinexy(0, 6, xsize);
|
chlinexy(0, 6, xsize);
|
||||||
cvlinexy(0, 6, 3);
|
cvlinexy(0, 6, 3);
|
||||||
|
@ -103,11 +104,10 @@ void main(void)
|
||||||
|
|
||||||
cursor(1);
|
cursor(1);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
/* do the "rvs" blinking */
|
/* do the "rvs" blinking */
|
||||||
i = textcolor(COLOR_BLACK);
|
i = textcolor(COLOR_BLACK);
|
||||||
gotoxy(8, 2);
|
gotoxy(8, 2);
|
||||||
j = n >> 4 & 1;
|
j = (++n / 16) & 1;
|
||||||
revers(j);
|
revers(j);
|
||||||
cputc(j ? 'R' : ' ');
|
cputc(j ? 'R' : ' ');
|
||||||
revers(j ^ 1);
|
revers(j ^ 1);
|
||||||
|
@ -126,40 +126,47 @@ void main(void)
|
||||||
cprintf("%02x", joy);
|
cprintf("%02x", joy);
|
||||||
#else
|
#else
|
||||||
i = cgetc();
|
i = cgetc();
|
||||||
if ((i >= '0') && (i <= '9')) {
|
switch (i) {
|
||||||
(void)textcolor(i - '0');
|
case CH_ENTER:
|
||||||
} else if (i == CH_ENTER) {
|
|
||||||
clrscr();
|
clrscr();
|
||||||
return;
|
return;
|
||||||
} else if (i == CH_CURS_LEFT) {
|
case CH_CURS_LEFT:
|
||||||
inpos = (inpos - 1) & 7;
|
inpos = (inpos - 1) % 8;
|
||||||
} else if (i == CH_CURS_RIGHT) {
|
break;
|
||||||
inpos = (inpos + 1) & 7;
|
case '0': case '1': case '2': case '3': case '4':
|
||||||
|
case '5': case '6': case '7': case '8': case '9':
|
||||||
|
(void)textcolor(i - '0');
|
||||||
|
break;
|
||||||
#ifdef CH_F5
|
#ifdef CH_F5
|
||||||
} else if (i == CH_F5) {
|
case CH_F5:
|
||||||
bgcol = (bgcol + 1) & 0x0f;
|
bcol = (bcol + 1) & 0x0f;
|
||||||
(void)bordercolor(bgcol);
|
(void)bordercolor(bcol);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CH_F6
|
#ifdef CH_F6
|
||||||
} else if (i == CH_F6) {
|
case CH_F6:
|
||||||
bgcol = (bgcol - 1) & 0x0f;
|
bcol = (bcol - 1) & 0x0f;
|
||||||
(void)bordercolor(bgcol);
|
(void)bordercolor(bcol);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CH_F7
|
#ifdef CH_F7
|
||||||
} else if (i == CH_F7) {
|
case CH_F7:
|
||||||
bgcol = (bgcol + 1) & 0x0f;
|
bgcol = (bgcol + 1) & 0x0f;
|
||||||
(void)bgcolor(bgcol);
|
(void)bgcolor(bgcol);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CH_F8
|
#ifdef CH_F8
|
||||||
} else if (i == CH_F8) {
|
case CH_F8:
|
||||||
bgcol = (bgcol - 1) & 0x0f;
|
bgcol = (bgcol - 1) & 0x0f;
|
||||||
(void)bgcolor(bgcol);
|
(void)bgcolor(bgcol);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
default:
|
||||||
cputc(i);
|
cputc(i);
|
||||||
inpos = (inpos + 1) & 7;
|
/* fallthrough */
|
||||||
|
case CH_CURS_RIGHT:
|
||||||
|
inpos = (inpos + 1) % 8;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
++n;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue