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