]> git.sur5r.net Git - cc65/blob - libsrc/lynx/joy/lynx-stdjoy.s
cleanups and add more comments
[cc65] / libsrc / lynx / joy / 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 ; Library reference
30
31         .addr   $0000
32
33 ; Button state masks (8 values)
34
35 joy_mask:
36         .byte   $80                     ; JOY_UP
37         .byte   $40                     ; JOY_DOWN
38         .byte   $20                     ; JOY_LEFT
39         .byte   $10                     ; JOY_RIGHT
40         .byte   $01                     ; JOY_FIRE
41         .byte   $02                     ; JOY_FIRE1
42         .byte   $00                     ;
43         .byte   $00                     ;
44
45 ; Jump table.
46
47         .addr   INSTALL
48         .addr   UNINSTALL
49         .addr   COUNT
50         .addr   READ
51         .addr   0                       ; IRQ entry unused
52
53 ; ------------------------------------------------------------------------
54 ; Constants
55
56 JOY_COUNT       = 1             ; Number of joysticks we support
57
58
59 ; ------------------------------------------------------------------------
60 ; Data.
61
62
63 .code
64
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
68 ; memory available.
69 ; Must return an JOY_ERR_xx code in a/x.
70 ;
71
72 INSTALL:
73         lda #<JOY_ERR_OK
74         ldx #>JOY_ERR_OK
75 ;       rts                     ; Run into UNINSTALL instead
76
77 ; ------------------------------------------------------------------------
78 ; UNINSTALL routine. Is called before the driver is removed from memory.
79 ; Can do cleanup or whatever. Must not return anything.
80 ;
81
82 UNINSTALL:
83         rts
84
85
86 ; ------------------------------------------------------------------------
87 ; COUNT: Return the total number of available joysticks in a/x.
88 ;
89
90 COUNT:
91         lda     #<JOY_COUNT
92         ldx     #>JOY_COUNT
93         rts
94
95 ; ------------------------------------------------------------------------
96 ; READ: Read a particular joystick passed in A.
97
98 READ:
99         ldx     #$00            ; Clear high byte
100         lda     JOYSTICK        ; Read joystick
101         and     #$F3            ; Mask relevant keys
102         rts
103
104