2015-10-14 15:24:42 +00:00
|
|
|
/*
|
2018-08-20 18:42:41 +00:00
|
|
|
* conio API test program
|
2015-10-14 15:24:42 +00:00
|
|
|
*
|
|
|
|
* keys:
|
|
|
|
*
|
|
|
|
* 1...0 change text color
|
|
|
|
* F5/F6 change border color
|
|
|
|
* F7/F8 change background color
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-09-27 16:12:25 +00:00
|
|
|
|
|
|
|
#include <conio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2015-12-01 22:06:51 +00:00
|
|
|
#include <joystick.h>
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-11-29 00:14:59 +00:00
|
|
|
#if defined(__GAMATE__)
|
2015-11-30 17:44:04 +00:00
|
|
|
/* there is not enough screen space to show all 256 characters at the bottom */
|
2015-11-29 00:14:59 +00:00
|
|
|
#define NUMCHARS 128
|
|
|
|
#define NUMCOLS 4
|
|
|
|
#else
|
|
|
|
#define NUMCHARS 256
|
|
|
|
#define NUMCOLS 16
|
|
|
|
#endif
|
|
|
|
|
2015-09-28 13:29:14 +00:00
|
|
|
static char grid[5][5] = {
|
2018-08-19 22:29:29 +00:00
|
|
|
{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 },
|
2018-08-20 18:42:41 +00:00
|
|
|
{CH_LLCORNER, CH_HLINE, CH_BTEE, CH_HLINE, CH_LRCORNER}
|
2015-09-28 13:29:14 +00:00
|
|
|
};
|
|
|
|
|
2015-09-27 16:12:25 +00:00
|
|
|
void main(void)
|
|
|
|
{
|
2018-08-20 18:42:41 +00:00
|
|
|
unsigned int i, j, n;
|
2015-10-14 15:24:42 +00:00
|
|
|
unsigned char xsize, ysize, tcol, bgcol, bcol, inpos = 0;
|
2015-12-01 23:13:32 +00:00
|
|
|
#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__)
|
|
|
|
unsigned char joy;
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-12-01 23:13:32 +00:00
|
|
|
joy_install(joy_static_stddrv);
|
|
|
|
#endif
|
2015-09-27 16:12:25 +00:00
|
|
|
clrscr();
|
|
|
|
screensize(&xsize, &ysize);
|
2015-11-29 00:14:59 +00:00
|
|
|
cputs("cc65 conio test\n\r");
|
2018-08-20 18:42:41 +00:00
|
|
|
cputs("Input:[ ]"); /* 8 spaces */
|
2015-09-27 16:36:53 +00:00
|
|
|
|
2018-08-20 18:42:41 +00:00
|
|
|
tcol = textcolor(0); /* memorize original textcolor */
|
|
|
|
bgcol = bgcolor(0); /* memorize original background color */
|
|
|
|
bcol = bordercolor(0); /* memorize original border color */
|
2018-08-19 22:29:29 +00:00
|
|
|
(void)bordercolor(bcol);
|
2018-08-20 18:42:41 +00:00
|
|
|
(void)bgcolor(bgcol);
|
|
|
|
|
|
|
|
cputsxy(0, 2, "Colors:" );
|
2015-09-28 13:29:14 +00:00
|
|
|
for (i = 0; i < 3; ++i) {
|
2018-08-19 22:29:29 +00:00
|
|
|
gotoxy(i, 3 + i);
|
2015-11-29 00:14:59 +00:00
|
|
|
for (j = 0; j < NUMCOLS; ++j) {
|
2018-08-19 22:29:29 +00:00
|
|
|
(void)textcolor(j);
|
2015-09-27 16:12:25 +00:00
|
|
|
cputc('X');
|
|
|
|
}
|
|
|
|
}
|
2018-08-19 22:29:29 +00:00
|
|
|
(void)textcolor(tcol);
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2018-08-20 18:42:41 +00:00
|
|
|
cprintf("\n\n\r Screensize: %ux%u", xsize, ysize);
|
2015-09-28 13:29:14 +00:00
|
|
|
|
2018-08-19 22:29:29 +00:00
|
|
|
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-27 16:12:25 +00:00
|
|
|
|
2015-09-28 13:29:14 +00:00
|
|
|
for (i = 0; i < 5; ++i) {
|
2018-08-19 22:29:29 +00:00
|
|
|
gotoxy(xsize - 5, i);
|
2015-09-28 13:29:14 +00:00
|
|
|
for (j = 0; j < 5; ++j) {
|
|
|
|
cputc(grid[i][j]);
|
|
|
|
}
|
|
|
|
}
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2018-08-19 22:29:29 +00:00
|
|
|
gotoxy(0, ysize - 2 - ((NUMCHARS + xsize) / xsize));
|
2015-09-28 13:29:14 +00:00
|
|
|
revers(1);
|
2015-09-27 16:12:25 +00:00
|
|
|
for (i = 0; i < xsize; ++i) {
|
|
|
|
cputc('0' + i % 10);
|
|
|
|
}
|
2015-09-28 13:29:14 +00:00
|
|
|
revers(0);
|
2015-11-29 00:14:59 +00:00
|
|
|
for (i = 0; i < NUMCHARS; ++i) {
|
2015-09-27 16:12:25 +00:00
|
|
|
if ((i != '\n') && (i != '\r')) {
|
|
|
|
cputc(i);
|
2015-10-11 15:07:48 +00:00
|
|
|
} else {
|
|
|
|
cputc(' ');
|
2015-09-27 16:12:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while(wherex() > 0) {
|
|
|
|
cputc('#');
|
|
|
|
}
|
2015-09-28 13:29:14 +00:00
|
|
|
revers(1);
|
2015-09-27 16:12:25 +00:00
|
|
|
for (i = 0; i < xsize; ++i) {
|
|
|
|
cputc('0' + i % 10);
|
|
|
|
}
|
2015-09-28 13:29:14 +00:00
|
|
|
revers(0);
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-09-28 15:12:33 +00:00
|
|
|
cursor(1);
|
2015-12-01 22:06:51 +00:00
|
|
|
for (;;) {
|
2015-12-01 23:13:32 +00:00
|
|
|
/* do the "rvs" blinking */
|
|
|
|
i = textcolor(COLOR_BLACK);
|
2015-09-28 13:29:14 +00:00
|
|
|
gotoxy(8, 2);
|
2018-08-20 18:42:41 +00:00
|
|
|
j = (++n / 16) & 1;
|
2015-09-27 16:12:25 +00:00
|
|
|
revers(j);
|
|
|
|
cputc(j ? 'R' : ' ');
|
2015-09-28 15:12:33 +00:00
|
|
|
revers(j ^ 1);
|
2015-11-29 00:14:59 +00:00
|
|
|
cputs(" rvs");
|
2015-09-27 16:12:25 +00:00
|
|
|
revers(0);
|
2018-08-19 22:29:29 +00:00
|
|
|
(void)textcolor(i);
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2018-08-19 22:29:29 +00:00
|
|
|
gotoxy(7 + inpos, 1);
|
2015-12-01 22:06:51 +00:00
|
|
|
|
2015-12-01 23:13:32 +00:00
|
|
|
#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__)
|
2017-07-17 21:15:05 +00:00
|
|
|
/* not all targets have waitvsync */
|
|
|
|
waitvsync();
|
2015-12-01 23:13:32 +00:00
|
|
|
/* for targets that do not have a keyboard, read the first
|
|
|
|
joystick */
|
|
|
|
joy = joy_read(JOY_1);
|
|
|
|
cprintf("%02x", joy);
|
2015-12-01 22:06:51 +00:00
|
|
|
#else
|
2015-10-09 21:39:55 +00:00
|
|
|
i = cgetc();
|
2018-08-20 18:42:41 +00:00
|
|
|
switch (i) {
|
|
|
|
case CH_ENTER:
|
|
|
|
clrscr();
|
|
|
|
return;
|
|
|
|
case CH_CURS_LEFT:
|
|
|
|
inpos = (inpos - 1) % 8;
|
|
|
|
break;
|
|
|
|
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;
|
2018-08-19 22:29:29 +00:00
|
|
|
#ifdef CH_F5
|
2018-08-20 18:42:41 +00:00
|
|
|
case CH_F5:
|
|
|
|
bcol = (bcol + 1) & 0x0f;
|
|
|
|
(void)bordercolor(bcol);
|
|
|
|
break;
|
2018-08-19 22:29:29 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CH_F6
|
2018-08-20 18:42:41 +00:00
|
|
|
case CH_F6:
|
|
|
|
bcol = (bcol - 1) & 0x0f;
|
|
|
|
(void)bordercolor(bcol);
|
|
|
|
break;
|
2018-08-19 22:29:29 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CH_F7
|
2018-08-20 18:42:41 +00:00
|
|
|
case CH_F7:
|
|
|
|
bgcol = (bgcol + 1) & 0x0f;
|
|
|
|
(void)bgcolor(bgcol);
|
|
|
|
break;
|
2018-08-19 22:29:29 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CH_F8
|
2018-08-20 18:42:41 +00:00
|
|
|
case CH_F8:
|
|
|
|
bgcol = (bgcol - 1) & 0x0f;
|
|
|
|
(void)bgcolor(bgcol);
|
|
|
|
break;
|
2018-08-19 22:29:29 +00:00
|
|
|
#endif
|
2018-08-20 18:42:41 +00:00
|
|
|
default:
|
|
|
|
cputc(i);
|
|
|
|
/* fallthrough */
|
|
|
|
case CH_CURS_RIGHT:
|
|
|
|
inpos = (inpos + 1) % 8;
|
2015-10-09 21:39:55 +00:00
|
|
|
}
|
2015-11-29 00:14:59 +00:00
|
|
|
#endif
|
2015-09-27 16:12:25 +00:00
|
|
|
}
|
|
|
|
}
|