Subversion Repositories Kolibri OS

Rev

Rev 1518 | Rev 1566 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1518 Rev 1522
Line 2... Line 2...
2
 
2
 
Line 3... Line 3...
3
Level_begin:
3
Level_begin:
4
 
4
 
-
 
5
    mov  [score],   0
-
 
6
    mov  [action],  0
5
    mov  [score],   0
7
    mov  eax,   [gw_mul_gh]
Line 6... Line 8...
6
    mov  [action],  0
8
    sub  eax, 3
7
    mov  [number_of_free_dots], GRID_WIDTH*GRID_HEIGHT-3
9
    mov  [number_of_free_dots], ax
Line 8... Line 10...
8
 
10
 
Line 14... Line 16...
14
    mov  dword  [hi_score],    eax
16
    mov  dword  [hi_score],    eax
15
  @@:
17
  @@:
Line 16... Line 18...
16
 
18
 
17
    mov  esi, start_map
19
    mov  esi, start_map
18
    mov  edi, field_map
20
    mov  edi, field_map
-
 
21
    mov  ecx, [gw_mul_gh]
19
    mov  ecx, GRID_WIDTH*GRID_HEIGHT/4
22
    shr  ecx, 2
Line -... Line 23...
-
 
23
    rep  movsd
-
 
24
 
20
    rep  movsd
25
      call      Get_eat
21
 
26
 
Line 22... Line 27...
22
Level_body:
27
Level_body:
23
    ;;===Level_body========================================================================================================
28
    ;;===Level_body========================================================================================================
24
 
29
 
25
mcall     26, 9
30
mcall     26, 9
Line 26... Line 31...
26
    mov  [time_before_waiting], eax
31
    mov  [time_before_waiting], eax
27
    mov  eax, [time_wait_limit]
32
    mov  eax, [time_wait_limit]
-
 
33
    mov  [time_to_wait],    eax
-
 
34
 
-
 
35
  .redraw:
-
 
36
      mcall     12,1
-
 
37
    mov  ebx, [wp_x]
-
 
38
    shl  ebx, 16
28
    mov  [time_to_wait],    eax
39
    add  ebx, dword[window_width]
Line 29... Line 40...
29
 
40
    mov  ecx, [wp_y]
30
  Redraw:
41
    shl  ecx, 16
31
      mcall     12,1
42
    add  ecx, dword[window_height]
32
      mcall     0,200*65536+WINDOW_WIDTH,326*65536+WINDOW_HEIGHT,[window_style], ,window_title
43
      mcall     0, , ,[window_style], ,window_title
Line 33... Line 44...
33
    
44
    
Line 34... Line 45...
34
      call      Draw_decorations
45
      call      Draw_decorations
35
      call      Draw_snake
46
      call      Draw_snake
36
      call      Draw_eat
47
      call      Draw_eat
37
      call      Draw_level_strings
48
      call      Draw_level_strings
38
 
49
 
39
      mcall     12,2
50
      mcall     12,2
Line 57... Line 68...
57
     jne Game_step
68
     jne Game_step
58
      mcall     26, 9
69
      mcall     26, 9
59
    mov  [time_before_waiting], eax
70
    mov  [time_before_waiting], eax
60
    mov  eax, [time_wait_limit]
71
    mov  eax, [time_wait_limit]
61
    mov  [time_to_wait],    eax
72
    mov  [time_to_wait],    eax
62
     jmp Waiting
73
     jmp .still
63
  @@:
74
  @@:
Line 64... Line 75...
64
 
75
 
65
      Message:                                  ; ok, what an event?
76
      .message:                                 ; ok, what an event?
66
        dec  al                                 ; has the window been moved or resized?
77
        dec  al                                 ; has the window been moved or resized?
67
         jz  Redraw                             ;
78
         jz  .redraw                            ;
68
        dec  al                                 ; was a key pressed?
79
        dec  al                                 ; was a key pressed?
69
         jz  Key                                ; 
80
         jz  .key                               ; 
