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