]> git.sur5r.net Git - cc65/blob - libsrc/geos/mousesprite/readjoy.s
fixed bug on C64 GEOS (I/O was not enabled when reading joystick)
[cc65] / libsrc / geos / mousesprite / readjoy.s
1 ;
2 ; Ullrich von Bassewitz, 23.09.1998
3 ;
4 ; unsigned readjoy (unsigned char joy);
5 ;
6
7         .export         _readjoy
8
9         .include        "../inc/geossym.inc"
10
11 .proc   _readjoy
12
13         php
14         sei                     ; disable IRQ
15         lda     $01
16         pha
17         lda     #$35
18         sta     $01             ; enable I/O
19
20         tax                     ; Joystick number into X
21         bne     joy2
22
23 ; Read joystick 1
24
25 joy1:   
26         lda     #$7F
27         sta     cia1base
28         lda     cia1base+1
29 back:   tax
30         pla
31         sta     $01
32         plp
33         txa
34         and     #$1F
35         eor     #$1F
36         ldx     #0
37         rts
38
39 ; Read joystick 2
40
41 joy2:   lda     #$E0
42         ldy     #$FF
43         sta     cia1base+2
44         lda     cia1base+1
45         sty     cia1base+2
46         jmp     back
47
48 .endproc