70
        dec  al                                 ; was a button pressed?
81
        dec  al                                 ; was a button pressed?
Line 71... Line 82...
71
         jz  Button                             ; 
82
         jz  .button                            ; 
72
 
83
 
Line 73... Line 84...
73
 
84
 
74
  Key:
85
  .key:
75
      mcall     2                               ; get keycode
86
      mcall     2                               ; get keycode
76
    
87
    
77
    cmp  ah,  0x1B                              ; Escape
88
    cmp  ah,  0x1B                              ; Escape
78
     je  First_menu
89
     je  First_menu
79
    cmp  ah,  0x20                              ; Space
90
    cmp  ah,  0x20                              ; Space
80
     je  Pause_mode
91
     je  Pause_mode
81
    cmp  ah,  0xB0                              ; Left
92
    cmp  ah,  0xB0                              ; Left
82
     je  .left
93
     je  .key.left
83
    cmp  ah,  0xB1                              ; Down
94
    cmp  ah,  0xB1                              ; Down
84
     je  .down
95
     je  .key.down
Line 85... Line 96...
85
    cmp  ah,  0xB2                              ; Up
96
    cmp  ah,  0xB2                              ; Up
Line -... Line 97...
-
 
97
     je  .key.up
-
 
98
    cmp  ah,  0xB3                              ; Right
-
 
99
     je  .key.right
-
 
100
    
-
 
101
     jmp .still                                 ; jump to wait for another event
-
 
102
 
-
 
103
 
-
 
104
  .button:                                       ; ¯à®æ¥¤ãà  ®¡à ¡®ª¨ ª­®¯®ª ¢ ¯à®£à ¬¬¥
-
 
105
      mcall     17                              ; äã­ªæ¨ï 17: ¯®«ãç¨âì ­®¬¥à ­ ¦ â®© ª­®¯ª¨
-
 
106
 
86
     je  .up
107
    shr  eax, 8                                 ; ᤢ¨£ ¥¬ ॣ¨áâà eax ­  8 ¡¨â ¢¯à ¢®, çâ®¡ë ¯®«ãç¨âì ­®¬¥à ­ ¦ â®© ª­®¯ª¨
87
    cmp  ah,  0xB3                              ; Right
108
    cmp  eax, 1
88
     je  .right
109
     je  Exit                                   ; ¥á«¨ íâ® ­¥ ª­®¯ª  1 (§ à¥§¥à¢¨à®¢ ­  á¨á⥬®© ª ª ª­®¯ª  § ªàëâ¨ï ¯à®£à ¬¬ë), ¯à®¯ã᪠¥¬ 2 á«¥¤ãî騥 áâà®çª¨ ª®¤ 
89
    
110
 
90
     jmp Waiting                                ; jump to wait for another event
111
     jmp .still
91
        
-
 
92
        
112
 
93
  .left:
113
 
Line 94... Line 114...
94
    cmp  [action],  0
114
  .key.left:
95
     jne @f
115
    bts  dword[action], 0
96
    mov  [time_to_wait],    0
116
     jc  @f
97
  @@:
117
    mov  [time_to_wait],    0
98
    mov  [action],  1
118
  @@:
99
    mov  [snake_napravlenie_next],  0
-
 
100
     jmp Waiting
119
    mov  [snake_napravlenie_next],  LEFT
101
            
120
     jmp .still
Line 102... Line 121...
102
  .down:
121
            
103
    cmp  [action],  0
122
  .key.down:
104
     jne @f
123
    bts  dword[action], 0
105
    mov  [time_to_wait],    0
124
     jc  @f
106
  @@:
125
    mov  [time_to_wait],    0
107
    mov  [action],  1
-
 
108
    mov  [snake_napravlenie_next],  1
126
  @@:
109
     jmp Waiting
127
    mov  [snake_napravlenie_next],  DOWN
Line 110... Line 128...
110
            
128
     jmp .still
111
  .up:
129
            
112
    cmp  [action],  0
130
  .key.up:
