;/* */
;/* */
;/* */
-;/* (C) 2002 Ullrich von Bassewitz */
-;/* Wacholderweg 14 */
-;/* D-70597 Stuttgart */
-;/* EMail: uz@musoftware.de */
+;/* (C) 2002-2006, Ullrich von Bassewitz */
+;/* Römerstraße 52 */
+;/* D-70794 Filderstadt */
+;/* EMail: uz@cc65.org */
;/* */
;/* */
;/* This software is provided 'as-is', without any expressed or implied */
.global _joy_count
.global _joy_read
+ .global _joy_clear_ptr
/* */
/* */
/* */
-/* (C) 2002-2004 Ullrich von Bassewitz */
-/* Römerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2002-2006, Ullrich von Bassewitz */
+/* Römerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+void joy_clear_ptr (void);
+/* Clear the joy_drv pointer */
+
+
+
/* End of joy-kernel.h */
#endif
; Common functions of the joystick API.
;
- .export joy_clear_ptr
-
.importzp ptr1
.interruptor joy_irq ; Export as IRQ handler
jsr joy_uninstall ; Call the driver routine
-joy_clear_ptr: ; External entry point
+_joy_clear_ptr: ; External entry point
lda #0
sta _joy_drv
sta _joy_drv+1 ; Clear the driver pointer
/* */
/* */
/* */
-/* (C) 2002-2003 Ullrich von Bassewitz */
-/* Römerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2002-2006, Ullrich von Bassewitz */
+/* Römerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
+/* Use static local variables, since the module is not reentrant anyway */
+#pragma staticlocals (on);
+
+
+
unsigned char __fastcall__ joy_load_driver (const char* name)
/* Load a joystick driver and return an error code */
{
if (Res == MLOAD_OK) {
/* Check the driver signature, install the driver */
- return joy_install (ctrl.module);
-
+ Res = joy_install (ctrl.module);
+
+ /* If the driver did not install correctly, remove it from
+ * memory again.
+ */
+ if (Res != JOY_ERR_OK) {
+ /* Do not call mouse_uninstall here, since the driver is not
+ * correctly installed.
+ */
+ mod_free (joy_drv);
+ joy_clear_ptr ();
+ }
+
+ /* Return the error code */
+ return Res;
}
}