From 5595137d1d5139671064af8aafec4382d30dd6db Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Fri, 30 May 2014 23:38:27 +0200 Subject: [PATCH 1/4] Adapt joy-test.c for Atari 5200 (only has 20x24 display) Fix static driver name. --- testcode/lib/joy-test.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/testcode/lib/joy-test.c b/testcode/lib/joy-test.c index c4bda1e53..f9b3a668a 100644 --- a/testcode/lib/joy-test.c +++ b/testcode/lib/joy-test.c @@ -5,6 +5,11 @@ #include #include +#if defined(__NES__) || defined(__ATARI5200__) +#define STATIC_DRIVER +#define NO_OSERROR +#endif + int main (void) { @@ -12,25 +17,40 @@ int main (void) unsigned char count; unsigned char i; -#ifdef __NES__ - extern void *co65_joy; - unsigned char Res = joy_install (&co65_joy); +#ifdef STATIC_DRIVER + unsigned char Res = joy_install (&joy_static_stddrv); #else unsigned char Res = joy_load_driver (joy_stddrv); #endif if (Res != JOY_ERR_OK) { cprintf ("Error in joy_load_driver: %u\r\n", Res); +#ifndef NO_OSERROR cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror)); +#endif exit (EXIT_FAILURE); } clrscr (); count = joy_count (); +#ifdef __ATARI5200__ + cprintf ("JOYSTICKS: %d", count); +#else cprintf ("Driver supports %d joystick(s)", count); +#endif while (1) { for (i = 0; i < count; ++i) { gotoxy (0, i+1); 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", i, (j & joy_masks[JOY_UP])? " up " : " ---- ", @@ -39,6 +59,7 @@ int main (void) (j & joy_masks[JOY_RIGHT])? "right " : " ---- ", (j & joy_masks[JOY_FIRE])? " fire " : " ---- ", (j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- "); +#endif } } return 0; From 3508b90ee844ad82552d1100779064c48b0c0ee6 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Sat, 31 May 2014 19:44:10 +0200 Subject: [PATCH 2/4] set DYN_DRV to 0; define atr5200std_joy --- include/atari5200.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/atari5200.h b/include/atari5200.h index 779095217..4bd5bc0fd 100644 --- a/include/atari5200.h +++ b/include/atari5200.h @@ -40,6 +40,11 @@ # error This module may only be used when compiling for the Atari 5200! #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 */ #define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1)) From deddb00a3a3ccee1f3b258b6d5e9c4074bdf0f50 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Sun, 1 Jun 2014 19:17:02 +0200 Subject: [PATCH 3/4] use DYN_DRV and MOUSE_DRIVER defines to decide which driver to use --- testcode/lib/joy-test.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/testcode/lib/joy-test.c b/testcode/lib/joy-test.c index f9b3a668a..bea8be718 100644 --- a/testcode/lib/joy-test.c +++ b/testcode/lib/joy-test.c @@ -5,8 +5,15 @@ #include #include +#ifdef MOUSE_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 +#endif + #if defined(__NES__) || defined(__ATARI5200__) -#define STATIC_DRIVER #define NO_OSERROR #endif @@ -17,11 +24,14 @@ int main (void) unsigned char count; unsigned char i; -#ifdef STATIC_DRIVER - unsigned char Res = joy_install (&joy_static_stddrv); -#else +#if DYN_DRV unsigned char Res = joy_load_driver (joy_stddrv); +#elif defined(MOUSE_DRIVER) + unsigned char Res = joy_install (&MOUSE_DRIVER); +#else + unsigned char Res = joy_install (&joy_static_stddrv); #endif + if (Res != JOY_ERR_OK) { cprintf ("Error in joy_load_driver: %u\r\n", Res); #ifndef NO_OSERROR @@ -64,4 +74,3 @@ int main (void) } return 0; } - From 939a5ccbc2bb29b12f71f2a81206464ec46b0434 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Mon, 2 Jun 2014 08:41:35 +0200 Subject: [PATCH 4/4] fix last change --- testcode/lib/joy-test.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/testcode/lib/joy-test.c b/testcode/lib/joy-test.c index bea8be718..0a5c80902 100644 --- a/testcode/lib/joy-test.c +++ b/testcode/lib/joy-test.c @@ -5,16 +5,20 @@ #include #include -#ifdef MOUSE_DRIVER + +#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 -#endif +#else -#if defined(__NES__) || defined(__ATARI5200__) -#define NO_OSERROR +/* Use a dynamically loaded driver, by default. */ +# ifndef DYN_DRV +# define DYN_DRV 1 +# endif #endif @@ -26,15 +30,15 @@ int main (void) #if DYN_DRV unsigned char Res = joy_load_driver (joy_stddrv); -#elif defined(MOUSE_DRIVER) - unsigned char Res = joy_install (&MOUSE_DRIVER); +#elif defined(JOYSTICK_DRIVER) + unsigned char Res = joy_install (&JOYSTICK_DRIVER); #else unsigned char Res = joy_install (&joy_static_stddrv); #endif if (Res != JOY_ERR_OK) { cprintf ("Error in joy_load_driver: %u\r\n", Res); -#ifndef NO_OSERROR +#if DYN_DRV cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror)); #endif exit (EXIT_FAILURE);