-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjoystick.inc
52 lines (39 loc) · 970 Bytes
/
joystick.inc
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
;----------------------------------------------------------
; Set PORTB direction
;----------------------------------------------------------
joyinit:
lda #$ff ; Write value to latch, bits 0-7 input
sta $b401
jsr interwritedelay
lda #$a1 ; Write direction in latch to PORTB
sta $b400
wait_until_not_busy:
lda $b400
bmi wait_until_not_busy
rts
;----------------------------------------------------------
; Get PORTB value
;----------------------------------------------------------
joyget:
lda #$a2 ; Read value PORTB in latch
sta $b400
jsr interwritedelay
lda $b401
beq no_joystick
eor #$ff
and #$1f
no_joystick:
rts
;----------------------------------------------------------
; Short delay
;
; Enough to intersperse 2 writes to the FATPIC.
;----------------------------------------------------------
interwritedelay:
lda #8
sec
loop:
sbc #1
bne loop
rts
tmp_byte: .byte 0