From: cuz Date: Mon, 10 Feb 2003 22:11:12 +0000 (+0000) Subject: Make joy_install, joy_uninstall user callable functions X-Git-Tag: V2.12.0~1738 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3aee15b6cee00116d19fbc7fcc7520a7d574916a;p=cc65 Make joy_install, joy_uninstall user callable functions git-svn-id: svn://svn.cc65.org/cc65/trunk@1950 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/asminc/joy-kernel.inc b/asminc/joy-kernel.inc index f108ed1fe..4517767e2 100644 --- a/asminc/joy-kernel.inc +++ b/asminc/joy-kernel.inc @@ -47,7 +47,7 @@ JOY_MASK_COUNT = 8 ; Size of the array 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 @@ -62,7 +62,7 @@ JOY_HDR_JUMPCOUNT = 4 ; Number of jump vectors ; Driver entry points .global joy_install - .global joy_deinstall + .global joy_uninstall .global joy_count .global joy_read @@ -70,7 +70,8 @@ JOY_HDR_JUMPCOUNT = 4 ; Number of jump vectors ; ASM functions .global _joy_install - .global _joy_deinstall + .global _joy_uninstall .global _joy_count .global _joy_read + diff --git a/include/joystick.h b/include/joystick.h index fcc7146cb..df7bf5c56 100644 --- a/include/joystick.h +++ b/include/joystick.h @@ -84,10 +84,18 @@ extern const char joy_stddrv[]; 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 */ diff --git a/include/joystick/joy-kernel.h b/include/joystick/joy-kernel.h index f30f7982b..0a967a8f1 100644 --- a/include/joystick/joy-kernel.h +++ b/include/joystick/joy-kernel.h @@ -58,7 +58,7 @@ typedef struct { /* 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 */ @@ -71,21 +71,6 @@ extern joy_drv_header* joy_drv; /* Pointer to driver */ - -/*****************************************************************************/ -/* 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 diff --git a/libsrc/joystick/joy-kernel.s b/libsrc/joystick/joy-kernel.s index 61d35ce2b..fbed5ce0a 100644 --- a/libsrc/joystick/joy-kernel.s +++ b/libsrc/joystick/joy-kernel.s @@ -4,8 +4,9 @@ ; 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" @@ -25,7 +26,7 @@ _joy_masks: .res JOY_MASK_COUNT .data joy_vectors: joy_install: jmp $0000 -joy_deinstall: jmp $0000 +joy_uninstall: jmp $0000 joy_count: jmp $0000 joy_read: jmp $0000 @@ -42,9 +43,9 @@ joy_sig_len = * - joy_sig _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 @@ -93,8 +94,19 @@ set: sta joy_vectors,x 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 diff --git a/libsrc/joystick/joy_unload.s b/libsrc/joystick/joy_unload.s index ffca49c4c..e5077703e 100644 --- a/libsrc/joystick/joy_unload.s +++ b/libsrc/joystick/joy_unload.s @@ -5,6 +5,8 @@ ; /* Unload the currently loaded driver. */ + .import joy_clear_ptr + .include "joy-kernel.inc" .include "joy-error.inc" .include "modload.inc" @@ -14,22 +16,17 @@ _joy_unload: 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 - +