]> git.sur5r.net Git - cc65/commitdiff
Replaced joystick test program
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 21 Dec 2002 09:35:54 +0000 (09:35 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 21 Dec 2002 09:35:54 +0000 (09:35 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1822 b7a2c559-68d2-44c3-8de9-860c34a00d81

testcode/lib/files.txt
testcode/lib/joy-test.c [new file with mode: 0644]
testcode/lib/joytest.c [deleted file]

index 012162655c67064a88c233c3be1d2bc502f40526..f89751b33cdf2b649df6c0eba66575fcb728a588 100644 (file)
@@ -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 (file)
index 0000000..3e1d97b
--- /dev/null
@@ -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;
+}
+
diff --git a/testcode/lib/joytest.c b/testcode/lib/joytest.c
deleted file mode 100644 (file)
index 9494c00..0000000
+++ /dev/null
@@ -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("      ");
-        }
-    }
-}