Merge pull request #125 from groessler/something_to_pull2
Adapt joy-test.c for Atari 5200
This commit is contained in:
@@ -40,6 +40,11 @@
|
|||||||
# error This module may only be used when compiling for the Atari 5200!
|
# error This module may only be used when compiling for the Atari 5200!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* no support for dynamically loadable drivers */
|
||||||
|
#define DYN_DRV 0
|
||||||
|
|
||||||
|
/* the addresses of the static drivers */
|
||||||
|
extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */
|
||||||
|
|
||||||
/* make GTIA color value */
|
/* make GTIA color value */
|
||||||
#define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1))
|
#define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1))
|
||||||
|
|||||||
@@ -6,31 +6,65 @@
|
|||||||
#include <joystick.h>
|
#include <joystick.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef JOYSTICK_DRIVER
|
||||||
|
|
||||||
|
/* A statically linked driver was named on the compiler's command line.
|
||||||
|
** Make sure that it is used instead of a dynamic one.
|
||||||
|
*/
|
||||||
|
# undef DYN_DRV
|
||||||
|
# define DYN_DRV 0
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Use a dynamically loaded driver, by default. */
|
||||||
|
# ifndef DYN_DRV
|
||||||
|
# define DYN_DRV 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
unsigned char j;
|
unsigned char j;
|
||||||
unsigned char count;
|
unsigned char count;
|
||||||
unsigned char i;
|
unsigned char i;
|
||||||
|
|
||||||
#ifdef __NES__
|
#if DYN_DRV
|
||||||
extern void *co65_joy;
|
|
||||||
unsigned char Res = joy_install (&co65_joy);
|
|
||||||
#else
|
|
||||||
unsigned char Res = joy_load_driver (joy_stddrv);
|
unsigned char Res = joy_load_driver (joy_stddrv);
|
||||||
|
#elif defined(JOYSTICK_DRIVER)
|
||||||
|
unsigned char Res = joy_install (&JOYSTICK_DRIVER);
|
||||||
|
#else
|
||||||
|
unsigned char Res = joy_install (&joy_static_stddrv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Res != JOY_ERR_OK) {
|
if (Res != JOY_ERR_OK) {
|
||||||
cprintf ("Error in joy_load_driver: %u\r\n", Res);
|
cprintf ("Error in joy_load_driver: %u\r\n", Res);
|
||||||
|
#if DYN_DRV
|
||||||
cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
|
cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
|
||||||
|
#endif
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
clrscr ();
|
clrscr ();
|
||||||
count = joy_count ();
|
count = joy_count ();
|
||||||
|
#ifdef __ATARI5200__
|
||||||
|
cprintf ("JOYSTICKS: %d", count);
|
||||||
|
#else
|
||||||
cprintf ("Driver supports %d joystick(s)", count);
|
cprintf ("Driver supports %d joystick(s)", count);
|
||||||
|
#endif
|
||||||
while (1) {
|
while (1) {
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
gotoxy (0, i+1);
|
gotoxy (0, i+1);
|
||||||
j = joy_read (i);
|
j = joy_read (i);
|
||||||
|
#ifdef __ATARI5200__
|
||||||
|
cprintf ("%1d:%-3s%-3s%-3s%-3s%-3s%-3s",
|
||||||
|
i,
|
||||||
|
(j & joy_masks[JOY_UP])? " U " : " u ",
|
||||||
|
(j & joy_masks[JOY_DOWN])? " D " : " d ",
|
||||||
|
(j & joy_masks[JOY_LEFT])? " L " : " l ",
|
||||||
|
(j & joy_masks[JOY_RIGHT])? " R " : " r ",
|
||||||
|
(j & joy_masks[JOY_FIRE])? " 1 " : " ",
|
||||||
|
(j & joy_masks[JOY_FIRE2])? " 2 " : " ");
|
||||||
|
#else
|
||||||
cprintf ("%2d: %-6s%-6s%-6s%-6s%-6s%-6s",
|
cprintf ("%2d: %-6s%-6s%-6s%-6s%-6s%-6s",
|
||||||
i,
|
i,
|
||||||
(j & joy_masks[JOY_UP])? " up " : " ---- ",
|
(j & joy_masks[JOY_UP])? " up " : " ---- ",
|
||||||
@@ -39,8 +73,8 @@ int main (void)
|
|||||||
(j & joy_masks[JOY_RIGHT])? "right " : " ---- ",
|
(j & joy_masks[JOY_RIGHT])? "right " : " ---- ",
|
||||||
(j & joy_masks[JOY_FIRE])? " fire " : " ---- ",
|
(j & joy_masks[JOY_FIRE])? " fire " : " ---- ",
|
||||||
(j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- ");
|
(j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- ");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user