1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-28 10:55:43 +00:00

Make joy_install, joy_uninstall user callable functions

git-svn-id: svn://svn.cc65.org/cc65/trunk@1950 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-02-10 22:11:12 +00:00
parent 0346cf692e
commit 3aee15b6ce
5 changed files with 41 additions and 38 deletions

View File

@ -47,7 +47,7 @@ JOY_MASK_COUNT = 8 ; Size of the array
JOY_HDR_JUMPTAB = 12 JOY_HDR_JUMPTAB = 12
JOY_HDR_INSTALL = JOY_HDR_JUMPTAB+0 ; INSTALL routine 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_COUNT = JOY_HDR_JUMPTAB+4 ; COUNT routine
JOY_HDR_READ = JOY_HDR_JUMPTAB+6 ; READ 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 ; Driver entry points
.global joy_install .global joy_install
.global joy_deinstall .global joy_uninstall
.global joy_count .global joy_count
.global joy_read .global joy_read
@ -70,7 +70,8 @@ JOY_HDR_JUMPCOUNT = 4 ; Number of jump vectors
; ASM functions ; ASM functions
.global _joy_install .global _joy_install
.global _joy_deinstall .global _joy_uninstall
.global _joy_count .global _joy_count
.global _joy_read .global _joy_read

View File

@ -84,10 +84,18 @@ extern const char joy_stddrv[];
unsigned char __fastcall__ joy_load_driver (const char* driver); 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); 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); unsigned char __fastcall__ joy_count (void);
/* Return the number of joysticks supported by the driver */ /* Return the number of joysticks supported by the driver */

View File

@ -58,7 +58,7 @@ typedef struct {
/* Jump vectors. Note that these are not C callable */ /* Jump vectors. Note that these are not C callable */
void* install; /* INSTALL routine */ void* install; /* INSTALL routine */
void* deinstall; /* DEINSTALL routine */ void* uninstall; /* UNINSTALL routine */
void* count; /* COUNT routine */ void* count; /* COUNT routine */
void* read; /* READ 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 */ /* End of joy-kernel.h */
#endif #endif

View File

@ -4,7 +4,8 @@
; Common functions of the joystick API. ; 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 .importzp ptr1
@ -25,7 +26,7 @@ _joy_masks: .res JOY_MASK_COUNT
.data .data
joy_vectors: joy_vectors:
joy_install: jmp $0000 joy_install: jmp $0000
joy_deinstall: jmp $0000 joy_uninstall: jmp $0000
joy_count: jmp $0000 joy_count: jmp $0000
joy_read: jmp $0000 joy_read: jmp $0000
@ -93,8 +94,19 @@ set: sta joy_vectors,x
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
; void __fastcall__ joy_deinstall (void); ; unsigned char __fastcall__ joy_uninstall (void);
; /* Deinstall the driver before unloading it */ ; /* Uninstall the currently loaded driver. Note: This call does not free
; * allocated memory.
; */
_joy_deinstall = joy_deinstall ; Call driver routine _joy_uninstall:
jsr joy_uninstall ; Call the 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

View File

@ -5,6 +5,8 @@
; /* Unload the currently loaded driver. */ ; /* Unload the currently loaded driver. */
.import joy_clear_ptr
.include "joy-kernel.inc" .include "joy-kernel.inc"
.include "joy-error.inc" .include "joy-error.inc"
.include "modload.inc" .include "modload.inc"
@ -14,18 +16,13 @@ _joy_unload:
ora _joy_drv+1 ora _joy_drv+1
beq no_driver ; No driver beq no_driver ; No driver
jsr _joy_deinstall ; Deinstall the driver jsr joy_uninstall ; Uninstall the driver
lda _joy_drv lda _joy_drv
ldx _joy_drv+1 ldx _joy_drv+1
jsr _mod_free ; Free the driver jsr _mod_free ; Free the driver
lda #0 jmp joy_clear_ptr ; Clear driver pointer, return zero
sta _joy_drv
sta _joy_drv+1 ; Clear the driver pointer
tax
rts ; Return zero
no_driver: no_driver:
tax ; X = 0 tax ; X = 0