-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjoystick.asm
58 lines (48 loc) · 882 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
*=* "Joystick Routine"
//
// Read both joysticks and store the results
//
ReadJoysticks:
ldx #$00
jsr ReadJoystick
inx
jsr ReadJoystick
rts
//
// Read the joystick position and button status and store the state
//
ReadJoystick:
lda #DISABLE
sta c64lib_joy_btn, x
sta c64lib_joy_left, x
sta c64lib_joy_right, x
sta c64lib_joy_up, x
sta c64lib_joy_down, x
lda cia.CIAPRA, x
and #JOY_BUTTON
beq !set_button+
and #JOY_LEFT
beq !set_left+
and #JOY_RIGHT
beq !set_right+
and #JOY_UP
beq !set_up+
and #JOY_DOWN
beq !set_down+
jmp !return+
!set_button:
stb #ENABLE:c64lib_joy_btn, x
jmp !return+
!set_left:
stb #ENABLE:c64lib_joy_left, x
jmp !return+
!set_right:
stb #ENABLE:c64lib_joy_right, x
jmp !return+
!set_up:
stb #ENABLE:c64lib_joy_up, x
jmp !return+
!set_down:
stb #ENABLE:c64lib_joy_down, x
!return:
rts