Subversion Repositories Kolibri OS

Rev

Rev 1520 | 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
;;===HEADER====================================================================================================================
2
 
3
use32
4
    org 0x0
5
    db  'MENUET01'
6
    dd  0x1,start,i_end,d_end,stacktop,0x0,cur_dir_path
7
 
8
;;---HEADER--------------------------------------------------------------------------------------------------------------------
9
 
10
include '../../../proc32.inc'
11
include '../../../macros.inc'
12
include '../../../system/launch/trunk/mem.inc'
13
include '../../../develop/libraries/libs-dev/.test/dll.inc'
14
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
1520 dunkaist 15
;include '../../../system/board/trunk/debug.inc'
1518 dunkaist 16
 
17
;;===Define_chapter============================================================================================================
18
 
19
SCORE_EAT                   equ     100
20
 
21
LEFT                        equ     0
22
DOWN                        equ     1
23
UP                          equ     2
24
RIGHT                       equ     3
25
 
26
;;---Define_chapter------------------------------------------------------------------------------------------------------------
27
 
28
start:
29
 
30
stdcall dll.Load,@IMPORT
31
    or   eax, eax
32
    jnz  Exit
33
 
34
align 4
35
 
36
    mov  eax, cur_dir_path
37
  @@:
38
    cmp  byte[eax], 0
39
     jz  @f
40
    inc  eax
41
     jmp @b
42
  @@:
43
    mov  dword[eax],    '.ini'
44
 
1520 dunkaist 45
      invoke  ini.get_int, cur_dir_path, aPreferences, aSpeed, 80
1518 dunkaist 46
    neg  eax
47
    add  [time_wait_limit],    eax
1522 dunkaist 48
      invoke  ini.get_int, cur_dir_path, aPreferences, aSquare_side_length, 19
49
    mov  [square_side_length],  eax
50
      invoke  ini.get_int, cur_dir_path, aPreferences, aSpace_between_squares, 1
51
    mov  [space_between_squares],   eax
52
      invoke  ini.get_str, cur_dir_path, aPreferences, aTheme, aTheme_name, 31, aTheme_name
53
 
54
      invoke  ini.get_int, cur_dir_path, aTheme_name, aDecorations, 2
1518 dunkaist 55
    mov  [decorations], al
1522 dunkaist 56
      invoke  ini.get_color, cur_dir_path, aTheme_name, aBackground_color, 0x000000
1518 dunkaist 57
    or   [background_color],    eax
58
    or   [window_style],    eax
1522 dunkaist 59
      invoke  ini.get_color, cur_dir_path, aTheme_name, aDecorations_color, 0x00aaaa00
1518 dunkaist 60
    or   [decorations_color],  eax
1522 dunkaist 61
      invoke  ini.get_color, cur_dir_path, aTheme_name, aSnake_color, 0x1111ff
1518 dunkaist 62
    or   [snake_color], eax
1522 dunkaist 63
      invoke  ini.get_color, cur_dir_path, aTheme_name, aSnake_head_color, 0x1111ff
1518 dunkaist 64
    or   [snake_head_color], eax
1522 dunkaist 65
      invoke  ini.get_color, cur_dir_path, aTheme_name, aSnake_picture_color, 0x4488ff
1518 dunkaist 66
    or   [snake_picture_color], eax
1522 dunkaist 67
      invoke  ini.get_color, cur_dir_path, aTheme_name, aVersion_picture_color, 0x55ff55
1518 dunkaist 68
    or   [version_picture_color],   eax
1522 dunkaist 69
      invoke  ini.get_color, cur_dir_path, aTheme_name, aPause_picture_color, 0x11ff11
1518 dunkaist 70
    or   [pause_picture_color], eax
1522 dunkaist 71
      invoke  ini.get_color, cur_dir_path, aTheme_name, aGame_over_picture_color, 0xff1111
1518 dunkaist 72
    or   [game_over_picture_color], eax
1522 dunkaist 73
      invoke  ini.get_color, cur_dir_path, aTheme_name, aEat_color, 0xffff11
1518 dunkaist 74
    or   [eat_color],   eax
1522 dunkaist 75
      invoke  ini.get_color, cur_dir_path, aTheme_name, aNavigation_strings_color, 0x80ff7777
1518 dunkaist 76
    or   [navigation_strings_color], eax
1522 dunkaist 77
      invoke  ini.get_color, cur_dir_path, aTheme_name, aGame_over_strings_color, 0x80ff9900
1518 dunkaist 78
    or   [game_over_strings_color],  eax
1522 dunkaist 79
      invoke  ini.get_color, cur_dir_path, aTheme_name, aScore_string_color, 0x80ffffff
1518 dunkaist 80
    or   [score_string_color],   eax
1522 dunkaist 81
      invoke  ini.get_color, cur_dir_path, aTheme_name, aHiscore_string_color, 0x80ffffff
1518 dunkaist 82
    or   [hiscore_string_color],   eax
1522 dunkaist 83
      invoke  ini.get_color, cur_dir_path, aTheme_name, aChampion_string_color, 0x80ffffff
1518 dunkaist 84
    or   [champion_string_color],   eax
1522 dunkaist 85
      invoke  ini.get_color, cur_dir_path, aTheme_name, aGame_over_hiscore_color, 0x80ffdd44
1518 dunkaist 86
    or   [game_over_hiscore_color], eax
