2 ; Standard joystick driver for the Apple ][. May be used multiple times when
3 ; linked to the statically application.
5 ; Ullrich von Bassewitz, 2003-05-02
6 ; Using the readjoy code from Stefan Haubenthal
9 .include "zeropage.inc"
11 .include "joy-kernel.inc"
12 .include "joy-error.inc"
18 ; ------------------------------------------------------------------------
23 ; ------------------------------------------------------------------------
26 PREAD := $FB1E ; Read paddle in X, return AD conv. value in Y
28 ; ------------------------------------------------------------------------
29 ; Header. Includes jump table
35 .byte $6A, $6F, $79 ; "joy"
36 .byte JOY_API_VERSION ; Driver API version number
38 ; Button state masks (8 values)
45 .byte $00 ; Future expansion
46 .byte $00 ; Future expansion
47 .byte $00 ; Future expansion
56 ; ------------------------------------------------------------------------
59 JOY_COUNT = 2 ; Number of joysticks we support
62 ; ------------------------------------------------------------------------
68 ; ------------------------------------------------------------------------
69 ; INSTALL routine. Is called after the driver is loaded into memory. If
70 ; possible, check if the hardware is present and determine the amount of
72 ; Must return an JOY_ERR_xx code in a/x.
78 ; rts ; Run into UNINSTALL instead
80 ; ------------------------------------------------------------------------
81 ; UNINSTALL routine. Is called before the driver is removed from memory.
82 ; Can do cleanup or whatever. Must not return anything.
89 ; ------------------------------------------------------------------------
90 ; COUNT: Return the total number of available joysticks in a/x.
98 ; ------------------------------------------------------------------------
99 ; READ: Read a particular joystick passed in A.
103 and #$01 ; Fix joystick number
105 tax ; Joystick number (0,2) into X
109 lda BUTN0,x ; Check fire button
110 and #$80 ; BTN 0 0 0 0 0 0 0
113 jsr PREAD ; Read first paddle value
116 ror a ; /LEFT BTN 0 0 0 0 0 0
118 ror a ; RIGHT /LEFT BTN 0 0 0 0 0
122 jsr PREAD ; Read second paddle
125 ror a ; /UP RIGHT /LEFT BTN 0 0 0 0
127 ror a ; DOWN /UP RIGHT /LEFT BTN 0 0 0
128 eor #%01010000 ; DOWN UP RIGHT LEFT BTN 0 0 0