From: cuz Date: Sat, 21 Dec 2002 09:35:54 +0000 (+0000) Subject: Replaced joystick test program X-Git-Tag: V2.12.0~1849 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=deca5a5fbab3e21b8952507b8ec572ccb5160b02;p=cc65 Replaced joystick test program git-svn-id: svn://svn.cc65.org/cc65/trunk@1822 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/testcode/lib/files.txt b/testcode/lib/files.txt index 012162655..f89751b33 100644 --- a/testcode/lib/files.txt +++ b/testcode/lib/files.txt @@ -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 diff --git a/testcode/lib/joy-test.c b/testcode/lib/joy-test.c new file mode 100644 index 000000000..3e1d97bcb --- /dev/null +++ b/testcode/lib/joy-test.c @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include +#include + + +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; +} + diff --git a/testcode/lib/joytest.c b/testcode/lib/joytest.c deleted file mode 100644 index 9494c00cf..000000000 --- a/testcode/lib/joytest.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * simple joystick test program - * CPG 2000 - */ - -#include -#include -#include - -/*#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(" "); - } - } -}