1522 dunkaist 87
      invoke  ini.get_color, cur_dir_path, aTheme_name, aScore_number_color, 0xffffff
1518 dunkaist 88
    or   [score_number_color],   eax
1522 dunkaist 89
      invoke  ini.get_color, cur_dir_path, aTheme_name, aHiscore_number_color, 0x00ffffff
1518 dunkaist 90
    or   [hiscore_number_color],   eax
1522 dunkaist 91
      invoke  ini.get_color, cur_dir_path, aTheme_name, aChampion_name_color, 0x80ffffff
1518 dunkaist 92
    or   [champion_name_color],   eax
1522 dunkaist 93
      invoke  ini.get_color, cur_dir_path, aTheme_name, aEdit_box_selection_color, 0x00aa00
1520 dunkaist 94
    or   [edit1+0x10],  eax
1518 dunkaist 95
 
1520 dunkaist 96
    mov  eax, [background_color]
97
    mov  [edit1+0x0C],  eax
98
    mov  [edit1+0x14],  eax
99
    mov  [edit1+0x18],  eax
100
    mov  eax, [game_over_hiscore_color]
101
    mov  [edit1+0x1C],  eax
102
 
1522 dunkaist 103
      call      Set_geometry
104
 
1518 dunkaist 105
include 'first_menu.asm'            ; First menu body and functions
106
include 'level.asm'                 ; Level body and functions (game process)
107
include 'pause.asm'                 ; Pause body and functions
108
include 'game_over.asm'             ; Game_over body and functions
109
 
110
;;===Some_functions============================================================================================================
111
 
112
Exit:
1522 dunkaist 113
    ;;===Exit==================================================================================================================
1518 dunkaist 114
 
115
    or  eax,    -1
116
    int 0x40
117
 
1522 dunkaist 118
    ;;---Exit------------------------------------------------------------------------------------------------------------------
119
 
120
 
121
Set_geometry:
122
    ;;===Set_geometry==========================================================================================================
123
 
124
    mov  eax, [space_between_squares]
125
    add  eax, [square_side_length]
126
    mov  [g_s],   eax
127
 
128
    mov  eax, [g_s]
129
    shr  eax, 1
130
    mov  ebx, eax
131
    shr  ebx, 1
132
    add  eax, ebx
133
    mov  [g_e], eax
134
 
135
    mov  eax, [g_s]
136
    add  eax, [g_e]
137
    mov  [gbxm1],   eax
138
 
139
    mov  eax, [g_e]
140
    add  eax, 25
141
    mov  [gbym1],   eax
142
 
143
    mov  eax, [g_w]
144
    mul  word[g_h]
145
    mov  [gw_mul_gh],   eax
146
 
147
    mov  edx, [g_w]
148
    mov  eax, [g_s]
149
    mul  dx
150
    mov  [gw_mul_gs],   eax
151
 
152
    mov  edx, [g_h]
153
    mov  eax, [g_s]
154
    mul  dx
155
    mov  [gh_mul_gs],   eax
156
 
157
    mov  eax, [gbxm1]
158
    add  eax, [gw_mul_gs]
159
    mov  [gbxm1_plus_gw_mul_gs],    eax
160
 
161
    mov  eax, [gbym1]
162
    add  eax, [gh_mul_gs]
163
    mov  [gbym1_plus_gh_mul_gs],    eax
164
 
165
    mov  eax, [g_s]
166
    shl  eax, 16
167
    add  eax, [g_s]
168
    mov  [gs_shl16_gs], eax
169
 
170
    mov  eax, [gbxm1]
171
    shl  eax, 16
172
    add  eax, [gbxm1]
173
    mov  [gbxm1_shl16_gbxm1],   eax
174
 
175
    mov  eax, [gbym1]
176
    shl  eax, 16
177
    add  eax, [gbym1]
178
    mov  [gbym1_shl16_gbym1],   eax
179
 
180
 
181
    mov  eax, [gw_mul_gs]
182
    add  eax, [gbxm1]
183
    add  eax, [gbxm1]
184
    add  eax, 5*2                                   ; skin width
185
    mov  [window_width],    eax
186
 
187
    mov  eax, [gh_mul_gs]
188
    add  eax, [gbym1]
189
    add  eax, [g_e]
190
    add  eax, 30
191
    add  eax, 22+5                                  ; skin height
192
    mov  [window_height],   eax
193
 
194
      mcall     48, 5
195
    mov  dx,  ax
196
    shr  eax, 16
197
    sub  dx,  ax
198
    cmp  dx, word[window_width]                     ; does window fit to work area width?
199
     jnl @f
200
    dec  [square_side_length]
201
;    dps  'snake: Window does not fit to screen.'
202
;    newline
203
;    dps  'Square_side_length was decreased.'
204
;    newline
205
;    dps  'Check you config file! (snake.ini)'
206
;    newline
207
     jmp Set_geometry
208
  @@:
209
 
210
    mov  cx,  bx
211
    shr  ebx, 16
212
    sub  cx,  bx
213
    cmp  cx, word[window_height]                     ; does window fit to work area height?
214
     jnl @f
215
    dec  [square_side_length]
216
;    dps  'snake: Window does not fit to screen.'
217
;    newline
218
;    dps  'Square_side_length was decreased.'
219
;    newline
220
;    dps  'Check you config file! (snake.ini)'
221
;    newline
222
     jmp Set_geometry
