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