2 ; Standard joystick driver for the Atari 5200.
4 ; Christian Groessler, 2014-05-28
7 .include "zeropage.inc"
9 .include "joy-kernel.inc"
10 .include "joy-error.inc"
11 .include "atari5200.inc"
16 ; ------------------------------------------------------------------------
17 ; Header. Includes jump table
19 module_header _atr5200std_joy
23 .byte $6A, $6F, $79 ; "joy"
24 .byte JOY_API_VERSION ; Driver API version number
30 ; Button state masks (8 values)
38 .byte $00 ; Future expansion
39 .byte $00 ; Future expansion
47 .addr 0 ; IRQ entry not used
51 ; ------------------------------------------------------------------------
52 ; INSTALL routine. Is called after the driver is loaded into memory. If
53 ; possible, check if the hardware is present and determine the amount of
55 ; Must return an JOY_ERR_xx code in a/x.
61 ; rts ; Run into UNINSTALL instead
63 ; ------------------------------------------------------------------------
64 ; UNINSTALL routine. Is called before the driver is removed from memory.
65 ; Can do cleanup or whatever. Must not return anything.
72 ; ------------------------------------------------------------------------
73 ; COUNT: Return the total number of available joysticks in a/x.
77 lda $FD32 ; check ROM version
81 .byte $2C ; bit opcode, eats the next 2 bytes
86 ; ------------------------------------------------------------------------
87 ; READ: Read a particular joystick passed in A.
94 and #3 ; put joystick number in range, just in case
97 tax ; Joystick number * 2 (0-6) into X, index into ZP shadow registers
99 lda #0 ; Initialize return value
106 @notrg: ldy PADDL0,x ; get horizontal position
107 cpy #CENTER-SENSIVITY
114 cpy #CENTER+SENSIVITY
119 @updown:ldy PADDL0+1,x ; get vertical position
120 cpy #CENTER-SENSIVITY
127 cpy #CENTER+SENSIVITY