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