-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinput_handling.asm
155 lines (113 loc) · 2.39 KB
/
input_handling.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
handle_input:
.var pra = $dc00 //CIA#1 Port Register A
.var prb = $dc01 //CIA#1 Port Register B
.var ddra = $dc02 // CIA#1 (Data Direction Register A)
.var ddrb = $dc03 // CIA#1 (Data Direction Register B)
lda #$FF
sta ddra // set data register a to output
lda #$00
sta ddrb // set data register b to input
jsr check_up
jsr check_down
rts
check_s_o:
lda #%11101101
sta pra // select second and fifth keyboard rows
lda prb //check 's' and 'o'
and #%01100000
beq move_s_o
check_w_l:
lda #%11011101
sta pra // select third keyboard row
lda prb // load column info
and #%00000110 //check if 'w' and 'l' is pressed
beq move_w_l
check_down:
lda #%11011101
sta pra // select third keyboard row
lda prb // load column info
and #%00100100 //check if 's' and 'l' is pressed
beq move_down_2
lda prb // load column info
and #%00000100 //check if 's' is pressed
beq move_down
lda prb // load column info
and #%00100000 //check if 'l' is pressed
beq move_down_l
rts
//check up
check_up:
lda #%11101101
sta pra // select second and fifth keyboard rows
lda prb // load column info
and #%01000010 // check if 'w' and 'o' was pressed
beq move_up_2
lda prb // load column info
and #%00000010 // check if 'w' was pressed
beq move_up_l
lda prb // load column info
and #%01000000 // check if 'o' was pressed
beq move_up
rts
//check down
//lda #%11011101
//sta pra // select third keyboard row
//lda prb // load column info
//and #%01100000 //check if 's' and 'o' is pressed
//beq move_up_2
move_w_l:
jsr move_up_l
jsr move_down
rts
move_up:
lda $d001
cmp #$33
bcs move_up_dec // if position >= $33, then branch
rts
move_s_o:
jsr move_up_dec
jsr move_down_dec_l
rts
move_up_2:
jsr move_up
jsr move_up_l
rts
move_up_l:
lda $d003
cmp #$33
bcs move_up_dec_l // if position >= $33, then branch
rts
move_up_dec:
dec $d001 //decrease sprite 1 y-coord
dec $d001
dec $d001
rts
move_up_dec_l:
dec $d003 //decrease sprite 1 y-coord
dec $d003
dec $d003
rts
move_down:
lda #$cf
cmp $d001
bcs move_down_dec // if position <= $cf, branch
rts
move_down_l:
lda #$cf
cmp $d003
bcs move_down_dec_l // if position <= $cf, branch
rts
move_down_dec:
inc $d001 //decrease sprite 1 y-coord
inc $d001
inc $d001
rts
move_down_2:
jsr move_down
jsr move_down_l
rts
move_down_dec_l:
inc $d003 //decrease sprite 1 y-coord
inc $d003
inc $d003
rts