223
  @@:
224
 
225
    sub  dx,  word[window_width]
226
    shr  dx,  1
227
    mov  word[wp_x],    dx
228
    sub  cx,  word[window_height]
229
    shr  cx,  1
230
    mov  dx,  cx
231
    shr  cx,  1
232
    add  cx,  dx
233
    mov  word[wp_y],    cx
234
 
235
    mov  [top_strings], 8
236
    mov  eax, [window_height]
237
    sub  eax, 50
238
    mov  [bottom_top_strings],  eax
239
    add  eax, 6
240
    mov  [bottom_middle_strings],  eax
241
    add  eax, 6
242
    mov  [bottom_bottom_strings],  eax
243
 
244
    sub  eax, 4
245
    mov  [edit1+0x08],  eax
246
 
247
    ret
248
 
249
    ;;---Set_geometry------------------------------------------------------------------------------------------------------
250
 
251
 
1518 dunkaist 252
Draw_decorations:
253
    ;;===Draw_decorations==================================================================================================
254
 
1522 dunkaist 255
    mov  al, [decorations]
256
    dec  al
257
     jz  grid_lines
258
    dec  al
259
     jz  grid_lines_with_ends
260
    dec  al
261
     jz  grid_lines_with_corners
262
    dec  al
263
     jz  grid_dots
264
    dec  al
265
     jz  borders_lines
266
    dec  al
267
     jz  borders_lines_with_corners
268
    dec  al
269
     jz  borders_dots
270
    dec  al
271
     jz  corners_dots
272
    dec  al
273
     jz  corners_inner
274
    dec  al
275
     jz  corners_outer
276
    dec  al
277
     jz  corners_crosses
1518 dunkaist 278
    ret
279
 
280
 
281
  grid_lines:
282
 
283
    mov  eax, 38
1522 dunkaist 284
;mov  ebx, (GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1)
285
    mov  ebx, [gbxm1_shl16_gbxm1]
286
;mov  ecx, (GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP)
287
    mov  ecx, [gbym1_shl16_gbym1]
288
    add  ecx, [gh_mul_gs]
1518 dunkaist 289
    mov  edx, [decorations_color]
1522 dunkaist 290
    mov  esi, [g_w]
291
    add  esi, 1
1518 dunkaist 292
 
293
  @@:
294
      mcall
1522 dunkaist 295
    add  ebx, [gs_shl16_gs]
296
    dec  esi
297
     jnz @b
1518 dunkaist 298
 
1522 dunkaist 299
;mov  ebx, (GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP)
300
    mov  ebx, [gbxm1_shl16_gbxm1]
301
    add  ebx, [gw_mul_gs]
302
    mov  ecx, [gbym1_shl16_gbym1]
303
    mov  esi, [g_h]
304
    add  esi, 1
1518 dunkaist 305
 
306
  @@:
307
      mcall
1522 dunkaist 308
    add  ecx, [gs_shl16_gs]
309
    dec  esi
310
     jnz @b
1518 dunkaist 311
 
312
    ret
313
 
314
 
315
  grid_lines_with_ends:
316
 
317
    mov  eax, 38
1522 dunkaist 318
    mov  ebx, [gbxm1_shl16_gbxm1]
319
    mov  ecx, [gbym1]
320
    sub  ecx, [g_e]
321
    shl  ecx, 16
322
    add  ecx, [gbym1_plus_gh_mul_gs]
323
    add  ecx, [g_e]
1518 dunkaist 324
    mov  edx, [decorations_color]
1522 dunkaist 325
    mov  esi, [g_w]
326
    add  esi, 1
1518 dunkaist 327
 
328
  @@:
329
      mcall
1522 dunkaist 330
    add  ebx, [gs_shl16_gs]
331
    dec  esi
332
     jnz @b
1518 dunkaist 333
 
1522 dunkaist 334
    mov  ebx, [gbxm1]
335
    sub  ebx, [g_e]
336
    shl  ebx, 16
337
    add  ebx, [gbxm1_plus_gw_mul_gs]
338
    add  ebx, [g_e]
339
    mov  ecx, [gbym1_shl16_gbym1]
340
    mov  esi, [g_h]
341
    add  esi, 1
1518 dunkaist 342
 
343
  @@:
344
      mcall
1522 dunkaist 345
    add  ecx, [gs_shl16_gs]
346
    dec  esi
347
     jnz @b
1518 dunkaist 348
 
349
    ret
350
 
351
 
352
  grid_lines_with_corners:
353
 
354
      call      grid_lines
355
      call      corners_outer
356
 
357
    ret
358
 
359
 
360
  grid_dots:
361
 
362
    mov  eax, 1
1522 dunkaist 363
    mov  ebx, [gbxm1]
364
    mov  ecx, [gbym1]
1518 dunkaist 365
    mov  edx, [decorations_color]
366
 
367
  @@:
368
      mcall
1522 dunkaist 369
    add  ebx, [g_s]
370
    cmp  ebx, [gbxm1_plus_gw_mul_gs]
1518 dunkaist 371
     jng @b
1522 dunkaist 372
    add  ecx, [g_s]
373
    cmp  ecx, [gbym1_plus_gh_mul_gs]
1518 dunkaist 374
     jg  @f
1522 dunkaist 375
    mov  ebx, [gbxm1]
