]> git.sur5r.net Git - cc65/blob - libsrc/lynx/lynx-stdjoy.s
ad7be484045c2f0f682545fc6f8946ca6255493c
[cc65] / libsrc / lynx / lynx-stdjoy.s
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
18
19 ; ------------------------------------------------------------------------
20 ; Header. Includes jump table
21
22 .segment        "JUMPTABLE"
23
24 ; Driver signature
25
26         .byte   $6A, $6F, $79           ; "joy"
27         .byte   JOY_API_VERSION         ; Driver API version number
28
29 ; Button state masks (8 values)
30
31         .byte   $80                     ; JOY_UP
32         .byte   $40                     ; JOY_DOWN
33         .byte   $20                     ; JOY_LEFT
34         .byte   $10                     ; JOY_RIGHT
35         .byte   $01                     ; JOY_FIRE
36         .byte   $02                     ; JOY_FIRE1
37         .byte   $00                     ;
38         .byte   $00                     ;
39
40 ; Jump table.
41
42         .word   INSTALL
43         .word   UNINSTALL
44         .word   COUNT
45         .word   READ
46
47 ; ------------------------------------------------------------------------
48 ; Constants
49
50 JOY_COUNT       = 1             ; Number of joysticks we support
51
52
53 ; ------------------------------------------------------------------------
54 ; Data.
55
56
57 .code
58
59 ; ------------------------------------------------------------------------
60 ; INSTALL routine. Is called after the driver is loaded into memory. If
61 ; possible, check if the hardware is present and determine the amount of
62 ; memory available.
63 ; Must return an JOY_ERR_xx code in a/x.
64 ;
65
66 INSTALL:
67         lda     #<JOY_ERR_OK
68         ldx     #>JOY_ERR_OK
69 ;       rts                     ; Run into UNINSTALL instead
70
71 ; ------------------------------------------------------------------------
72 ; UNINSTALL routine. Is called before the driver is removed from memory.
73 ; Can do cleanup or whatever. Must not return anything.
74 ;
75
76 UNINSTALL:
77         rts
78
79
80 ; ------------------------------------------------------------------------
81 ; COUNT: Return the total number of available joysticks in a/x.
82 ;
83
84 COUNT:
85         lda     #<JOY_COUNT
86         ldx     #>JOY_COUNT
87         rts
88
89 ; ------------------------------------------------------------------------
90 ; READ: Read a particular joystick passed in A.
91
92 READ:
93         ldx     #$00            ; Clear high byte
94         lda     JOYSTICK        ; Read joystick
95         rts
96
97