113
     jne @f
131
    bts  dword[action], 0
114
    mov  [time_to_wait],    0
132
     jc  @f
115
  @@:
-
 
116
    mov  [action],  1        
133
    mov  [time_to_wait],    0
117
    mov  [snake_napravlenie_next],  2
-
 
118
     jmp Waiting
-
 
119
            
-
 
120
  .right:
-
 
121
    cmp  [action],  0
-
 
122
     jne @f
-
 
123
    mov  [time_to_wait],    0
-
 
124
  @@:
-
 
125
    mov  [action],  1           
-
 
126
    mov  [snake_napravlenie_next],  3
-
 
127
     jmp Waiting
134
  @@:
Line 128... Line 135...
128
            
135
    mov  [snake_napravlenie_next],  UP
Line 129... Line 136...
129
 
136
     jmp .still
Line 190... Line 197...
190
        mov  [snake_napravlenie],   LEFT
197
        mov  [snake_napravlenie],   LEFT
191
        mov  ax,  [edx]
198
        mov  ax,  [edx]
192
        dec  al
199
        dec  al
193
        cmp  al,  -1
200
        cmp  al,  -1
194
         jne @f
201
         jne @f
195
        mov  al,  GRID_WIDTH-1
202
        mov  al,  byte[g_w]
-
 
203
        dec  al
196
      @@:
204
      @@:
197
         jmp Snake_move
205
         jmp Snake_move
Line 198... Line 206...
198
 
206
 
199
      .to_down:
207
      .to_down:
200
        mov  [snake_napravlenie],   DOWN
208
        mov  [snake_napravlenie],   DOWN
201
        mov  ax,  [edx]
209
        mov  ax,  [edx]
202
        inc  ah
210
        inc  ah
203
        cmp  ah,  GRID_HEIGHT
211
        cmp  ah,  byte[g_h]
204
         jne @f
212
         jne @f
205
        mov  ah,  0
213
        mov  ah,  0
206
      @@:
214
      @@:
Line 210... Line 218...
210
        mov  [snake_napravlenie],   UP
218
        mov  [snake_napravlenie],   UP
211
        mov  ax,  [edx]
219
        mov  ax,  [edx]
212
        dec  ah
220
        dec  ah
213
        cmp  ah,  -1
221
        cmp  ah,  -1
214
         jne @f
222
         jne @f
215
        mov  ah,  GRID_HEIGHT-1
223
        mov  ah,  byte[g_h]
-
 
224
        dec  ah
216
      @@:
225
      @@:
217
         jmp Snake_move
226
         jmp Snake_move
Line 218... Line 227...
218
        
227
        
219
      .to_right:
228
      .to_right:
220
        mov  [snake_napravlenie],   RIGHT
229
        mov  [snake_napravlenie],   RIGHT
221
        mov  ax,  [edx]
230
        mov  ax,  [edx]
222
        inc  al
231
        inc  al
223
        cmp  al,  GRID_WIDTH
232
        cmp  al,  byte[g_w]
224
         jne @f
233
         jne @f
225
        mov  al,  0
234
        mov  al,  0
226
      @@:
235
      @@:
Line 272... Line 281...
272
 
281
 
273
 
282
 
Line -... Line 283...
-
 
283
Draw_level_strings:
-
 
284
    ;;===Draw_level_strings================================================================================================
-
 
285
 
-
 
286
    mov  ebx, [window_width]
-
 
287
    shr  ebx, 1
-
 
288
    sub  ebx, (string_resume_space-string_pause_space-1)*3+6
-
 
289
    shl  ebx, 16
274
Draw_level_strings:
290
    add  ebx, [top_strings]
275
    ;;===Draw_level_strings================================================================================================
291
      mcall     4, ,[navigation_strings_color],string_pause_space ; Draw 'PAUSE - SPACE' string
276
 
292
 
277
    call    Draw_menu_esc
-
 
278
    call    Draw_score_string
-
 
279
    call    Draw_score_number                   ; Draw score (number)
