Subversion Repositories Kolibri OS

Rev

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