1518 dunkaist 376
     jmp @b
377
 
378
  @@:
379
    ret
380
 
381
 
382
  borders_lines:
383
 
1522 dunkaist 384
    mov  eax, 38
385
    mov  ebx, [gbxm1_shl16_gbxm1]
386
    mov  ecx, [gbym1_shl16_gbym1]
387
    add  ecx, [gh_mul_gs]
388
    mov  edx, [decorations_color]
389
      mcall
1518 dunkaist 390
 
1522 dunkaist 391
    mov  ebx, [gbxm1_plus_gw_mul_gs]
392
    shl  ebx, 16
393
    add  ebx, [gbxm1_plus_gw_mul_gs]
394
      mcall
395
 
396
    mov  ebx, [gbxm1_shl16_gbxm1]
397
    add  ebx, [gw_mul_gs]
398
    mov  ecx, [gbym1_shl16_gbym1]
399
      mcall
400
 
401
    mov  ecx, [gbym1_plus_gh_mul_gs]
402
    shl  ecx, 16
403
    add  ecx, [gbym1_plus_gh_mul_gs]
404
      mcall
405
 
1518 dunkaist 406
    ret
407
 
408
 
1522 dunkaist 409
  borders_lines_with_corners:
1518 dunkaist 410
 
411
      call      borders_lines
412
      call      corners_outer
413
 
414
    ret
415
 
416
 
417
  borders_dots:
418
 
419
    mov  eax, 1
1522 dunkaist 420
    mov  ebx, [gbxm1]
421
    mov  ecx, [gbym1]
1518 dunkaist 422
    mov  edx, [decorations_color]
423
  @@:
424
      mcall
1522 dunkaist 425
    add  ebx, [g_s]
426
    cmp  ebx, [gbxm1_plus_gw_mul_gs]
1518 dunkaist 427
     jng @b
428
 
1522 dunkaist 429
    mov  ebx, [gbxm1]
430
    mov  ecx, [gbym1_plus_gh_mul_gs]
1518 dunkaist 431
  @@:
432
      mcall
1522 dunkaist 433
    add  ebx, [g_s]
434
    cmp  ebx, [gbxm1_plus_gw_mul_gs]
1518 dunkaist 435
     jng @b
436
 
1522 dunkaist 437
    mov  ebx, [gbxm1]
438
    mov  ecx, [gbym1]
1518 dunkaist 439
  @@:
440
      mcall
1522 dunkaist 441
    add  ecx, [g_s]
442
    cmp  ecx, [gbym1_plus_gh_mul_gs]
1518 dunkaist 443
     jng @b
444
 
1522 dunkaist 445
    mov  ebx, [gbxm1_plus_gw_mul_gs]
446
    mov  ecx, [gbym1]
1518 dunkaist 447
  @@:
448
      mcall
1522 dunkaist 449
    add  ecx, [g_s]
450
    cmp  ecx, [gbym1_plus_gh_mul_gs]
1518 dunkaist 451
     jng @b
452
 
453
    ret
454
 
455
 
456
  corners_dots:
457
 
1522 dunkaist 458
    mov  eax, 13
459
    mov  ebx, [gbxm1]
460
    dec  ebx
461
    shl  ebx, 16
462
    add  ebx, 2
463
    mov  ecx, [gbym1]
464
    dec  ecx
465
    shl  ecx, 16
466
    add  ecx, 2
467
    mov  edx, [decorations_color]
468
      mcall
1518 dunkaist 469
 
1522 dunkaist 470
    mov  ebx, [gbxm1_plus_gw_mul_gs]
471
    shl  ebx, 16
472
    add  ebx, 2
473
      mcall
474
 
475
    mov  ebx, [gbxm1]
476
    dec  ebx
477
    shl  ebx, 16
478
    add  ebx, 2
479
    mov  ecx, [gbym1_plus_gh_mul_gs]
480
    shl  ecx, 16
481
    add  ecx, 2
482
      mcall
483
 
484
    mov  ebx, [gbxm1_plus_gw_mul_gs]
485
    shl  ebx, 16
486
    add  ebx, 2
487
      mcall
488
 
1518 dunkaist 489
    ret
490
 
491
 
492
  corners_inner:
493
 
1522 dunkaist 494
    mov  eax, 38
495
    mov  ebx, [gbxm1_shl16_gbxm1]
496
    add  ebx, [g_e]
497
    mov  ecx, [gbym1_shl16_gbym1]
498
    mov  edx, [decorations_color]
499
      mcall
1518 dunkaist 500
 
1522 dunkaist 501
    mov  ecx, [gbym1_plus_gh_mul_gs]
502
    shl  ecx, 16
503
    add  ecx, [gbym1_plus_gh_mul_gs]
504
      mcall
505
 
506
    mov  ebx, [gbxm1_plus_gw_mul_gs]
507
    sub  ebx, [g_e]
508
    shl  ebx, 16
509
    add  ebx, [gbxm1_plus_gw_mul_gs]
510
      mcall
511
 
512
    mov  ecx, [gbym1_shl16_gbym1]
513
      mcall
514
 
515
    mov  ebx, [gbxm1_shl16_gbxm1]
516
    mov  ecx, [gbym1_shl16_gbym1]
517
    add  ecx, [g_e]
518
      mcall
519
 
520
    mov  ebx, [gbxm1_plus_gw_mul_gs]
