http://www.ctv.es/pckits/tutorial.html
#include <tscope.h>
#include <tscope/internal.h>
int main()
{
ts_scrsize(SIZE1);
ts_defkey(KEY_SPACE);
ts_textmode(0);
if (ioperm(PAR1STATUS, 1, 1))
ts_fatal("error opening parallel port");
if (ioperm(PAR2STATUS, 1, 1))
ts_fatal("error opening parallel port");
if (ioperm(PAR3STATUS, 1, 1))
ts_fatal("error opening parallel port");
ts_printf_centre(0, YMAX - 20, "testpport.c");
ts_printf_centre(0, YMAX - 20, "Status of the parallel ports:");
ts_printf(-XMAX + 20, -YMAX + 170,
"If a button is ON when pressed, use a P(PP)1-P(PP)5 definition");
ts_printf(-XMAX + 20, -YMAX + 160,
"If a buttons is OFF when pressed, use a IP(PP)1-IP(PP)5 definition");
ts_printf(-XMAX + 20, -YMAX + 120,
"If no box is connected, the values are undefined");
ts_printf(-XMAX + 20, -YMAX + 80, "Read the source of this program");
ts_printf(-XMAX + 20, -YMAX + 70, "for more information about");
ts_printf(-XMAX + 20, -YMAX + 60, "the parallel posrt.");
ts_printf(-XMAX + 20, -YMAX + 20, "Press space to exit.");
ts_printf_centre(0, 180, "parallel port 1");
ts_printf_centre(0, 100, "parallel port 2");
ts_printf_centre(0, 20, "parallel port 3");
int i, resp, boxhex;
do {
resp = ts_respstatus();
for (i = 0; i < 3; i++) {
if (i == 0) {
boxhex = inb(PAR1STATUS);
} else if (i == 1) {
boxhex = inb(PAR2STATUS);
} else {
boxhex = inb(PAR3STATUS);
}
if ((boxhex & 8) >> 3)
ts_fgcolor(RED);
else
ts_fgcolor(WHITE);
ts_printf_centre(0, 160 - 80 * i, "P(PP)1 (pin 15 / bit 3)");
if ((boxhex & 16) >> 4)
ts_fgcolor(RED);
else
ts_fgcolor(WHITE);
ts_printf_centre(0, 150 - 80 * i, "P(PP)2 (pin 17 / bit 4)");
if ((boxhex & 32) >> 5)
ts_fgcolor(RED);
else
ts_fgcolor(WHITE);
ts_printf_centre(0, 140 - 80 * i, "P(PP)3 (pin 12 / bit 5)");
if ((boxhex & 64) >> 6)
ts_fgcolor(RED);
else
ts_fgcolor(WHITE);
ts_printf_centre(0, 130 - 80 * i, "P(PP)4 (pin 10 / bit 6)");
if ((boxhex & 128) >> 7)
ts_fgcolor(RED);
else
ts_fgcolor(WHITE);
ts_printf_centre(0, 120 - 80 * i, "P(PP)5 (pin 11 / bit 7)");
}
} while (resp != 1);
ioperm(PAR1DATA, 3, 0);
ioperm(PAR2DATA, 3, 0);
ioperm(PAR3DATA, 3, 0);
return 0;
}
END_OF_MAIN();