-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJoystick.asm
76 lines (67 loc) · 845 Bytes
/
Joystick.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// inspired by this post
// https://codebase64.org/doku.php?id=base:joystick_input_handling
Joystick:
{
.segment ZP
pressedBit: .byte 0
.segment CODE
.label UP = 0
.label DOWN = 1
.label LEFT = 2
.label RIGHT = 3
.label FIRE = 4
Reset:
{
ldx #$00
lda #$ff
!:
sta data,x
inx
cpx #8
bne !-
rts
}
//
Poll:
{
// lda #$00
// sta cia1_ddra
// PORT 2
lda cia1_pra
lsr
ror data+UP
lsr
ror data+DOWN
lsr
ror data+LEFT
lsr
ror data+RIGHT
lsr
ror data+FIRE
rts
}
// where X = button type
Pressed:
{
lda data,x
sta pressedBit
lda #%11111111
bit pressedBit
bmi noaction
bvc noaction
lda #$00
rts
noaction:
lda #$01
rts
}
// where X = button type
// if touched currently
Held:
{
lda data,x
and #1
rts
}
data: .fill 8,0
}