521
    shl  ebx, 16
522
    add  ebx, [gbxm1_plus_gw_mul_gs]
523
      mcall
524
 
525
    mov  ecx, [gbym1_plus_gh_mul_gs]
526
    sub  ecx, [g_e]
527
    shl  ecx, 16
528
    add  ecx, [gbym1_plus_gh_mul_gs]
529
      mcall
530
 
531
    mov  ebx, [gbxm1_shl16_gbxm1]
532
      mcall
533
 
1518 dunkaist 534
    ret
535
 
536
 
537
  corners_outer:
538
 
1522 dunkaist 539
    mov  eax, 38
540
    mov  ebx, [gbxm1_shl16_gbxm1]
541
    sub  ebx, [g_e]
542
    mov  ecx, [gbym1_shl16_gbym1]
543
    mov  edx, [decorations_color]
544
      mcall
1518 dunkaist 545
 
1522 dunkaist 546
    mov  ecx, [gbym1_plus_gh_mul_gs]
547
    shl  ecx, 16
548
    add  ecx, [gbym1_plus_gh_mul_gs]
549
      mcall
550
 
551
    mov  ebx, [gbxm1_plus_gw_mul_gs]
552
    shl  ebx, 16
553
    add  ebx, [gbxm1_plus_gw_mul_gs]
554
    add  ebx, [g_e]
555
      mcall
556
 
557
    mov  ecx, [gbym1_shl16_gbym1]
558
      mcall
559
 
560
    mov  ebx, [gbxm1_shl16_gbxm1]
561
    mov  ecx, [gbym1_shl16_gbym1]
562
    sub  ecx, [g_e]
563
      mcall
564
 
565
    mov  ebx, [gbxm1_plus_gw_mul_gs]
566
    shl  ebx, 16
567
    add  ebx, [gbxm1_plus_gw_mul_gs]
568
      mcall
569
 
570
    mov  ecx, [gbym1_plus_gh_mul_gs]
571
    shl  ecx, 16
572
    add  ecx, [gbym1_plus_gh_mul_gs]
573
    add  ecx, [g_e]
574
      mcall
575
 
576
    mov  ebx, [gbxm1_shl16_gbxm1]
577
      mcall
578
 
1518 dunkaist 579
    ret
580
 
581
 
582
  corners_crosses:
583
 
584
      call      corners_inner
585
      call      corners_outer
586
 
587
    ret
588
 
589
 
590
    ;;---Draw_decorations--------------------------------------------------------------------------------------------------
591
 
592
 
593
Draw_square:
594
    ;;===Draw_square=======================================================================================================
595
    ;; bl   -   x_coord
596
    ;; bh   -   y_coord
597
    ;; edx  -   color
598
 
599
    mov  cl,  bh
600
 
1522 dunkaist 601
    mov  al,  byte[g_s]
1518 dunkaist 602
    mul  bl
603
    mov  bx,  ax
1522 dunkaist 604
    add  bx,  word[gbxm1]
605
    inc  bx
1518 dunkaist 606
    shl  ebx, 16
1522 dunkaist 607
    add  ebx, [g_s]
608
    dec  ebx
1518 dunkaist 609
 
1522 dunkaist 610
    mov  al,  byte[g_s]
1518 dunkaist 611
    mul  cl
612
    mov  cx,  ax
1522 dunkaist 613
    add  cx,  word[gbym1]
614
    inc  cx
1518 dunkaist 615
    shl  ecx, 16
1522 dunkaist 616
    add  ecx, [g_s]
617
    dec  ecx
1518 dunkaist 618
 
619
      mcall     13
620
 
621
    ret
622
 
623
    ;;---Draw_square-------------------------------------------------------------------------------------------------------
624
 
625
 
626
Draw_menu_esc:
627
    ;;===Draw_menu_esc=====================================================================================================
628
 
1522 dunkaist 629
    mov  ebx, [window_width]
630
    shr  ebx, 1
631
    sub  ebx, (string_apply_name_enter-string_menu_esc-1)*3+6
632
    shl  ebx, 16
633
    add  ebx, dword[top_strings]
634
      mcall     4, ,[navigation_strings_color],string_menu_esc
1518 dunkaist 635
 
636
    ret
637
 
638
    ;;---Draw_menu_esc-----------------------------------------------------------------------------------------------------
639
 
640
 
641
Draw_score_string:
642
    ;;===Draw_score_string=================================================================================================
1522 dunkaist 643
 
644
    mov  ebx, [window_width]
645
    shr  ebx, 3
646
    sub  ebx, 5
647
    shl  ebx, 16
648
    add  ebx, dword[bottom_top_strings]
649
      mcall     4, ,[score_string_color],string_score
1518 dunkaist 650
 
651
    ret
652
 
653
    ;;---Draw_score_string-------------------------------------------------------------------------------------------------
654
 
655
 
656
Draw_score_number:
657
    ;;===Draw_score_number=================================================================================================
1522 dunkaist 658
 
659
    mov  edx, [window_width]
660
    shr  edx, 3
661
    sub  edx, 6
662
    add  edx, (string_hi_score-string_score)*6
663
    shl  edx, 16
664
    add  edx, dword[bottom_top_strings]
665
      mcall     47,0x00070000,[score], ,[score_number_color],[background_color]
1518 dunkaist 666
 
667
    ret
668
 
