2 ; Standard joystick driver for the Plus/4 and C16.
3 ; May be used multiple times when linked statically to an application.
5 ; 2002-12-21, Ullrich von Bassewitz
6 ; 2016-06-18, Greg King
9 .include "joy-kernel.inc"
10 .include "joy-error.inc"
16 ; ------------------------------------------------------------------------
17 ; Header. Includes jump table
19 .if .xmatch ("MODULE_LABEL", .string(MODULE_LABEL))
20 module_header _plus4_stdjoy_joy
22 module_header MODULE_LABEL
27 .byte $6A, $6F, $79 ; ASCII "joy"
28 .byte JOY_API_VERSION ; Driver API version number
34 ; Button state masks (8 values)
41 .byte $00 ; JOY_FIRE2 unavailable
42 .byte $00 ; Future expansion
43 .byte $00 ; Future expansion
51 .addr 0 ; IRQ entry unused
53 ; ------------------------------------------------------------------------
56 JOY_COUNT = 2 ; Number of joysticks we support
59 ; ------------------------------------------------------------------------
65 ; ------------------------------------------------------------------------
66 ; INSTALL routine. Is called after the driver is loaded into memory. If
67 ; possible, check if the hardware is present and determine the amount of
69 ; Must return an JOY_ERR_xx code in a/x.
75 ; rts ; Run into UNINSTALL instead
77 ; ------------------------------------------------------------------------
78 ; UNINSTALL routine. Is called before the driver is removed from memory.
79 ; Can do cleanup or whatever. Must not return anything.
86 ; ------------------------------------------------------------------------
87 ; COUNT: Return the total number of available joysticks in a/x.
95 ; ------------------------------------------------------------------------
96 ; READ: Read a particular joystick passed in A.
99 READ: ldy #%11111011 ; Load index for joystick #1
100 tax ; Test joystick number
102 ldy #%11111101 ; Load index for joystick #2
103 ldx #>$0000 ; (Return unsigned int)
105 sty TED_KBD ; Read a joystick ...
106 lda TED_KBD ; ... and some keys -- it's unavoidable
110 ; The fire buttons are in bits 6 and 7. Both of them cannot be %1 together.
111 ; Therefore, bit 6 can be merged with bit 7.