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