669
    ;;---Draw_score_number-------------------------------------------------------------------------------------------------
670
 
671
 
672
Draw_hiscore_string:
673
    ;;===Draw_hiscore_string===============================================================================================
674
 
1522 dunkaist 675
    mov  ebx, [window_width]
676
    shr  ebx, 3
677
    neg  ebx
678
    add  ebx, [window_width]
679
    sub  ebx, (string_player-string_hi_score)*6+7*6+5
680
    shl  ebx, 16
681
    add  ebx, dword[bottom_top_strings]
682
      mcall     4, ,[hiscore_string_color],string_hi_score
1518 dunkaist 683
 
684
    ret
685
 
686
    ;;---Draw_hiscore_string-----------------------------------------------------------------------------------------------
687
 
688
 
689
Draw_hiscore_number:
690
    ;;===Draw_hiscore_number===============================================================================================
691
 
1522 dunkaist 692
    mov  edx, [window_width]
693
    shr  edx, 3
694
    neg  edx
695
    add  edx, [window_width]
696
    sub  edx, 7*6+6
697
    shl  edx, 16
698
    add  edx, dword[bottom_top_strings]
699
      mcall     47,0x00070000,[hi_score], ,[hiscore_number_color]
1518 dunkaist 700
 
701
    ret
702
 
703
    ;;---Draw_hiscore_number-----------------------------------------------------------------------------------------------
704
 
705
 
706
Draw_champion_string:
707
    ;;===Draw_champion_string==============================================================================================
708
 
1522 dunkaist 709
    mov  ebx, [window_width]
710
    shr  ebx, 3
711
    neg  ebx
712
    add  ebx, [window_width]
713
    sub  ebx, (string_level-string_champion)*6+7*6+5
714
    shl  ebx, 16
715
    add  ebx, dword[bottom_bottom_strings]
716
      mcall     4, ,[champion_string_color],string_champion
1518 dunkaist 717
 
718
    ret
719
 
720
    ;;---Draw_champion_string----------------------------------------------------------------------------------------------
721
 
722
 
723
Draw_champion_name:
724
    ;;===Draw_champion_name================================================================================================
725
 
1522 dunkaist 726
    mov  ebx, [window_width]
727
    shr  ebx, 3
728
    neg  ebx
729
    add  ebx, [window_width]
730
    sub  ebx, (press_to_start-champion_name)*6+7*6+6
731
    add  ebx, (press_to_start-champion_name)*6
732
    shl  ebx, 16
733
    add  ebx, dword[bottom_bottom_strings]
734
      mcall     4, ,[champion_name_color],champion_name
1518 dunkaist 735
 
736
    ret
737
 
738
    ;;---Draw_champion_name------------------------------------------------------------------------------------------------
739
 
740
 
741
Draw_picture:
742
    ;;===Draw_picture======================================================================================================
743
    ;;  in  :
1522 dunkaist 744
    ;;           ax =   number of left square *0x100+ picture width (in squares)
745
    ;;           cx =   number of top square *0x100+ picture height (in squares)
1518 dunkaist 746
    ;;          edx =   picture color
1522 dunkaist 747
    ;;          esi =   pointer to picture data
1518 dunkaist 748
    ;;
749
 
1522 dunkaist 750
    add  al,  ah
751
    add  cl,  ch
752
    mov  bh,  ch
753
 
1518 dunkaist 754
  .draw:
1522 dunkaist 755
    mov  bl,  ah
1518 dunkaist 756
 
757
  .loop:
1522 dunkaist 758
    cmp  byte[esi], 0
1518 dunkaist 759
     jz  @f
1522 dunkaist 760
    push eax ebx ecx esi
1518 dunkaist 761
      call      Draw_square
1522 dunkaist 762
    pop  esi ecx ebx eax
1518 dunkaist 763
 
764
  @@:
1522 dunkaist 765
    inc  esi
1518 dunkaist 766
    inc  bl
1522 dunkaist 767
    cmp  bl,  al
1518 dunkaist 768
     jne .loop
769
 
1522 dunkaist 770
    inc  bh
771
    cmp  bh,  cl
772
     jne .draw
1518 dunkaist 773
    ret
774
 
775
    ;;---Draw_picture------------------------------------------------------------------------------------------------------
776
 
777
 
778
Draw_on_map:
779
    ;;===Draw_on_map=======================================================================================================
780
    ;;  in  :
781
    ;;           al =   x coord
782
    ;;           ah =   y coord
783
    ;;           cl =   value to draw
784
    ;;
785
 
786
    and  eax, 0x0000ffff
787
    xor  bx,  bx
788
    mov  bl,  al
789
    shr  ax,  8
1522 dunkaist 790
    mov  dx,  word[g_w]
1518 dunkaist 791
    mul  dx
792
    add  ax,  bx
793
    mov  edi, field_map
794
    add  edi, eax
795
    mov  [edi], cl
796
 
797
    ret
798
 
799
    ;;---Draw_on_map-------------------------------------------------------------------------------------------------------
800
 
801
 
802
Get_from_map:
803
    ;;===Get_from_map======================================================================================================
804
    ;;  in  :
805
    ;;           al =   x coord
806
    ;;           ah =   y coord
807
    ;;  out :
1522 dunkaist 808
    ;;           bl =   value on map
1518 dunkaist 809
    ;;
810
 
811
    push eax
812
 
813
    and  eax, 0x0000ffff
