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 .sizeof(JOY_HDR::MASKS)
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, JOY_API_VERSION ; "joy", version
38 ;----------------------------------------------------------------------------
39 ; unsigned char __fastcall__ joy_install (void* driver);
40 ; /* Install the driver once it is loaded */
49 ; Check the driver signature
51 ldy #.sizeof(joy_sig)-1
60 ldy #JOY_HDR::MASKS + .sizeof(JOY_HDR::MASKS) - 1
61 ldx #.sizeof(JOY_HDR::MASKS)-1
68 ; Copy the jump vectors
72 @L2: inx ; Skip the JMP opcode
73 jsr copy ; Copy one byte
74 jsr copy ; Copy one byte
75 cpy #(JOY_HDR::JUMPTAB + .sizeof(JOY_HDR::JUMPTAB))
78 jmp joy_install ; Call driver install routine
80 ; Driver signature invalid
83 lda #JOY_ERR_INV_DRIVER
87 ; Copy one byte from the jump vectors
91 set: sta joy_vectors,x
95 ;----------------------------------------------------------------------------
96 ; unsigned char __fastcall__ joy_uninstall (void);
97 ; /* Uninstall the currently loaded driver. Note: This call does not free
102 jsr joy_uninstall ; Call the driver routine
104 joy_clear_ptr: ; External entry point
107 sta _joy_drv+1 ; Clear the driver pointer