]> git.sur5r.net Git - cc65/blob - libsrc/c128/joy/c128-stdjoy.s
Removed joy_masks array.
[cc65] / libsrc / c128 / joy / c128-stdjoy.s
1 ;
2 ; Standard joystick driver for the C128. May be used multiple times when linked
3 ; to the statically application.
4
5 ;
6 ; Ullrich von Bassewitz, 2002-12-21
7 ;
8
9         .include        "zeropage.inc"
10
11         .include        "joy-kernel.inc"
12         .include        "joy-error.inc"
13         .include        "c128.inc"
14
15         .macpack        generic
16         .macpack        module
17
18
19 ; ------------------------------------------------------------------------
20 ; Header. Includes jump table
21
22         module_header   _c128_stdjoy_joy
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 ; Jump table.
34
35         .addr   INSTALL
36         .addr   UNINSTALL
37         .addr   COUNT
38         .addr   READ
39         .addr   0                       ; IRQ entry not used
40
41 ; ------------------------------------------------------------------------
42 ; Constants
43
44 JOY_COUNT       = 2             ; Number of joysticks we support
45
46
47 ; ------------------------------------------------------------------------
48 ; Data.
49
50
51 .code
52
53 ; ------------------------------------------------------------------------
54 ; INSTALL routine. Is called after the driver is loaded into memory. If
55 ; possible, check if the hardware is present and determine the amount of
56 ; memory available.
57 ; Must return an JOY_ERR_xx code in a/x.
58 ;
59
60 INSTALL:
61         lda     #<JOY_ERR_OK
62         ldx     #>JOY_ERR_OK
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 back:   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         jmp     back