814
    xor  bx,  bx
815
    mov  bl,  al
816
    shr  ax,  8
1522 dunkaist 817
    mov  dx,  word[g_w]
1518 dunkaist 818
    mul  dx
819
    add  ax,  bx
820
    mov  edi, field_map
821
    add  edi, eax
822
    mov  bl,  [edi]
823
 
824
    pop  eax
825
 
826
    ret
827
 
828
    ;;---Get_from_map------------------------------------------------------------------------------------------------------
829
 
830
 
831
;;---Some_functions--------------------------------------------------------------------------------------------------------
832
 
833
 
834
;;===Variables=============================================================================================================
835
 
836
window_title                db      'Snake',0
837
window_style                dd      0x34000000
838
time_before_waiting         dd      0x0
839
time_to_wait                dd      0x0
840
time_wait_limit             dd      101
841
 
842
 
1522 dunkaist 843
gbxm1                       dd      30
844
gbym1                       dd      30
845
g_w                         dd      29
846
g_h                         dd      15
847
g_e                         dd      13
848
 
849
field_map                   db      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
850
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
851
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
852
                                    0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
853
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
854
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
855
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
856
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
857
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
858
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
859
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
860
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
861
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
862
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
863
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
864
 
1518 dunkaist 865
string_score                db      'SCORE :',0
866
string_hi_score             db      'HI-SCORE :',0
867
string_player               db      'PLAYER :',0
868
string_champion             db      'CHAMPION :',0
869
string_level                db      'LEVEL :',0
870
string_pause_space          db      'PAUSE - ',0x27,'SPACE',0x27,0
871
string_resume_space         db      'RESUME - ',0x27,'SPACE',0x27,0
872
string_menu_esc             db      'MENU - ',0x27,'ESC',0x27,0
873
string_apply_name_enter     db      'APPLY NAME - ',0x27,'ENTER',0x27,0
1522 dunkaist 874
press_to_start              db      'PRESS ',0x27,'SPACE',0x27,' OR ',0x27,'ENTER',0x27,' TO START',0
1518 dunkaist 875
press_esc_to_exit           db      'PRESS ',0x27,'ESC',0x27,' TO EXIT',0
876
;press_F2_to_options         db      'PRESS ',0x27,'F2',0x27,' TO OPTIONS',0
877
 
1522 dunkaist 878
string_congratulations      db      '   Congratulations!!! New hi-score is :',0
879
string_enter_your_name      db      'You are the champion! Enter your name :',0
880
strings_end:
881
 
882
snake_dots                  db      3,3, 4,3, 5,3,  865    dup (0)
1518 dunkaist 883
snake_napravlenie           db      3
884
snake_napravlenie_next      db      3
885
snake_length_x2             dd      6
886
 
887
score                       dd      0
888
hi_score                    dd      777
889
is_new_record               db      0
890
 
891
action                      db      0
892
 
1522 dunkaist 893
picture_first_menu_snake    db      1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,1,0,0,1,0,0,1,0,0,1,1,1,1,1,\
894
                                    1,0,0,0,0,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,\
895
                                    1,0,0,0,0,0,1,0,1,0,1,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,\
896
                                    1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,1,0,0,0,0,1,1,1,1,0,\
897
                                    0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,\
898
                                    1,1,1,1,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,1,1,0,1,1,1,1,1
1518 dunkaist 899
 
1522 dunkaist 900
picture_first_menu_version  db      1,1,1,1,0,0,0,1,1,1,1,\
901
                                    1,0,0,1,0,0,0,0,0,0,1,\
902
                                    1,0,0,1,0,0,0,0,1,1,1,\
903
                                    1,0,0,1,0,0,0,0,0,0,1,\
904
                                    1,1,1,1,0,1,0,1,1,1,1
1518 dunkaist 905
 
1522 dunkaist 906
picture_pause               db      0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
907
                                    0,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,1,1,0,1,1,1,1,0,0,\
908
                                    0,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,\
909
                                    0,0,1,1,1,1,0,0,1,0,0,1,0,1,0,0,1,0,1,1,1,1,0,1,1,1,0,0,0,\
910
                                    0,0,1,0,0,0,0,0,1,1,1,1,0,1,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,\
911
                                    0,0,1,0,0,0,0,0,1,0,0,1,0,0,1,1,0,0,1,1,1,1,0,1,1,1,1,0,0
1518 dunkaist 912
 
1522 dunkaist 913
picture_game_over           db      0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
914
                                    0,1,0,0,1,0,0,1,1,1,0,0,1,0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,\
915
                                    1,0,0,0,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,\
916
                                    1,0,0,1,1,0,1,0,0,0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,\
917
                                    1,0,0,0,1,0,1,1,1,1,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,\
918
                                    0,1,1,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,\
919
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
920
                                    0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
921
                                    0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,0,1,1,1,1,0,0,\
922
                                    0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,1,0,0,0,1,0,\
923
                                    0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,0,0,1,0,0,0,1,0,\
924
                                    0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,0,1,1,1,1,0,0,\
925
                                    0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,0,0,0,1,1,1,1,0,1,0,0,0,1,0
1518 dunkaist 926
 
1522 dunkaist 927
start_map                   db      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
928
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
929
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
930
                                    0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
931
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
932
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
933
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
934
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
935
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
936
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
937
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
938
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
939
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
940
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
941
                                    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
