1;
2; Standard joystick driver for the Atari Lynx.
3; The Lynx has two fire buttons. So it is not quite "standard".
4;
5; Modified by Karri Kaksonen, 2004-09-16
6; Ullrich von Bassewitz, 2002-12-20
7; Using code from Steve Schmidtke
8;
9
10        .include        "zeropage.inc"
11
12        .include        "joy-kernel.inc"
13        .include        "joy-error.inc"
14        .include        "lynx.inc"
15
16        .macpack        generic
17        .macpack        module
18
19
20; ------------------------------------------------------------------------
21; Header. Includes jump table
22
23        module_header   _lynx_stdjoy_joy
24
25; Driver signature
26
27        .byte   $6A, $6F, $79           ; "joy"
28        .byte   JOY_API_VERSION         ; Driver API version number
29
30; Library reference
31
32        .addr   $0000
33
34; Jump table.
35
36        .addr   INSTALL
37        .addr   UNINSTALL
38        .addr   COUNT
39        .addr   READ
40
41; ------------------------------------------------------------------------
42; Constants
43
44JOY_COUNT       = 1             ; Number of joysticks we support
45
46
47; ------------------------------------------------------------------------
48; Data.
49
50
51.code
52
53; ------------------------------------------------------------------------
54; INSTALL routine. Is called after the driver is loaded into memory. If
55; possible, check if the hardware is present and determine the amount of
56; memory available.
57; Must return an JOY_ERR_xx code in a/x.
58;
59
60INSTALL:
61        lda #<JOY_ERR_OK
62        ldx #>JOY_ERR_OK
63;       rts                     ; Run into UNINSTALL instead
64
65; ------------------------------------------------------------------------
66; UNINSTALL routine. Is called before the driver is removed from memory.
67; Can do cleanup or whatever. Must not return anything.
68;
69
70UNINSTALL:
71        rts
72
73
74; ------------------------------------------------------------------------
75; COUNT: Return the total number of available joysticks in a/x.
76;
77
78COUNT:
79        lda     #<JOY_COUNT
80        ldx     #>JOY_COUNT
81        rts
82
83; ------------------------------------------------------------------------
84; READ: Read a particular joystick passed in A.
85
86READ:
87        ldx     #$00            ; Clear high byte
88        lda     JOYSTICK        ; Read joystick
89        and     #$F3            ; Mask relevant keys
90        rts
91
92
93