]> git.sur5r.net Git - cc65/blob - libsrc/creativision/joy.s
Cleanups for Creativision.
[cc65] / libsrc / creativision / joy.s
1 ;*
2 ;* Creativision Joystick Function
3 ;*
4 ;* unsigned char __fastcall__ joystate(unsigned char joy);
5 ;*
6 ;* JOY_1 -> Return Left Joystick direction
7 ;* JOY_2 -> Return Right Joystick direction
8 ;* JOY_3 -> Return Left Joystick buttons
9 ;* JOY_4 -> Return Right Joystick buttons
10 ;*
11 ;* Will only work if interrupts are enabled.
12
13         .export         _joystate
14         .include        "creativision.inc"
15
16 _joystate:
17         cmp             #1      ; Left Direction
18         bne             l1
19
20         lda             $11
21         beq             l5
22         and             #$0F
23         lsr             a
24         tax
25         inx
26         txa
27         rts
28
29 l1:     cmp             #2      ; Right Direction
30         bne             l2
31
32         lda             $13
33         beq             l5
34         and             #$0F
35         lsr             a
36         tax
37         inx
38         txa
39         rts
40
41 l2:     cmp             #3      ; Left Buttons
42         bne             l3
43
44         lda             $16
45         beq             l5
46         and             #$0F
47         rts
48
49 l3:     cmp             #4
50         bne             l4
51
52         lda             $17
53         beq             l5
54         and             #$0F
55         rts
56
57 l4:     lda             #0
58 l5:     rts