1518 dunkaist 942
 
943
background_color            dd      0x000000
944
decorations_color           dd      0x00000000
945
snake_color                 dd      0x000000
946
snake_head_color            dd      0x000000
947
snake_picture_color         dd      0x000000
948
version_picture_color       dd      0x000000
949
pause_picture_color         dd      0x000000
950
game_over_picture_color     dd      0x000000
951
eat_color                   dd      0x000000
952
navigation_strings_color    dd      0x80000000
953
game_over_strings_color     dd      0x80000000
954
score_string_color          dd      0x80000000
955
hiscore_string_color        dd      0x80000000
956
champion_string_color       dd      0x80000000
957
game_over_hiscore_color     dd      0x80000000
958
score_number_color          dd      0x40000000
959
hiscore_number_color        dd      0x00000000
960
champion_name_color         dd      0x80000000
961
 
962
align 4
963
@IMPORT:
964
 
965
library \
966
        libini      ,   'libini.obj'        ,\
967
        box_lib     ,   'box_lib.obj'
968
 
969
import  libini,\
970
    ini.get_str     ,   'ini_get_str'       ,\
971
    ini.get_int     ,   'ini_get_int'       ,\
972
    ini.set_str     ,   'ini_set_str'       ,\
973
    ini.set_int     ,   'ini_set_int'       ,\
974
    ini.get_color   ,   'ini_get_color'
975
 
976
import  box_lib,\
977
    edit_box.draw   ,   'edit_box'          ,\
978
    edit_box.key    ,   'edit_box_key'      ,\
979
    edit_box.mouse  ,   'edit_box_mouse'
980
 
981
bFirstDraw  db  0
982
 
983
aPreferences                db      'Preferences',0
984
aSpeed                      db      'Speed',0
1522 dunkaist 985
aSquare_side_length         db      'Square_side_length',0
986
aSpace_between_squares      db      'Space_between_squares',0
987
aTheme                      db      'Theme',0
988
 
989
aTheme_name                 db      32  dup (0)
1518 dunkaist 990
aDecorations                db      'Decorations',0
991
aBackground_color           db      'Background_color',0
992
aDecorations_color          db      'Decorations_color',0
993
aSnake_color                db      'Snake_color',0
994
aSnake_head_color           db      'Snake_head_color',0
995
aSnake_picture_color        db      'Snake_picture_color',0
996
aVersion_picture_color      db      'Version_picture_color',0
997
aPause_picture_color        db      'Pause_picture_color',0
998
aGame_over_picture_color    db      'Game_over_picture_color',0
999
aEat_color                  db      'Eat_color',0
1000
aNavigation_strings_color   db      'Navigation_string_color',0
1001
aGame_over_strings_color    db      'Game_over_string_color',0
1002
aScore_string_color         db      'Score_string_color',0
1003
aHiscore_string_color       db      'Hiscore_string_color',0
1004
aChampion_string_color      db      'Champion_string_color',0
1005
aGame_over_hiscore_color    db      'Game_over_hiscore_color',0
1006
aScore_number_color         db      'Score_number_color',0
1007
aHiscore_number_color       db      'Hiscore_number_color',0
1008
aChampion_name_color        db      'Champion_name_color',0
1520 dunkaist 1009
aEdit_box_selection_color   db      'Edit_box_selection_color',0
1518 dunkaist 1010
 
1522 dunkaist 1011
aScore                      db      'Score',0
1012
aHiscore                    db      'Hiscore',0
1013
aChampion_name              db      'Champion_name',0
1518 dunkaist 1014
 
1522 dunkaist 1015
edit1 edit_box 65,397,0x0,0x000000,0x000000,0x000000,0x000000,0x80000000,15,hed,mouse_dd,ed_focus,hed_end-hed-1,hed_end-hed-1
1016
 
1518 dunkaist 1017
hed                         db      '',0
1522 dunkaist 1018
;;---Variables-------------------------------------------------------------------------------------------------------------
1019
i_end:
1518 dunkaist 1020
hed_end:
1021
rb  256
1022
mouse_dd                    rd      1
1023
 
1522 dunkaist 1024
decorations                 rb      1
1025
number_of_free_dots         rw      1
1026
 
1027
eat                         rb      1
1028
 
1029
square_side_length          rd      1
1030
space_between_squares       rd      1
1031
g_s                         rd      1
1032
 
1033
window_width                rd      1
1034
window_height               rd      1
1035
wp_x                        rd      1
1036
wp_y                        rd      1
1037
 
1038
gw_mul_gh                   rd      1
1039
gw_mul_gs                   rd      1
1040
gh_mul_gs                   rd      1
1041
gbxm1_plus_gw_mul_gs        rd      1
1042
gbym1_plus_gh_mul_gs        rd      1
1043
gs_shl16_gs                 rd      1
1044
gbxm1_shl16_gbxm1           rd      1
1045
gbym1_shl16_gbym1           rd      1
1046
 
1047
bottom_top_strings          rd      1
1048
bottom_middle_strings       rd      1
1049
bottom_bottom_strings       rd      1
1050
top_strings                 rd      1
1051
 
1052
champion_name               rb      16
1053
 
1518 dunkaist 1054
cur_dir_path                rb      4096
1055
@PARAMS                     rb      4096
1056
 
1057
rb 4096
1058
stacktop:
1059
d_end: