2 ; Ullrich von Bassewitz, 2002-12-20
4 ; Common functions of the joystick API.
7 .export _joy_install, _joy_uninstall, _joy_masks
12 .include "joy-kernel.inc"
13 .include "joy-error.inc"
16 ;----------------------------------------------------------------------------
21 _joy_drv: .res 2 ; Pointer to driver
23 _joy_masks: .res JOY_MASK_COUNT
25 ; Jump table for the driver functions.
28 joy_install: jmp $0000
29 joy_uninstall: jmp $0000
33 ; Driver header signature
35 joy_sig: .byte $6A, $6F, $79, $00 ; "joy", version
36 joy_sig_len = * - joy_sig
39 ;----------------------------------------------------------------------------
40 ; unsigned char __fastcall__ joy_install (void* driver);
41 ; /* Install the driver once it is loaded */
50 ; Check the driver signature
61 ldy #JOY_MASKS + JOY_MASK_COUNT - 1
69 ; Copy the jump vectors
73 @L2: inx ; Skip the JMP opcode
74 jsr copy ; Copy one byte
75 jsr copy ; Copy one byte
76 cpx #(JOY_HDR_JUMPCOUNT*3)
79 jmp joy_install ; Call driver install routine
81 ; Driver signature invalid
84 lda #JOY_ERR_INV_DRIVER
88 ; Copy one byte from the jump vectors
92 set: sta joy_vectors,x
96 ;----------------------------------------------------------------------------
97 ; unsigned char __fastcall__ joy_uninstall (void);
98 ; /* Uninstall the currently loaded driver. Note: This call does not free
103 jsr joy_uninstall ; Call the driver routine
105 joy_clear_ptr: ; External entry point
108 sta _joy_drv+1 ; Clear the driver pointer