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
39 ; ------------------------------------------------------------------------
40 ; INSTALL routine. Is called after the driver is loaded into memory. If
41 ; possible, check if the hardware is present and determine the amount of
43 ; Must return an JOY_ERR_xx code in a/x.
47 lda #$04 ; enable POT input from the joystick ports, see section "GTIA" in
48 sta CONSOL ; http://www.atarimuseum.com/videogames/consoles/5200/conv_to_5200.html
51 ; rts ; Run into UNINSTALL instead
53 ; ------------------------------------------------------------------------
54 ; UNINSTALL routine. Is called before the driver is removed from memory.
55 ; Can do cleanup or whatever. Must not return anything.
62 ; ------------------------------------------------------------------------
63 ; COUNT: Return the total number of available joysticks in a/x.
67 lda $FD32 ; check ROM version
71 .byte $2C ; bit opcode, eats the next 2 bytes
76 ; ------------------------------------------------------------------------
77 ; READ: Read a particular joystick passed in A.
84 and #3 ; put joystick number in range, just in case
85 sta jsnum ; remember joystick number
88 tax ; Joystick number * 2 (0-6) into X, index into ZP shadow registers
90 lda #0 ; Initialize return value
97 @notrg: ldy PADDL0,x ; get horizontal position
105 cpy #CENTER+SENSIVITY
110 @updown:ldy PADDL0+1,x ; get vertical position
111 cpy #CENTER-SENSIVITY
118 cpy #CENTER+SENSIVITY