-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.inc
298 lines (272 loc) · 8.73 KB
/
options.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
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
.data
MY_LABEL_BLANKS byte " ",0
MY_LABEL_DIFF byte "请选择游戏难度:",0
MY_LABEL_KEY byte "(上下键选择,回车确认)",0
MY_LABEL_EASY byte "简单模式",0
MY_LABEL_NORM byte "普通模式",0
MY_LABEL_MID byte "中等模式",0
MY_LABEL_HARD byte "困难模式",0
MY_MENU_BOARD1 byte "╔══════════════════════════════════════╗",0
MY_MENU_BOARD2 byte "║ ║",0
MY_MENU_BOARD3 byte "╠══════════════════════════════════════╣",0
MY_MENU_BOARD4 byte "╚══════════════════════════════════════╝",0
MY_MENU_TITLE byte "游戏结束",0
MY_MENU_MSG1 byte "很遗憾,你挂了!",0
MY_MENU_MSG2 byte "方向盘还是不够熟练诶TAT",0
MY_MENU_MSG3 byte "本局得分:",0
MY_MENU_MSG4 byte "本局评价:",0
MY_MENU_MSG5 byte "这位蛇勇士,是否重新开始?",0
MY_MENU_YES byte "好鸭,再战一次",0
MY_MENU_NO byte "不辽,还是学习有意思",0
.code
ShowSelection proc
invoke SetFontColor,3 ; 覆盖原先画面
invoke SetCursorPosition,13,26
invoke crt_printf,addr MY_LABEL_BLANKS
invoke SetCursorPosition,13,27
invoke crt_printf,addr MY_LABEL_BLANKS
invoke SetCursorPosition,6,21
invoke crt_printf,addr MY_LABEL_DIFF
invoke SetCursorPosition,6,22
invoke crt_printf,addr MY_LABEL_KEY
invoke SetCursorPosition,27,22
mov MY_DIFFICULTY,1
invoke SetBackColor ; 第一个选项默认选中
invoke crt_printf,addr MY_LABEL_EASY
invoke SetCursorPosition,27,24
invoke SetFontColor,3
invoke crt_printf,addr MY_LABEL_NORM
invoke SetCursorPosition,27,26
invoke crt_printf,addr MY_LABEL_MID
invoke SetCursorPosition,27,28
invoke crt_printf,addr MY_LABEL_HARD
invoke SetCursorPosition,0,31
chooseLabel:
call ReadChar ; 从缓冲区读入字符
mov MY_CHAR,ah
cmp MY_CHAR,72
je chooseUp
cmp MY_CHAR,80
je chooseDown
cmp MY_CHAR,28
je chooseEnter
jmp chooseBack
chooseUp: ; 上方向键
cmp MY_DIFFICULTY,1
jle chooseBack
cmp MY_DIFFICULTY,2
je chooseUp_2
cmp MY_DIFFICULTY,3
je chooseUp_3
cmp MY_DIFFICULTY,4
je chooseUp_4
jmp chooseBack
chooseUp_2:
invoke SetCursorPosition,27,22 ; 给待选中项设置背景色
invoke SetBackColor
invoke crt_printf,addr MY_LABEL_EASY
invoke SetCursorPosition,27,24 ; 将已选中项取消背景色
invoke SetFontColor,3
invoke crt_printf,addr MY_LABEL_NORM
mov ax,MY_DIFFICULTY
dec ax
mov MY_DIFFICULTY,ax
jmp chooseBack
chooseUp_3:
invoke SetCursorPosition,27,24
invoke SetBackColor
invoke crt_printf,addr MY_LABEL_NORM
invoke SetCursorPosition,27,26
invoke SetFontColor,3
invoke crt_printf,addr MY_LABEL_MID
mov ax,MY_DIFFICULTY
dec ax
mov MY_DIFFICULTY,ax
jmp chooseBack
chooseUp_4:
invoke SetCursorPosition,27,26
invoke SetBackColor
invoke crt_printf,addr MY_LABEL_MID
invoke SetCursorPosition,27,28
invoke SetFontColor,3
invoke crt_printf,addr MY_LABEL_HARD
mov ax,MY_DIFFICULTY
dec ax
mov MY_DIFFICULTY,ax
jmp chooseBack
chooseDown: ; 下方向键
cmp MY_DIFFICULTY,4
jge chooseBack
cmp MY_DIFFICULTY,1
je chooseDown_1
cmp MY_DIFFICULTY,2
je chooseDown_2
cmp MY_DIFFICULTY,3
je chooseDown_3
jmp chooseBack
chooseDown_1:
invoke SetCursorPosition,27,24
invoke SetBackColor
invoke crt_printf,addr MY_LABEL_NORM
invoke SetCursorPosition,27,22
invoke SetFontColor,3
invoke crt_printf,addr MY_LABEL_EASY
mov ax,MY_DIFFICULTY
inc ax
mov MY_DIFFICULTY,ax
jmp chooseBack
chooseDown_2:
invoke SetCursorPosition,27,26
invoke SetBackColor
invoke crt_printf,addr MY_LABEL_MID
invoke SetCursorPosition,27,24
invoke SetFontColor,3
invoke crt_printf,addr MY_LABEL_NORM
mov ax,MY_DIFFICULTY
inc ax
mov MY_DIFFICULTY,ax
jmp chooseBack
chooseDown_3:
invoke SetCursorPosition,27,28
invoke SetBackColor
invoke crt_printf,addr MY_LABEL_HARD
invoke SetCursorPosition,27,26
invoke SetFontColor,3
invoke crt_printf,addr MY_LABEL_MID
mov ax,MY_DIFFICULTY
inc ax
mov MY_DIFFICULTY,ax
jmp chooseBack
chooseBack:
invoke SetCursorPosition,0,31
jmp chooseLABEL
chooseEnter: ; 回车键
invoke SetCursorPosition,0,31
mov ax,MY_DIFFICULTY ; 根据难度选择速度,值越大速度越慢,值越小速度越快
cmp ax,1
mov MY_SPEED,120
je outLABEL
cmp ax,2
mov MY_SPEED,90
je outLABEL
cmp ax,3
mov MY_SPEED,60
je outLABEL
mov MY_SPEED,30
outLABEL:
ret
ShowSelection endp
ShowDeathMenu proc ; 游戏结束,绘制界面
local key:word
mov eax,100
call Delay
invoke SetFontColor,11
invoke SetCursorPosition,10,8
invoke crt_printf,addr MY_MENU_BOARD1
invoke SetCursorPosition,10,9
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,10
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,11
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,12
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,13
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,14
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,15
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,16
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,17
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,18
invoke crt_printf,addr MY_MENU_BOARD3
invoke SetCursorPosition,10,19
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,20
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,21
invoke crt_printf,addr MY_MENU_BOARD2
invoke SetCursorPosition,10,22
invoke crt_printf,addr MY_MENU_BOARD4
invoke SetFontColor,14
invoke SetCursorPosition,18,9
invoke crt_printf,addr MY_MENU_TITLE
invoke SetFontColor,MY_MENU_COL
invoke SetCursorPosition,16,11
invoke crt_printf,addr MY_MENU_MSG1
invoke SetCursorPosition,14,13
invoke crt_printf,addr MY_MENU_MSG2
invoke SetCursorPosition,21,15
movzx eax,MY_SCORE
call WriteDec
invoke PrintFood,21,17
.if MY_SCORE>=5
invoke PrintFood,22,17
.if MY_SCORE>=15
invoke PrintFood,23,17
.if MY_SCORE>=30
invoke PrintFood,24,17
.if MY_SCORE>=50
invoke PrintFood,25,17
.endif
.endif
.endif
.endif
invoke SetFontColor,6
invoke SetCursorPosition,16,15
invoke crt_printf,addr MY_MENU_MSG3
invoke SetCursorPosition,16,17
invoke crt_printf,addr MY_MENU_MSG4
invoke SetFontColor,14
invoke SetCursorPosition,11,19
invoke crt_printf,addr MY_MENU_MSG5
mov key,1
invoke SetBackColor
invoke SetCursorPosition,11,21
invoke crt_printf,addr MY_MENU_YES
invoke SetFontColor,MY_MENU_COL
invoke _SetCursorPosition,39,21
invoke crt_printf,addr MY_MENU_NO
chooseLoop:
invoke SetCursorPosition,0,31
call ReadChar
mov MY_CHAR,ah
.if MY_CHAR==75 ; left
.if key==2
invoke SetBackColor
invoke SetCursorPosition,11,21
invoke crt_printf,addr MY_MENU_YES
invoke SetFontColor,MY_MENU_COL
invoke _SetCursorPosition,39,21
invoke crt_printf,addr MY_MENU_NO
mov ax,key
dec ax
mov key,ax
.endif
.elseif MY_CHAR==77 ; right
.if key==1
invoke SetFontColor,MY_MENU_COL
invoke SetCursorPosition,11,21
invoke crt_printf,addr MY_MENU_YES
invoke SetBackColor
invoke _SetCursorPosition,39,21
invoke crt_printf,addr MY_MENU_NO
mov ax,key
inc ax
mov key,ax
.endif
.elseif MY_CHAR==28 ; enter
jmp chooseOut
.endif
jmp chooseLoop
chooseOut:
.if key==1
mov eax,1
.elseif key==2
mov eax,0
.endif
ret
ShowDeathMenu endp