JOY_HDR_JUMPTAB = 12
JOY_HDR_INSTALL = JOY_HDR_JUMPTAB+0 ; INSTALL routine
-JOY_HDR_DEINSTALL = JOY_HDR_JUMPTAB+2 ; DEINSTALL routine
+JOY_HDR_UNINSTALL = JOY_HDR_JUMPTAB+2 ; UNINSTALL routine
JOY_HDR_COUNT = JOY_HDR_JUMPTAB+4 ; COUNT routine
JOY_HDR_READ = JOY_HDR_JUMPTAB+6 ; READ routine
; Driver entry points
.global joy_install
- .global joy_deinstall
+ .global joy_uninstall
.global joy_count
.global joy_read
; ASM functions
.global _joy_install
- .global _joy_deinstall
+ .global _joy_uninstall
.global _joy_count
.global _joy_read
+
unsigned char __fastcall__ joy_load_driver (const char* driver);
-/* Load a joystick driver and return an error code */
+/* Load and install a joystick driver. Return an error code. */
unsigned char __fastcall__ joy_unload (void);
-/* Unload the currently loaded driver. */
+/* Uninstall, then unload the currently loaded driver. */
+
+unsigned char __fastcall__ joy_install (void* driver);
+/* Install an already loaded driver. */
+
+unsigned char __fastcall__ joy_uninstall (void);
+/* Uninstall the currently loaded driver. Note: This call does not free
+ * allocated memory.
+ */
unsigned char __fastcall__ joy_count (void);
/* Return the number of joysticks supported by the driver */
/* Jump vectors. Note that these are not C callable */
void* install; /* INSTALL routine */
- void* deinstall; /* DEINSTALL routine */
+ void* uninstall; /* UNINSTALL routine */
void* count; /* COUNT routine */
void* read; /* READ routine */
-
-/*****************************************************************************/
-/* Functions */
-/*****************************************************************************/
-
-
-
-unsigned char __fastcall__ joy_install (void* driver);
-/* Install the driver once it is loaded, return an error code. */
-
-void __fastcall__ joy_deinstall (void);
-/* Deinstall the driver before unloading it */
-
-
-
/* End of joy-kernel.h */
#endif
; Common functions of the joystick API.
;
- .export _joy_install, _joy_deinstall, _joy_masks
-
+ .export _joy_install, _joy_uninstall, _joy_masks
+ .export joy_clear_ptr
+
.importzp ptr1
.include "joy-kernel.inc"
.data
joy_vectors:
joy_install: jmp $0000
-joy_deinstall: jmp $0000
+joy_uninstall: jmp $0000
joy_count: jmp $0000
joy_read: jmp $0000
_joy_install:
sta _joy_drv
- sta ptr1
- stx _joy_drv+1
- stx ptr1+1
+ sta ptr1
+ stx _joy_drv+1
+ stx ptr1+1
; Check the driver signature
rts
;----------------------------------------------------------------------------
-; void __fastcall__ joy_deinstall (void);
-; /* Deinstall the driver before unloading it */
+; unsigned char __fastcall__ joy_uninstall (void);
+; /* Uninstall the currently loaded driver. Note: This call does not free
+; * allocated memory.
+; */
+
+_joy_uninstall:
+ jsr joy_uninstall ; Call the driver routine
-_joy_deinstall = joy_deinstall ; Call driver routine
+joy_clear_ptr: ; External entry point
+ lda #0
+ sta _joy_drv
+ sta _joy_drv+1 ; Clear the driver pointer
+
+ tax ; Return zero
+ rts
; /* Unload the currently loaded driver. */
+ .import joy_clear_ptr
+
.include "joy-kernel.inc"
.include "joy-error.inc"
.include "modload.inc"
ora _joy_drv+1
beq no_driver ; No driver
- jsr _joy_deinstall ; Deinstall the driver
+ jsr joy_uninstall ; Uninstall the driver
lda _joy_drv
ldx _joy_drv+1
jsr _mod_free ; Free the driver
- lda #0
- sta _joy_drv
- sta _joy_drv+1 ; Clear the driver pointer
-
- tax
- rts ; Return zero
+ jmp joy_clear_ptr ; Clear driver pointer, return zero
no_driver:
tax ; X = 0
lda #JOY_ERR_NO_DRIVER
rts
-
+