-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_joystick.asm
78 lines (69 loc) · 1.56 KB
/
_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
76
77
78
////////////////////////////////////////////////////////////////////////////////
//
// Project : ForestSaver - https://github.com/intoinside/ForestSaver
// Target : Commodore 64
// Author : Raffaele Intorcia - [email protected]
//
// Routine for joystick managing
//
////////////////////////////////////////////////////////////////////////////////
#importonce
FirePressed: .byte $00
Direction: // Player sprite direction
.byte $01 // $00 - no move, $01 - right, $ff - left
DirectionY: // Player sprite vertical direction
.byte $ff // $00 - no move, $01 - down, $ff - up
Orientation: // Player sprite orientation
.byte $01 // $01 - right, $ff - left
GetJoystickMove: {
ldx #$00
lda $dc00
ldy GameEnded
bne CheckOnlyFirePress
lsr
bcs !NoUp+
ldx #$ff
!NoUp:
lsr
bcs !NoDown+
ldx #$01
!NoDown:
stx DirectionY
ldx #$00
lsr
bcs !NoLeft+
ldx #$ff
stx Orientation
!NoLeft:
lsr
bcs !NoRight+
ldx #$01
stx Orientation
!NoRight:
stx Direction
ldx #$00
lsr
bcs !NoFirePressed+
ldx #$ff
!NoFirePressed:
stx FirePressed
rts
CheckOnlyFirePress:
jmp GetOnlyFirePress
}
// Read joystick (port 2) status and set FirePressed to $ff if fire is pressed
// $00 otherwise
GetOnlyFirePress: {
lda $dc00
ldx #0
lsr
lsr
lsr
lsr
lsr
bcs !NoFirePressed+
ldx #$ff
!NoFirePressed:
stx FirePressed
rts
}