-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVGAwith9block.txt
193 lines (171 loc) · 3.48 KB
/
VGAwith9block.txt
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
timer_isr:
//RAM allocation,no need to initialise the RAM
//00-store the information whether this is the first time to fresh the frame buffer
//01-current pixel address x
//02-current pixel address y
//03-which part call the judge function
//04-color
//05-IR command
//06-Mouse status
//07-Mouse right click state
//08,09,0A,0B-four colours
//0C-mouse select counter
BEGIN:
load a 00 //check whether it’s the first time
load_val b 01
BREQ MOUSE_CLEAR //if not the first time, do the counter
//LOOP to RETURN is the region judge, no matter the region construction
//or to judge the color of the mouse position should use this function or loop
LOOP:
load a 01
store B0 a
load a 02 //y’s range
store B1 a
load_val b 28
BLTQ REGION1
load_val b 50
BLTQ REGION2
GOTO REGION3
REGION1: // x’s range
load a 01
load_val b 36
BLTQ BLOCK1
load_val b 6C
BLTQ BLOCK2
GOTO BLOCK3
REGION2:
load a 01
load_val b 36
BLTQ BLOCK4
load_val b 6C
BLTQ BLOCK5
GOTO BLOCK6
REGION3:
load a 01
load_val b 36
BLTQ BLOCK7
load_val b 6C
BLTQ BLOCK8
GOTO BLOCK9
BLOCK1:
load_val a 01 //command of the car
GOTO RETURN0
BLOCK2:
load_val a 02 //command of the car
GOTO RETURN1
BLOCK3:
load_val a 03 //command of the car
GOTO RETURN0
BLOCK4:
load_val a 04 //command of the car
GOTO RETURN1
BLOCK5:
load_val a 05 //command of the car
GOTO RETURN0
BLOCK6:
load_val a 06 //command of the car
GOTO RETURN1
BLOCK7:
load_val a 07 //command of the car
GOTO RETURN0
BLOCK8:
load_val a 08 //command of the car
GOTO RETURN1
BLOCK9:
load_val a 09 //command of the car
GOTO RETURN0
RETURN0:
store 05 a //store what came from the car
load_val a 00
load b 03 //0F to store who call this function
add a b
store B2 a
load_val a 00
BREQ CREATNEXT
load_val a 01
BREQ CARCONTROL
GOTO MOUSE_SET
RETURN1:
store 05 a //store what came from the car
load_val a 01
load b 03
add a b
store B2 a
load_val a 00
BREQ CREATNEXT
load_val a 01
BREQ CARCONTROL
GOTO MOUSE_SET
//CREATNEXT is with 2 counters that counts from 0 to 160 and 0 to 120 respectively
CREATNEXT:
load a 01
load_val b 9F
BREQ ADDY
incr a a
store 01 a
GOTO LOOP
ADDY:
load a 02
load_val b 77
BREQ FINISH
incr a a
store 02 a
load_val a 00
store 01 a
GOTO LOOP
FINISH:
load_val a 01
store 00 a
MOUSE_ISR:
MOUSE_CLEAR:
//first to clear the last position of mouse
load_val a 02 //02 means in check region,it should clear the former position
store 03 a
GOTO LOOP
MOUSE_SET: //then set the current mouse address to foreground
load a A0 //mouse click information
store 06 a
load_val b 02
and a b
load b 07
store 07 a
BLTQ NOCLICK
BREQ NOCLICK //if clicked, generate a new color
load_val a 00 //00 car
GOTO NOCLICK
//car counter in here
load a 0C
load_val b 04
BREQ SELECT_ZERO_CAR
incr a a
GOTO NOCLICK
SELECT_ZERO_CAR: //also clears colour
load_val a 00
store 0C a //select car in here directly
load_val b 08
add a b
deref a
store B3 a
NOCLICK:
//just show the position
load a A1 //mouse X address
store 01 a
load a A2 //mouse Y address
store 02 a
load_val a 01 //01 means in loop, it should set the specific position
store 03 a
GOTO LOOP
CARCONTROL:
load a 06 //before everything starts, check if mouse is left clicked
load_val b 01
and a b
BREQ SKIP_LEFT_CLICK_RESET
load_val a 05 //reset IR command
store 05 a
SKIP_LEFT_CLICK_RESET:
load a 05 //05 to store the command of car
store C0 a //send to IR
store 90 a
load a 0C
store 91 a
GOTO_IDLE