]> git.sur5r.net Git - cc65/blob - libsrc/atari/joy/atrmj8.s
Renamed JUMPTABLE and cleaned up module.cfg.
[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
18
19 ; ------------------------------------------------------------------------
20 ; Header. Includes jump table
21
22 .segment        "HEADER"
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         .byte   $02                     ; JOY_UP
36         .byte   $04                     ; JOY_DOWN
37         .byte   $08                     ; JOY_LEFT
38         .byte   $10                     ; JOY_RIGHT
39         .byte   $01                     ; JOY_FIRE
40         .byte   $00                     ; JOY_FIRE2 not available
41         .byte   $00                     ; Future expansion
42         .byte   $00                     ; Future expansion
43
44 ; Jump table.
45
46         .addr   INSTALL
47         .addr   UNINSTALL
48         .addr   COUNT
49         .addr   READJOY
50         .addr   0                       ; IRQ entry not used
51
52 ; ------------------------------------------------------------------------
53 ; Constants
54
55 JOY_COUNT       = 8             ; Number of joysticks we support
56
57
58 ; ------------------------------------------------------------------------
59 ; Data.
60
61
62 .code
63
64 ; ------------------------------------------------------------------------
65 ; INSTALL routine. Is called after the driver is loaded into memory. If
66 ; possible, check if the hardware is present and determine the amount of
67 ; memory available.
68 ; Must return an JOY_ERR_xx code in a/x.
69 ;
70
71 INSTALL:
72         lda     #$30
73         sta     PACTL
74         lda     #$F0
75         sta     PORTA
76         lda     #$34
77         sta     PACTL
78         lda     #JOY_ERR_OK
79         ldx     #0
80 ;       rts                     ; Run into UNINSTALL instead
81
82 ; ------------------------------------------------------------------------
83 ; UNINSTALL routine. Is called before the driver is removed from memory.
84 ; Can do cleanup or whatever. Must not return anything.
85 ;
86
87 UNINSTALL:
88         rts
89
90
91 ; ------------------------------------------------------------------------
92 ; COUNT: Return the total number of available joysticks in a/x.
93 ;
94
95 COUNT:
96         lda     #JOY_COUNT
97         ldx     #0
98         rts
99
100 ; ------------------------------------------------------------------------
101 ; READ: Read a particular joystick passed in A.
102 ;
103
104 READJOY:
105         asl     a
106         asl     a
107         asl     a
108         asl     a
109         sta     PORTA
110
111 ; Read joystick
112
113         lda     PORTA           ; get position
114         and     #%00001111
115         asl     a
116         ora     TRIG0           ; add button information
117         eor     #%00011111
118         ldx     #0              ; fix X
119         rts