mirror of
https://github.com/cc65/cc65.git
synced 2024-12-22 12:30:41 +00:00
Replaced joystick test program
git-svn-id: svn://svn.cc65.org/cc65/trunk@1822 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
69ac0ce1fc
commit
deca5a5fba
@ -11,7 +11,7 @@ em-test.c - test extended memory drivers
|
||||
fileio-test.c - test C file i/o routines (fopen/fread/fwrite/fclose)
|
||||
ft.c - file I/O test program (open + read functions)
|
||||
getsp.s - helper routine for ft.c
|
||||
joytest.c - readjoy function test program
|
||||
joy-test.c - joystick driver test program
|
||||
posixio-test.c - test POSIX file i/o routines (open/read/write/close)
|
||||
seek.c - test lseek()/fseek()/ftell()
|
||||
time-test.c - test the time/mktime/gmtime/asctime functions
|
||||
|
40
testcode/lib/joy-test.c
Normal file
40
testcode/lib/joy-test.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <conio.h>
|
||||
#include <joystick.h>
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
unsigned char j;
|
||||
unsigned char count;
|
||||
unsigned char i;
|
||||
|
||||
unsigned char Res = joy_load_driver (joy_stddrv);
|
||||
if (Res != JOY_ERR_OK) {
|
||||
cprintf ("Error in joy_load_driver: %u\r\n", Res);
|
||||
cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
clrscr ();
|
||||
count = joy_count ();
|
||||
cprintf ("Driver supports %d joystick(s)", count);
|
||||
while (1) {
|
||||
for (i = 0; i < count; ++i) {
|
||||
gotoxy (0, i+1);
|
||||
j = joy_read (i);
|
||||
cprintf ("%2d: %-6s%-6s%-6s%-6s%-6s",
|
||||
i,
|
||||
(j & joy_masks[JOY_UP])? " up " : " ---- ",
|
||||
(j & joy_masks[JOY_DOWN])? " down " : " ---- ",
|
||||
(j & joy_masks[JOY_LEFT])? " left " : " ---- ",
|
||||
(j & joy_masks[JOY_RIGHT])? "right " : " ---- ",
|
||||
(j & joy_masks[JOY_FIRE])? " fire " : " ---- ");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* simple joystick test program
|
||||
* CPG 2000
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <joystick.h>
|
||||
|
||||
/*#define printf_to_use xxprintf*/
|
||||
#define printf_to_use cprintf
|
||||
|
||||
void xxprintf(char *string)
|
||||
{
|
||||
char i=0;
|
||||
|
||||
while (*(string + i)) cputc(*(string + i++));
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char c,j;
|
||||
int s;
|
||||
|
||||
clrscr();
|
||||
printf_to_use("Enter joystick # (0-3): ");
|
||||
do {
|
||||
c = cgetc();
|
||||
} while (c < '0' && c > '3');
|
||||
printf("%c\n",c);
|
||||
j = c - '0';
|
||||
printf("using joystick #%d, 'q' to quit\n",j);
|
||||
|
||||
while(1) {
|
||||
if (kbhit()) {
|
||||
c = cgetc();
|
||||
if (c == 'q' || c == 'Q')
|
||||
return(0);
|
||||
}
|
||||
s = readjoy(j);
|
||||
gotoxy(1,5);
|
||||
if (s & JOY_UP) {
|
||||
printf_to_use("UP ");
|
||||
}
|
||||
else {
|
||||
printf_to_use(" ");
|
||||
}
|
||||
if (s & JOY_DOWN) {
|
||||
printf_to_use("DOWN ");
|
||||
}
|
||||
else {
|
||||
printf_to_use(" ");
|
||||
}
|
||||
if (s & JOY_LEFT) {
|
||||
printf_to_use("LEFT ");
|
||||
}
|
||||
else {
|
||||
printf_to_use(" ");
|
||||
}
|
||||
if (s & JOY_RIGHT) {
|
||||
printf_to_use("RIGHT ");
|
||||
}
|
||||
else {
|
||||
printf_to_use(" ");
|
||||
}
|
||||
if (s & JOY_FIRE) {
|
||||
revers(1);
|
||||
printf_to_use(" FIRE ");
|
||||
revers(0);
|
||||
}
|
||||
else {
|
||||
printf_to_use(" ");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user