293
;    call    Draw_menu_esc
280
    call    Draw_hiscore_string
294
    call    Draw_score_string
281
    call    Draw_hiscore_number
-
 
282
    call    Draw_champion_string
295
    call    Draw_score_number                   ; Draw score (number)
-
 
296
    call    Draw_champion_string
Line 283... Line 297...
283
    call    Draw_champion_name
297
    call    Draw_champion_name
Line 284... Line 298...
284
 
298
    call    Draw_hiscore_string
Line 297... Line 311...
297
    mov  esi, snake_dots
311
    mov  esi, snake_dots
298
    mov  edi, snake_dots-2
312
    mov  edi, snake_dots-2
299
    add  edi, [snake_length_x2]
313
    add  edi, [snake_length_x2]
Line 300... Line 314...
300
 
314
 
301
  @@:
-
 
302
 
315
  @@:
303
    mov  ax,  [edi]
316
    mov  ax,  [edi]
304
    xchg ax,  [esi]
317
    xchg ax,  [esi]
Line 305... Line -...
305
    mov  [edi], ax
-
 
306
 
318
    mov  [edi], ax
307
    dec  cx
319
 
308
    add  esi, 2
-
 
309
    sub  edi, 2
320
    add  esi, 2
310
 
321
    sub  edi, 2
Line 311... Line 322...
311
    test  cx, cx
322
    dec  cx
Line 312... Line 323...
312
     jnz @b
323
     jnz @b
Line 355... Line 366...
355
     jmp .loop
366
     jmp .loop
Line 356... Line 367...
356
     
367
     
357
  .place_found:
368
  .place_found:
358
    sub  ebx, field_map
369
    sub  ebx, field_map
359
    mov  eax, ebx
370
    mov  eax, ebx
360
    mov  bl,  GRID_WIDTH
371
    mov  bl,  byte[g_w]
361
    div  bl
372
    div  bl
Line 362... Line 373...
362
    xchg al,  ah
373
    xchg al,  ah
Line 389... Line 400...
389
 
400
 
390
    mov  eax, snake_dots
401
    mov  eax, snake_dots
Line 391... Line 402...
391
    mov  ebx, snake_dots+2
402
    mov  ebx, snake_dots+2
392
 
403
 
Line 393... Line 404...
393
    mov  cl,  [eax]                             ; The last dot x_coord
404
    mov  cl,  [eax]                             ; The last dot x_coord
394
    mov  dl,  [ebx]                             ; The pre_last dot x_coord
405
    mov  ch,  [ebx]                             ; The pre_last dot x_coord
Line 395... Line 406...
395
 
406
 
396
    cmp  cl,  dl
407
    cmp  cl,  ch
Line -... Line 408...
-
 
408
     je  .X_ravny
-
 
409
    
397
     je  .X_ravny
410
    cmp  cl,  0
398
    
411
     jne .skip2
399
    cmp  cl,  0
412
    
400
     jne .skip2
413
    mov  dl,  byte[g_w]
Line 401... Line 414...
401
    
414
    dec  dl
-
 
415
    cmp  ch,  dl
-
 
416
     jne .Normal_y_ravny
402
    cmp  dl,  23
417
    mov  [snake_napravlenie_next],  RIGHT
403
     jne .Normal_y_ravny
418
    ret
404
    mov  [snake_napravlenie_next],  3
419
        
405
    ret
420
  .skip2:
406
        
421
    mov  dl,  byte[g_w]
407
  .skip2:
422
    dec  dl
Line 408... Line 423...
408
    cmp  cl,  23
423
    cmp  cl,  dl
Line 409... Line 424...
409
     jne .Normal_y_ravny
424
     jne .Normal_y_ravny
410
    cmp  dl,  0
425
    cmp  ch,  0
411
     jne .Normal_y_ravny
426
     jne .Normal_y_ravny
412
    mov  [snake_napravlenie_next],  0
427
    mov  [snake_napravlenie_next],  LEFT
Line 413... Line 428...
413
    ret
