]> git.sur5r.net Git - cc65/blob - libsrc/atari/joy/atrmj8.s
Removed IRQ support from joystick drivers.
[cc65] / libsrc / atari / joy / atrmj8.s
1 ;
2 ; MultiJoy joystick driver for the Atari. May be used multiple times when linked
3 ; to the statically application.
4 ;
5 ; Ullrich von Bassewitz, 2002-12-21
6 ; Stefan Haubenthal, 2009-04-10
7 ; Using code from Carsten Strotmann and help from Christian Groessler
8 ;
9
10         .include        "zeropage.inc"
11
12         .include        "joy-kernel.inc"
13         .include        "joy-error.inc"
14         .include        "atari.inc"
15
16         .macpack        generic
17         .macpack        module
18
19
20 ; ------------------------------------------------------------------------
21 ; Header. Includes jump table
22
23 .ifdef __ATARIXL__
24         module_header   _atrxmj8_joy
25 .else
26         module_header   _atrmj8_joy
27 .endif
28
29 ; Driver signature
30
31         .byte   $6A, $6F, $79           ; "joy"
32         .byte   JOY_API_VERSION         ; Driver API version number
33
34 ; Library reference
35
36         .addr   $0000
37
38 ; Jump table.
39
40         .addr   INSTALL
41         .addr   UNINSTALL
42         .addr   COUNT
43         .addr   READJOY
44
45 ; ------------------------------------------------------------------------
46 ; Constants
47
48 JOY_COUNT       = 8             ; Number of joysticks we support
49
50
51 ; ------------------------------------------------------------------------
52 ; Data.
53
54
55 .code
56
57 ; ------------------------------------------------------------------------
58 ; INSTALL routine. Is called after the driver is loaded into memory. If
59 ; possible, check if the hardware is present and determine the amount of
60 ; memory available.
61 ; Must return an JOY_ERR_xx code in a/x.
62 ;
63
64 INSTALL:
65         lda     #$30
66         sta     PACTL
67         lda     #$F0
68         sta     PORTA
69         lda     #$34
70         sta     PACTL
71         lda     #JOY_ERR_OK
72         ldx     #0
73 ;       rts                     ; Run into UNINSTALL instead
74
75 ; ------------------------------------------------------------------------
76 ; UNINSTALL routine. Is called before the driver is removed from memory.
77 ; Can do cleanup or whatever. Must not return anything.
78 ;
79
80 UNINSTALL:
81         rts
82
83
84 ; ------------------------------------------------------------------------
85 ; COUNT: Return the total number of available joysticks in a/x.
86 ;
87
88 COUNT:
89         lda     #JOY_COUNT
90         ldx     #0
91         rts
92
93 ; ------------------------------------------------------------------------
94 ; READ: Read a particular joystick passed in A.
95 ;
96
97 READJOY:
98         asl     a
99         asl     a
100         asl     a
101         asl     a
102         sta     PORTA
103
104 ; Read joystick
105
106         lda     STRIG0          ; get button
107         asl     a
108         asl     a
109         asl     a
110         asl     a
111         ora     PORTA           ; add position information
112         eor     #$1F
113         ldx     #0              ; fix X
114         rts