Rev 1522 | Rev 1677 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1518 | dunkaist | 1 | ;;===First_menu_mode=========================================================================================================== |
2 | |||
3 | First_menu: |
||
1566 | dunkaist | 4 | mcall 40,111b ; set events: standart |
5 | mov [is_new_record], 0 |
||
6 | call Show_cursor |
||
1518 | dunkaist | 7 | |
1566 | dunkaist | 8 | mov [score], 0 |
9 | call Set_first_level_of_play_mode |
||
1518 | dunkaist | 10 | |
1522 | dunkaist | 11 | .redraw: |
1518 | dunkaist | 12 | mcall 12,1 |
1522 | dunkaist | 13 | mov ebx, [wp_x] |
14 | shl ebx, 16 |
||
15 | add ebx, dword[window_width] |
||
16 | mov ecx, [wp_y] |
||
17 | shl ecx, 16 |
||
18 | add ecx, dword[window_height] |
||
19 | mcall 0, , ,[window_style], ,window_title |
||
1518 | dunkaist | 20 | |
1566 | dunkaist | 21 | call Draw_decorations |
22 | call Draw_first_menu_picture |
||
23 | call Draw_menu_strings |
||
24 | call Draw_buttons |
||
1518 | dunkaist | 25 | |
26 | mcall 12,2 |
||
27 | |||
1522 | dunkaist | 28 | .still: |
1518 | dunkaist | 29 | mcall 10 ; wait for event |
30 | ; ok, what an event? |
||
31 | dec al ; has the window been moved or resized? |
||
1522 | dunkaist | 32 | jz .redraw ; |
1518 | dunkaist | 33 | dec al ; was a key pressed? |
1522 | dunkaist | 34 | jz .key ; |
1518 | dunkaist | 35 | |
36 | |||
1522 | dunkaist | 37 | .button: ; a button was pressed |
1518 | dunkaist | 38 | mcall 17 ; get button number |
39 | shr eax, 8 ; we should do it to get the real button code |
||
40 | |||
41 | cmp eax, 1 ; is it close button? |
||
1566 | dunkaist | 42 | je Save_do_smth_else_and_exit ; if so, jump to quit... |
43 | cmp eax, 0xD0 ; 'play' button? |
||
44 | je Level_begin |
||
45 | cmp eax, 0xD1 ; 'exit' button? |
||
46 | je Save_do_smth_else_and_exit |
||
47 | cmp eax, 0xD2 ; change play mode button? |
||
48 | jne @f |
||
49 | call Change_play_mode |
||
50 | call Delete_buttons |
||
51 | call Draw_buttons |
||
52 | jmp .still ; jump to wait for another event |
||
53 | @@: |
||
54 | cmp eax, 0xD3 ; '+INC+' button? |
||
55 | jne @f |
||
56 | call Increase_geometry |
||
57 | jmp .redraw ; jump to wait for another event |
||
58 | @@: |
||
59 | cmp eax, 0xD4 ; '-dec-' button? |
||
60 | jne @f |
||
61 | call Decrease_geometry |
||
62 | jmp .redraw ; jump to wait for another event |
||
63 | @@: |
||
1518 | dunkaist | 64 | |
1522 | dunkaist | 65 | jmp .still ; jump to wait for another event |
1518 | dunkaist | 66 | |
67 | |||
1522 | dunkaist | 68 | .key: ; a key was pressed |
1518 | dunkaist | 69 | mcall 2 ; get keycode |
70 | |||
71 | cmp ah, 0x1B ; Escape |
||
1566 | dunkaist | 72 | je Save_do_smth_else_and_exit |
1518 | dunkaist | 73 | cmp ah, 0x0D ; Enter |
74 | je Level_begin |
||
75 | cmp ah, 0x20 ; Space |
||
1566 | dunkaist | 76 | jne @f |
77 | call Change_play_mode |
||
78 | call Delete_buttons |
||
79 | call Draw_buttons |
||
1522 | dunkaist | 80 | jmp .still ; jump to wait for another event |
1566 | dunkaist | 81 | @@: |
82 | jmp .still ; jump to wait for another event |
||
1518 | dunkaist | 83 | |
84 | ;;---First_menu_mode----------------------------------------------------------------------------------------------------------- |
||
85 | |||
86 | |||
87 | ;;===Some_functions============================================================================================================ |
||
88 | |||
89 | Draw_first_menu_picture: |
||
90 | ;;===Draw_first_menu_picture================================================================================================ |
||
91 | |||
1566 | dunkaist | 92 | mov ax, 2*0x100+24 |
93 | mov cx, 1*0x100+5 |
||
1518 | dunkaist | 94 | mov edx, [snake_picture_color] |
1522 | dunkaist | 95 | mov esi, picture_first_menu_snake |
1518 | dunkaist | 96 | call Draw_picture |
97 | |||
1566 | dunkaist | 98 | mov ax, 3*0x100+11 |
99 | mov cx, 8*0x100+5 |
||
1518 | dunkaist | 100 | mov edx, [version_picture_color] |
1522 | dunkaist | 101 | mov esi, picture_first_menu_version |
1518 | dunkaist | 102 | call Draw_picture |
103 | |||
104 | ret |
||
105 | |||
106 | ;;---Draw_first_menu_picture------------------------------------------------------------------------------------------------ |
||
107 | |||
108 | |||
109 | Draw_menu_strings: |
||
1566 | dunkaist | 110 | ;;===Make_menu_strings====================================================================================================== |
1518 | dunkaist | 111 | |
1522 | dunkaist | 112 | mov ebx, [window_width] |
113 | shr ebx, 1 |
||
1566 | dunkaist | 114 | sub ebx, press_to_start.size*3+6 |
1522 | dunkaist | 115 | shl ebx, 16 |
116 | add ebx, dword[bottom_middle_strings] |
||
117 | mcall 4, ,[navigation_strings_color],press_to_start |
||
118 | mov ebx, [window_width] |
||
119 | shr ebx, 1 |
||
1566 | dunkaist | 120 | sub ebx, press_esc_to_exit.size*3+6 |
1522 | dunkaist | 121 | shl ebx, 16 |
122 | add ebx, [top_strings] |
||
123 | mcall , ,[navigation_strings_color],press_esc_to_exit |
||
1518 | dunkaist | 124 | ; mcall ,406*65536+TOP_STRINGS,[navigation_strings_color],press_F2_to_options |
125 | |||
126 | ret |
||
127 | |||
1566 | dunkaist | 128 | ;;---Make_menu_strings------------------------------------------------------------------------------------------------------ |
129 | |||
130 | |||
131 | Draw_buttons: |
||
132 | ;;===Draw_buttons=========================================================================================================== |
||
133 | |||
134 | mov ebx, [button_x_left] |
||
135 | shl ebx, 16 |
||
136 | mov bx, word[button_width_short] |
||
137 | mov ecx, [button_y_top] |
||
138 | shl ecx, 16 |
||
139 | add cx, word[button_height] |
||
140 | mcall 8, , ,0x000000D0,[button_color] ; top left button |
||
141 | shr ecx, 16 |
||
142 | mov bx, cx |
||
143 | mov edx, [button_height] |
||
144 | shr edx, 1 |
||
145 | sub edx, 3 ; ~half of font height |
||
146 | add bx, dx |
||
147 | ror ebx, 16 |
||
148 | mov edx, [button_width_short] |
||
149 | shr edx, 1 |
||
150 | sub edx, string_button_play.size*3 |
||
151 | add bx, dx |
||
152 | ror ebx, 16 |
||
153 | mcall 4, ,[button_text_color],string_button_play |
||
154 | |||
155 | mov ebx, [button_x_right] |
||
156 | shl ebx, 16 |
||
157 | mov bx, word[button_width_short] |
||
158 | mov ecx, [button_y_top] |
||
159 | shl ecx, 16 |
||
160 | add cx, word[button_height] |
||
161 | mcall 8, , ,0x000000D1, ; top right button |
||
162 | shr ecx, 16 |
||
163 | mov bx, cx |
||
164 | mov edx, [button_height] |
||
165 | shr edx, 1 |
||
166 | sub edx, 3 ; ~half of font height |
||
167 | add bx, dx |
||
168 | ror ebx, 16 |
||
169 | mov edx, [button_width_short] |
||
170 | shr edx, 1 |
||
171 | sub edx, string_button_exit.size*3 |
||
172 | add bx, dx |
||
173 | ror ebx, 16 |
||
174 | mcall 4, ,[button_text_color],string_button_exit |
||
175 | |||
176 | mov ebx, [button_x_left] |
||
177 | shl ebx, 16 |
||
178 | mov bx, word[button_width_long] |
||
179 | mov ecx, [button_y_middle] |
||
180 | shl ecx, 16 |
||
181 | add cx, word[button_height] |
||
182 | mcall 8, , ,0x000000D2, ; middle button |
||
183 | shr ecx, 16 |
||
184 | mov bx, cx |
||
185 | mov edi, [button_height] |
||
186 | shr edi, 1 |
||
187 | sub edi, 3 ; ~half of font height |
||
188 | add bx, di |
||
189 | ror ebx, 16 |
||
190 | mov edi, [button_width_long] |
||
191 | shr edi, 1 |
||
192 | cmp [play_mode], 0 |
||
193 | jne @f |
||
194 | sub edi, string_button_pm_classic.size*3 |
||
195 | mov edx, string_button_pm_classic |
||
196 | jmp .skip |
||
197 | @@: |
||
198 | sub edi, string_button_pm_levels.size*3 |
||
199 | mov edx, string_button_pm_levels |
||
200 | .skip: |
||
201 | add bx, di |
||
202 | ror ebx, 16 |
||
203 | mcall 4, ,[button_text_color], |
||
204 | |||
205 | mov ebx, [button_x_left] |
||
206 | shl ebx, 16 |
||
207 | mov bx, word[button_width_short] |
||
208 | mov ecx, [button_y_bottom] |
||
209 | shl ecx, 16 |
||
210 | add cx, word[button_height] |
||
211 | mcall 8, , ,0x000000D3, ; bottom left button |
||
212 | shr ecx, 16 |
||
213 | mov bx, cx |
||
214 | mov edx, [button_height] |
||
215 | shr edx, 1 |
||
216 | sub edx, 3 ; ~half of font height |
||
217 | add bx, dx |
||
218 | ror ebx, 16 |
||
219 | mov edx, [button_width_short] |
||
220 | shr edx, 1 |
||
221 | sub edx, string_button_inc.size*3 |
||
222 | add bx, dx |
||
223 | ror ebx, 16 |
||
224 | mcall 4, ,[button_text_color],string_button_inc |
||
225 | |||
226 | mov ebx, [button_x_right] |
||
227 | shl ebx, 16 |
||
228 | mov bx, word[button_width_short] |
||
229 | mov ecx, [button_y_bottom] |
||
230 | shl ecx, 16 |
||
231 | add cx, word[button_height] |
||
232 | mcall 8, , ,0x000000D4, |
||
233 | shr ecx, 16 |
||
234 | mov bx, cx |
||
235 | mov edx, [button_height] |
||
236 | shr edx, 1 |
||
237 | sub edx, 3 ; ~half of font height |
||
238 | add bx, dx |
||
239 | ror ebx, 16 |
||
240 | mov edx, [button_width_short] |
||
241 | shr edx, 1 |
||
242 | sub edx, string_button_dec.size*3 |
||
243 | add bx, dx |
||
244 | ror ebx, 16 |
||
245 | mcall 4, ,[button_text_color],string_button_dec |
||
246 | |||
247 | ret |
||
248 | |||
249 | ;;---Draw_buttons---------------------------------------------------------------------------------------------------------- |
||
250 | |||
251 | |||
252 | Delete_buttons: |
||
253 | ;;===Delete_buttons======================================================================================================== |
||
254 | |||
255 | mcall 8,,,0x800000D0 |
||
256 | mcall ,,,0x800000D1 |
||
257 | mcall ,,,0x800000D2 |
||
258 | mcall ,,,0x800000D3 |
||
259 | mcall ,,,0x800000D4 |
||
260 | |||
261 | ret |
||
262 | |||
263 | ;;---Delete_buttons-------------------------------------------------------------------------------------------------------- |
||
264 | |||
265 | |||
266 | Change_play_mode: |
||
267 | ;;===Change_play_mode====================================================================================================== |
||
268 | |||
269 | cmp [play_mode], LEVELS_MODE |
||
270 | jne @f |
||
271 | mov [play_mode], CLASSIC_MODE |
||
272 | mov [cur_level_number], 0 |
||
273 | ret |
||
274 | @@: |
||
275 | inc [play_mode] |
||
276 | |||
277 | call Set_first_level_of_play_mode |
||
278 | |||
279 | ret |
||
280 | |||
281 | ;;---Change_play_mode------------------------------------------------------------------------------------------------------ |
||
282 | |||
283 | |||
284 | Set_first_level_of_play_mode: |
||
285 | ;;===Set_first_level_of_play_mode========================================================================================== |
||
286 | |||
287 | cmp [play_mode], CLASSIC_MODE |
||
288 | jne @f |
||
289 | mov [cur_level_number], CLASSIC_MODE_FIRST_LEVEL |
||
290 | @@: |
||
291 | cmp [play_mode], LEVELS_MODE |
||
292 | jne @f |
||
293 | mov [cur_level_number], LEVELS_MODE_FIRST_LEVEL |
||
294 | @@: |
||
295 | |||
296 | ret |
||
297 | |||
298 | ;;---Set_first_level_of_play_mode------------------------------------------------------------------------------------------- |
||
299 | |||
300 | ;;---Some_functions------------------------------------------------------------------------------------------------------------- |