428
    ret
414
    
429
    
415
  .Normal_y_ravny:
430
  .Normal_y_ravny:
Line 416... Line 431...
416
 
431
 
417
    cmp  cl,  dl
432
    cmp  cl,  ch
418
     jg  .Napravlenie_to_right
433
     jg  .Napravlenie_to_right
419
    mov  [snake_napravlenie_next],  0
434
    mov  [snake_napravlenie_next],  LEFT
420
    ret
435
    ret
Line 421... Line 436...
421
 
436
 
422
  .Napravlenie_to_right:
437
  .Napravlenie_to_right:
Line -... Line 438...
-
 
438
    mov  [snake_napravlenie_next],  RIGHT
-
 
439
    ret
423
    mov  [snake_napravlenie_next],  3
440
 
424
    ret
441
  .X_ravny:
425
 
442
    inc  eax
426
  .X_ravny:
443
    inc  ebx
Line 427... Line 444...
427
    inc  eax
444
    mov  cl,  [eax]
-
 
445
    mov  ch,  [ebx]
-
 
446
    
428
    inc  ebx
447
    cmp  cl,  0
429
    mov  cl,  [eax]
448
     jne .skip3
430
    mov  dl,  [ebx]
449
    
431
    
450
    mov  dl,  byte[g_h]
432
    cmp  cl,  0
451
    dec  dl
433
     jne .skip3
452
    cmp  ch,  dl
Line 434... Line 453...
434
    
453
     jne .Normal_x_ravny
Line 435... Line 454...
435
    cmp  dl,  10
454
    mov  [snake_napravlenie_next],  DOWN
436
     jne .Normal_x_ravny
455
    ret
437
    mov  [snake_napravlenie_next],  1
456
        
438
    ret
457
  .skip3:
439
        
458
    mov  dl,  byte[g_h]
440
  .skip3:
459
    dec  dl
441
    cmp  cl,  10
460
    cmp  ch,  dl
Line 442... Line 461...
442
     jne .Normal_x_ravny
461
     jne .Normal_x_ravny
Line 443... Line 462...
443
    cmp  dl,  0
462
    cmp  ch,  0
Line 487... Line 506...
487
     jmp Keys_done
506
     jmp Keys_done
Line 488... Line 507...
488
 
507
 
Line -... Line 508...
-
 
508
 
-
 
509
  .eat_and_new_head_are_different:
489
 
510
 
-
 
511
    push ax
490
  .eat_and_new_head_are_different:
512
    
-
 
513
    mov  ax,  word[snake_dots]
-
 
514
    mov  cl,  0
Line 491... Line 515...
491
 
515
      call      Draw_on_map
492
    mov  ecx, snake_dots-4
516
 
493
    add  ecx, [snake_length_x2]
517
    pop ax
Line 501... Line 525...
501
      
525
      
502
    mov  bx,  word[snake_dots]
526
    mov  bx,  word[snake_dots]
503
    mov  edx, [background_color]
527
    mov  edx, [background_color]
Line 504... Line -...
504
      call      Draw_square
-
 
505
 
-
 
506
    mov  ax,  word[snake_dots]
-
 
507
    mov  cl,  0
528
      call      Draw_square
Line 508... Line 529...
508
      call      Draw_on_map
529
    
Line 520... Line 541...
520
  @@:
541
  @@:
521
      mcall     26, 9
542
      mcall     26, 9
522
    mov  [time_before_waiting], eax
543
    mov  [time_before_waiting], eax
523
    mov  eax, [time_wait_limit]
544
    mov  eax, [time_wait_limit]
524
    mov  [time_to_wait],    eax
545
    mov  [time_to_wait],    eax
525
     jmp Waiting
546
     jmp Level_body.still
Line 526... Line 547...
526
 
547
 
Line 527... Line 548...
527
    ;;---Snake_move--------------------------------------------------------------------------------------------------------
548
    ;;---Snake_move------------------------------------------------------------------------------------------------------------
528
 
549