]> git.sur5r.net Git - cc65/blob - testcode/lib/joy-test.c
Another small change in OptJumpTarget3.
[cc65] / testcode / lib / joy-test.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <errno.h>
5 #include <conio.h>
6 #include <joystick.h>
7
8
9 int main (void)
10 {
11     unsigned char j;
12     unsigned char count;
13     unsigned char i;
14
15 #ifdef __NES__
16     extern void *co65_joy;
17     unsigned char Res = joy_install (&co65_joy);
18 #else
19     unsigned char Res = joy_load_driver (joy_stddrv);
20 #endif
21     if (Res != JOY_ERR_OK) {
22         cprintf ("Error in joy_load_driver: %u\r\n", Res);
23         cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
24         exit (EXIT_FAILURE);
25     }
26
27     clrscr ();
28     count = joy_count ();
29     cprintf ("Driver supports %d joystick(s)", count);
30     while (1) {
31         for (i = 0; i < count; ++i) {
32             gotoxy (0, i+1);
33             j = joy_read (i);
34             cprintf ("%2d: %-6s%-6s%-6s%-6s%-6s%-6s",
35                      i,
36                      (j & joy_masks[JOY_UP])?    "  up  " : " ---- ",
37                      (j & joy_masks[JOY_DOWN])?  " down " : " ---- ",
38                      (j & joy_masks[JOY_LEFT])?  " left " : " ---- ",
39                      (j & joy_masks[JOY_RIGHT])? "right " : " ---- ",
40                      (j & joy_masks[JOY_FIRE])?  " fire " : " ---- ",
41                      (j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- ");
42         }
43     }
44     return 0;
45 }
46