Subversion Repositories Kolibri OS

Rev

Rev 1518 | Rev 1522 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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'
  15. ;include '../../../system/board/trunk/debug.inc'
  16.  
  17. ;;===Define_chapter============================================================================================================
  18.  
  19. WINDOW_WIDTH                equ     550
  20. WINDOW_HEIGHT               equ     320
  21. GRID_STEP                   equ     20
  22. GRID_BEGIN_X                equ     31
  23. GRID_BEGIN_Y                equ     31
  24. GRID_WIDTH                  equ     24
  25. GRID_HEIGHT                 equ     11
  26. GRID_ENDS_WIDTH             equ     13
  27.  
  28. BOTTOM_TOP_STRINGS          equ     270
  29. BOTTOM_MIDDLE_STRINGS       equ     276
  30. BOTTOM_BOTTOM_STRINGS       equ     282
  31. TOP_STRINGS                 equ     5
  32.  
  33. SCORE_EAT                   equ     100
  34.  
  35. LEFT                        equ     0
  36. DOWN                        equ     1
  37. UP                          equ     2
  38. RIGHT                       equ     3
  39.  
  40. ;;---Define_chapter------------------------------------------------------------------------------------------------------------
  41.  
  42. start:
  43.  
  44. stdcall dll.Load,@IMPORT
  45.     or   eax, eax
  46.     jnz  Exit
  47.    
  48. align 4
  49.  
  50.     mov  eax, cur_dir_path
  51.   @@:
  52.     cmp  byte[eax], 0
  53.      jz  @f
  54.     inc  eax
  55.      jmp @b
  56.   @@:
  57.     mov  dword[eax],    '.ini'
  58.  
  59.       invoke  ini.get_int, cur_dir_path, aPreferences, aSpeed, 80
  60.     neg  eax
  61.     add  [time_wait_limit],    eax
  62.       invoke  ini.get_int, cur_dir_path, aPreferences, aDecorations, 2
  63.     mov  [decorations], al
  64.  
  65.       invoke  ini.get_color, cur_dir_path, aColors, aBackground_color, 0x000000
  66.     or   [background_color],    eax
  67.     or   [window_style],    eax
  68.       invoke  ini.get_color, cur_dir_path, aColors, aDecorations_color, 0x00aaaa00
  69.     or   [decorations_color],  eax
  70.       invoke  ini.get_color, cur_dir_path, aColors, aSnake_color, 0x1111ff
  71.     or   [snake_color], eax
  72.       invoke  ini.get_color, cur_dir_path, aColors, aSnake_head_color, 0x1111ff
  73.     or   [snake_head_color], eax
  74.       invoke  ini.get_color, cur_dir_path, aColors, aSnake_picture_color, 0x4488ff
  75.     or   [snake_picture_color], eax
  76.       invoke  ini.get_color, cur_dir_path, aColors, aVersion_picture_color, 0x55ff55
  77.     or   [version_picture_color],   eax
  78.       invoke  ini.get_color, cur_dir_path, aColors, aPause_picture_color, 0x11ff11
  79.     or   [pause_picture_color], eax
  80.       invoke  ini.get_color, cur_dir_path, aColors, aGame_over_picture_color, 0xff1111
  81.     or   [game_over_picture_color], eax
  82.       invoke  ini.get_color, cur_dir_path, aColors, aEat_color, 0xffff11
  83.     or   [eat_color],   eax
  84.       invoke  ini.get_color, cur_dir_path, aColors, aNavigation_strings_color, 0x80ff7777
  85.     or   [navigation_strings_color], eax
  86.       invoke  ini.get_color, cur_dir_path, aColors, aGame_over_strings_color, 0x80ff9900
  87.     or   [game_over_strings_color],  eax
  88.       invoke  ini.get_color, cur_dir_path, aColors, aScore_string_color, 0x80ffffff
  89.     or   [score_string_color],   eax
  90.       invoke  ini.get_color, cur_dir_path, aColors, aHiscore_string_color, 0x80ffffff
  91.     or   [hiscore_string_color],   eax
  92.       invoke  ini.get_color, cur_dir_path, aColors, aChampion_string_color, 0x80ffffff
  93.     or   [champion_string_color],   eax
  94.       invoke  ini.get_color, cur_dir_path, aColors, aGame_over_hiscore_color, 0x80ffdd44
  95.     or   [game_over_hiscore_color], eax
  96.       invoke  ini.get_color, cur_dir_path, aColors, aScore_number_color, 0xffffff
  97.     or   [score_number_color],   eax
  98.       invoke  ini.get_color, cur_dir_path, aColors, aHiscore_number_color, 0x00ffffff
  99.     or   [hiscore_number_color],   eax
  100.       invoke  ini.get_color, cur_dir_path, aColors, aChampion_name_color, 0x80ffffff
  101.     or   [champion_name_color],   eax
  102.       invoke  ini.get_color, cur_dir_path, aColors, aEdit_box_selection_color, 0x00aa00
  103.     or   [edit1+0x10],  eax
  104.  
  105.     mov  eax, [background_color]
  106.     mov  [edit1+0x0C],  eax
  107.     mov  [edit1+0x14],  eax
  108.     mov  [edit1+0x18],  eax
  109.     mov  eax, [game_over_hiscore_color]
  110.     mov  [edit1+0x1C],  eax
  111.  
  112. include 'first_menu.asm'            ; First menu body and functions
  113. include 'level.asm'                 ; Level body and functions (game process)
  114. include 'pause.asm'                 ; Pause body and functions
  115. include 'game_over.asm'             ; Game_over body and functions
  116.  
  117. ;;===Some_functions============================================================================================================
  118.  
  119. Exit:
  120.     ;;===Exit==============================================================================================================
  121.  
  122.     or  eax,    -1
  123.     int 0x40
  124.    
  125.     ;;---Exit--------------------------------------------------------------------------------------------------------------
  126.    
  127.    
  128. Draw_decorations:
  129.     ;;===Draw_decorations==================================================================================================
  130.  
  131.     cmp  [decorations], 1
  132.      je  grid_lines
  133.     cmp  [decorations], 2
  134.      je  grid_lines_with_ends
  135.     cmp  [decorations], 3
  136.      je  grid_lines_with_corners
  137.     cmp  [decorations], 4
  138.      je  grid_dots
  139.     cmp  [decorations], 5
  140.      je  borders_lines
  141.     cmp  [decorations], 6
  142.      je  borders_lines_with_ends
  143.     cmp  [decorations], 7
  144.      je  borders_dots
  145.     cmp  [decorations], 8
  146.      je  corners_dots
  147.     cmp  [decorations], 9
  148.      je  corners_inner
  149.     cmp  [decorations], 10
  150.      je  corners_outer
  151.     cmp  [decorations], 11
  152.      je  corners_crosses
  153.     ret
  154.  
  155.  
  156.   grid_lines:
  157.  
  158.     mov  eax, 38
  159.     mov  ebx, (GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1)
  160.     mov  ecx, (GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP)
  161.     mov  edx, [decorations_color]
  162.  
  163.   @@:
  164.       mcall
  165.     add  ebx, GRID_STEP*65536+GRID_STEP
  166.     cmp  ebx, (GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP)*65536+(GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP)
  167.      jng @b
  168.  
  169.     mov  ebx, (GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP)
  170.     mov  ecx, (GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1)
  171.    
  172.   @@:
  173.       mcall
  174.     add  ecx, GRID_STEP*65536+GRID_STEP
  175.     cmp  ecx, (GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP)*65536+(GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP)
  176.      jng @b
  177.  
  178.     ret
  179.  
  180.  
  181.   grid_lines_with_ends:
  182.  
  183.     mov  eax, 38
  184.     mov  ebx, (GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1)
  185.     mov  ecx, (GRID_BEGIN_Y-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP+GRID_ENDS_WIDTH)
  186.     mov  edx, [decorations_color]
  187.  
  188.   @@:
  189.       mcall
  190.     add  ebx, GRID_STEP*65536+GRID_STEP
  191.     cmp  ebx, (GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP)*65536+(GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP)
  192.      jng @b
  193.  
  194.     mov  ebx, (GRID_BEGIN_X-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP+GRID_ENDS_WIDTH)
  195.     mov  ecx, (GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1)
  196.    
  197.   @@:
  198.       mcall
  199.     add  ecx, GRID_STEP*65536+GRID_STEP
  200.     cmp  ecx, (GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP)*65536+(GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP)
  201.      jng @b
  202.  
  203.     ret
  204.  
  205.  
  206.   grid_lines_with_corners:
  207.  
  208.       call      grid_lines
  209.       call      corners_outer
  210.  
  211.     ret
  212.  
  213.  
  214.   grid_dots:
  215.  
  216.     mov  eax, 1
  217.     mov  ebx, GRID_BEGIN_X-1
  218.     mov  ecx, GRID_BEGIN_Y-1
  219.     mov  edx, [decorations_color]
  220.  
  221.   @@:
  222.       mcall
  223.     add  ebx, GRID_STEP
  224.     cmp  ebx, GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1
  225.      jng @b
  226.     add  ecx, GRID_STEP
  227.     cmp  ecx, GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1
  228.      jg  @f
  229.     mov  ebx, GRID_BEGIN_X-1
  230.      jmp @b
  231.  
  232.   @@:
  233.     ret
  234.  
  235.  
  236.   borders_lines:
  237.  
  238.       mcall     38,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1),17*65536+263,[decorations_color]
  239.       mcall       ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1), ,
  240.       mcall       ,17*65536+523,(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1)
  241.       mcall       ,17*65536+523,(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)
  242.  
  243.     ret
  244.  
  245.  
  246.   borders_lines_with_ends:
  247.  
  248.       call      borders_lines
  249.       call      corners_outer
  250.  
  251.     ret
  252.  
  253.  
  254.   borders_dots:
  255.  
  256.     mov  eax, 1
  257.     mov  ebx, GRID_BEGIN_X-1
  258.     mov  ecx, GRID_BEGIN_Y-1
  259.     mov  edx, [decorations_color]
  260.   @@:
  261.       mcall
  262.     add  ebx, GRID_STEP
  263.     cmp  ebx, GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP
  264.      jng @b
  265.  
  266.     mov  ebx, GRID_BEGIN_X-1
  267.     mov  ecx, GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP
  268.   @@:
  269.       mcall
  270.     add  ebx, GRID_STEP
  271.     cmp  ebx, GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP
  272.      jng @b
  273.  
  274.     mov  ebx, GRID_BEGIN_X-1
  275.     mov  ecx, GRID_BEGIN_Y-1
  276.   @@:
  277.       mcall
  278.     add  ecx, GRID_STEP
  279.     cmp  ecx, GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP
  280.      jng @b
  281.  
  282.     mov  ebx, GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP
  283.     mov  ecx, GRID_BEGIN_Y-1
  284.   @@:
  285.       mcall
  286.     add  ecx, GRID_STEP
  287.     cmp  ecx, GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP
  288.      jng @b
  289.  
  290.     ret
  291.  
  292.  
  293.   corners_dots:
  294.  
  295.       mcall     13,(GRID_BEGIN_X-2)*65536+2,(GRID_BEGIN_Y-2)*65536+2,[decorations_color]
  296.       mcall       ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+2,(GRID_BEGIN_Y-2)*65536+2,
  297.       mcall     13,(GRID_BEGIN_X-2)*65536+2,(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+2,
  298.       mcall       ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+2,(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+2,
  299.  
  300.     ret
  301.  
  302.  
  303.   corners_inner:
  304.  
  305.       mcall     38,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1+GRID_ENDS_WIDTH),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1),[decorations_color]
  306.       mcall       ,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1+GRID_ENDS_WIDTH),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1),
  307.       mcall       ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-GRID_ENDS_WIDTH-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1),
  308.       mcall       ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-GRID_ENDS_WIDTH-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1),
  309.       mcall       ,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1+GRID_ENDS_WIDTH),
  310.       mcall       ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1+GRID_ENDS_WIDTH),
  311.       mcall       ,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-GRID_ENDS_WIDTH-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1),
  312.       mcall       ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-GRID_ENDS_WIDTH-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1),
  313.  
  314.     ret
  315.  
  316.  
  317.   corners_outer:
  318.  
  319.       mcall     38,(GRID_BEGIN_X-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1),[decorations_color]
  320.       mcall       ,(GRID_BEGIN_X-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1),
  321.       mcall       ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1+GRID_ENDS_WIDTH),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1),
  322.       mcall       ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1+GRID_ENDS_WIDTH),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1),
  323.       mcall       ,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_Y-1),
  324.       mcall       ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_Y-1),
  325.       mcall       ,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1+GRID_ENDS_WIDTH),
  326.       mcall       ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1+GRID_ENDS_WIDTH),
  327.  
  328.     ret
  329.  
  330.  
  331.   corners_crosses:
  332.  
  333.       call      corners_inner
  334.       call      corners_outer
  335.  
  336.     ret
  337.  
  338.  
  339.     ;;---Draw_decorations--------------------------------------------------------------------------------------------------
  340.  
  341.  
  342. Draw_square:
  343.     ;;===Draw_square=======================================================================================================
  344.     ;; bl   -   x_coord
  345.     ;; bh   -   y_coord
  346.     ;; edx  -   color
  347.  
  348.     mov  cl,  bh
  349.  
  350.     mov  al,  20
  351.     mul  bl
  352.     mov  bx,  ax
  353.     add  bx,  31
  354.     shl  ebx, 16
  355.     add  ebx, 19
  356.  
  357.     mov  al,  20
  358.     mul  cl
  359.     mov  cx,  ax
  360.     add  cx,  31
  361.     shl  ecx, 16
  362.     add  ecx, 19
  363.        
  364.       mcall     13
  365.  
  366.     ret
  367.  
  368.     ;;---Draw_square-------------------------------------------------------------------------------------------------------
  369.    
  370.    
  371. Draw_menu_esc:
  372.     ;;===Draw_menu_esc=====================================================================================================
  373.  
  374.       mcall     4,234*65536+TOP_STRINGS,[navigation_strings_color],string_menu_esc
  375.    
  376.     ret
  377.    
  378.     ;;---Draw_menu_esc-----------------------------------------------------------------------------------------------------
  379.  
  380.  
  381. Draw_score_string:
  382.     ;;===Draw_score_string=================================================================================================
  383.    
  384.       mcall     4,56*65536+BOTTOM_TOP_STRINGS,[score_string_color],string_score
  385.      
  386.     ret
  387.    
  388.     ;;---Draw_score_string-------------------------------------------------------------------------------------------------
  389.    
  390.    
  391. Draw_score_number:
  392.     ;;===Draw_score_number=================================================================================================
  393.    
  394.       mcall     47,0x00070000,[score],104*65536+BOTTOM_TOP_STRINGS,[score_number_color],[background_color]
  395.        
  396.     ret
  397.        
  398.     ;;---Draw_score_number-------------------------------------------------------------------------------------------------
  399.  
  400.  
  401. Draw_hiscore_string:
  402.     ;;===Draw_hiscore_string===============================================================================================
  403.  
  404.       mcall     4,376*65536+BOTTOM_TOP_STRINGS,[hiscore_string_color],string_hi_score
  405.    
  406.     ret
  407.    
  408.     ;;---Draw_hiscore_string-----------------------------------------------------------------------------------------------
  409.  
  410.    
  411. Draw_hiscore_number:
  412.     ;;===Draw_hiscore_number===============================================================================================
  413.  
  414.       mcall     47,0x00070000,[hi_score],442*65536+BOTTOM_TOP_STRINGS,[hiscore_number_color]
  415.    
  416.     ret
  417.    
  418.     ;;---Draw_hiscore_number-----------------------------------------------------------------------------------------------
  419.    
  420.    
  421. Draw_champion_string:
  422.     ;;===Draw_champion_string==============================================================================================
  423.  
  424.       mcall     4,376*65536+BOTTOM_BOTTOM_STRINGS,[champion_string_color],string_champion
  425.  
  426.     ret
  427.  
  428.     ;;---Draw_champion_string----------------------------------------------------------------------------------------------
  429.  
  430.  
  431. Draw_champion_name:
  432.     ;;===Draw_champion_name================================================================================================
  433.  
  434.       mcall     4,442*65536+BOTTOM_BOTTOM_STRINGS,[champion_name_color],champion_name
  435.  
  436.     ret
  437.  
  438.     ;;---Draw_champion_name------------------------------------------------------------------------------------------------
  439.  
  440.  
  441. Draw_picture:
  442.     ;;===Draw_picture======================================================================================================
  443.     ;;  in  :
  444.     ;;           al =   picture height (in squares)
  445.     ;;           bh =   number of top square
  446.     ;;          ecx =   pointer to picture data
  447.     ;;          edx =   picture color
  448.     ;;
  449.  
  450.   .draw:
  451.     xor  bl,  bl
  452.    
  453.   .loop:
  454.     cmp  byte[ecx], 0
  455.      jz  @f
  456.     push eax ebx ecx
  457.       call      Draw_square
  458.     pop  ecx ebx eax
  459.    
  460.   @@:
  461.     inc  ecx
  462.     inc  bl
  463.     cmp  bl,  GRID_WIDTH
  464.      jne .loop
  465.    
  466.     dec  al
  467.     test al,  al
  468.      jnz @f
  469.     ret
  470.   @@:
  471.     inc  bh
  472.      jmp .draw
  473.    
  474.  
  475.     ;;---Draw_picture------------------------------------------------------------------------------------------------------
  476.  
  477.  
  478. Draw_on_map:
  479.     ;;===Draw_on_map=======================================================================================================
  480.     ;;  in  :
  481.     ;;           al =   x coord
  482.     ;;           ah =   y coord
  483.     ;;           cl =   value to draw
  484.     ;;
  485.  
  486.     and  eax, 0x0000ffff
  487.     xor  bx,  bx
  488.     mov  bl,  al
  489.     shr  ax,  8
  490.     mov  dx,  24
  491.     mul  dx
  492.     add  ax,  bx
  493.     mov  edi, field_map
  494.     add  edi, eax
  495.     mov  [edi], cl
  496.  
  497.     ret
  498.  
  499.     ;;---Draw_on_map-------------------------------------------------------------------------------------------------------
  500.  
  501.  
  502. Get_from_map:
  503.     ;;===Get_from_map======================================================================================================
  504.     ;;  in  :
  505.     ;;           al =   x coord
  506.     ;;           ah =   y coord
  507.     ;;  out :
  508.     ;;           al =   value on map
  509.     ;;
  510.  
  511.     push eax
  512.    
  513.     and  eax, 0x0000ffff
  514.     xor  bx,  bx
  515.     mov  bl,  al
  516.     shr  ax,  8
  517.     mov  dx,  24
  518.     mul  dx
  519.     add  ax,  bx
  520.     mov  edi, field_map
  521.     add  edi, eax
  522.     mov  bl,  [edi]
  523.  
  524.     pop  eax
  525.  
  526.     ret
  527.  
  528.     ;;---Get_from_map------------------------------------------------------------------------------------------------------
  529.  
  530.  
  531. ;;---Some_functions--------------------------------------------------------------------------------------------------------
  532.  
  533.  
  534. ;;===Variables=============================================================================================================
  535.  
  536. window_title                db      'Snake',0
  537. window_style                dd      0x34000000
  538. time_before_waiting         dd      0x0
  539. time_to_wait                dd      0x0
  540. time_wait_limit             dd      101
  541. decorations                 db      0x0
  542. number_of_free_dots         dw      0x0
  543.  
  544. 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,\
  545.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  546.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  547.                                     0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  548.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  549.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  550.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  551.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  552.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  553.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  554.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  555.  
  556. string_score                db      'SCORE :',0
  557. string_hi_score             db      'HI-SCORE :',0
  558. string_player               db      'PLAYER :',0
  559. string_champion             db      'CHAMPION :',0
  560. string_level                db      'LEVEL :',0
  561. string_pause_space          db      'PAUSE - ',0x27,'SPACE',0x27,0
  562. string_resume_space         db      'RESUME - ',0x27,'SPACE',0x27,0
  563. string_menu_esc             db      'MENU - ',0x27,'ESC',0x27,0
  564. string_apply_name_enter     db      'APPLY NAME - ',0x27,'ENTER',0x27,0
  565.  
  566. champion_name               db      'dunkaist',0x20,0x20,0x20,0x20,0x20,0x20,0x20,0
  567.  
  568. press_to_start              db      '...PRESS ',0x27,'SPACE',0x27,' OR ',0x27,'ENTER',0x27,' TO START...',0
  569. press_esc_to_exit           db      'PRESS ',0x27,'ESC',0x27,' TO EXIT',0
  570. ;press_F2_to_options         db      'PRESS ',0x27,'F2',0x27,' TO OPTIONS',0
  571.  
  572. snake_dots                  db      3,3, 4,3, 5,3,  522  dup (0)     ; 264 dots
  573. snake_napravlenie           db      3
  574. snake_napravlenie_next      db      3
  575. snake_length_x2             dd      6
  576.  
  577. eat                         db      0,0
  578.  
  579. score                       dd      0
  580. hi_score                    dd      777
  581. is_new_record               db      0
  582.  
  583. action                      db      0
  584.  
  585. string_congratulations      db      'Congratulations!!! You are the champion!! New hi-score is :',0
  586. string_enter_your_name      db      'Enter your name, please :',0
  587.  
  588. picture_first_menu_snake    db      1,1,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,1,1,\
  589.                                     1,0,0,0,0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,0,1,\
  590.                                     1,1,1,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,0,1,1,1,1,\
  591.                                     0,0,0,1,0,1,0,1,1,0,1,1,1,1,0,1,0,1,0,0,1,0,0,0,\
  592.                                     1,1,1,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,1,1,1
  593.  
  594. picture_first_menu_version  db      0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,\
  595.                                     0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,\
  596.                                     0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,\
  597.                                     0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0,0,0,0,0,0,0,0
  598.  
  599. picture_pause               db      1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,1,1,0,1,1,1,1,\
  600.                                     1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,0,1,0,0,0,\
  601.                                     1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,0,1,0,0,0,\
  602.                                     1,1,1,0,0,1,1,1,1,0,1,0,0,1,0,1,1,1,1,0,1,1,1,0,\
  603.                                     1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,0,1,0,1,0,0,0,\
  604.                                     1,0,0,0,0,1,0,0,1,0,0,1,1,0,0,1,1,1,1,0,1,1,1,1
  605.  
  606. picture_game_over           db      0,0,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,1,1,1,1,0,\
  607.                                     0,1,0,0,1,0,0,1,0,1,0,0,1,1,0,1,1,0,1,0,0,0,0,0,\
  608.                                     1,0,0,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,0,0,\
  609.                                     1,0,0,1,0,0,1,1,1,1,1,0,1,0,0,0,1,0,1,0,0,0,0,0,\
  610.                                     0,1,1,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,1,0,\
  611.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  612.                                     0,0,1,1,1,0,0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,0,\
  613.                                     0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,\
  614.                                     0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,0,0,1,0,0,0,1,\
  615.                                     0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,\
  616.                                     0,0,1,1,1,0,0,0,0,1,0,0,0,1,1,1,1,1,0,1,0,0,0,1
  617.  
  618. 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,\
  619.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  620.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  621.                                     0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  622.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  623.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  624.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  625.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  626.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  627.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
  628.                                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  629.  
  630. background_color            dd      0x000000
  631. decorations_color           dd      0x00000000
  632. snake_color                 dd      0x000000
  633. snake_head_color            dd      0x000000
  634. snake_picture_color         dd      0x000000
  635. version_picture_color       dd      0x000000
  636. pause_picture_color         dd      0x000000
  637. game_over_picture_color     dd      0x000000
  638. eat_color                   dd      0x000000
  639. navigation_strings_color    dd      0x80000000
  640. game_over_strings_color     dd      0x80000000
  641. score_string_color          dd      0x80000000
  642. hiscore_string_color        dd      0x80000000
  643. champion_string_color       dd      0x80000000
  644. game_over_hiscore_color     dd      0x80000000
  645. score_number_color          dd      0x40000000
  646. hiscore_number_color        dd      0x00000000
  647. champion_name_color         dd      0x80000000
  648.  
  649. align 4
  650. @IMPORT:
  651.  
  652. library \
  653.         libini      ,   'libini.obj'        ,\
  654.         box_lib     ,   'box_lib.obj'
  655.  
  656. import  libini,\
  657.     ini.get_str     ,   'ini_get_str'       ,\
  658.     ini.get_int     ,   'ini_get_int'       ,\
  659.     ini.set_str     ,   'ini_set_str'       ,\
  660.     ini.set_int     ,   'ini_set_int'       ,\
  661.     ini.get_color   ,   'ini_get_color'
  662.  
  663. import  box_lib,\
  664.     edit_box.draw   ,   'edit_box'          ,\
  665.     edit_box.key    ,   'edit_box_key'      ,\
  666.     edit_box.mouse  ,   'edit_box_mouse'
  667.  
  668. bFirstDraw  db  0
  669.  
  670. aScore                      db      'Score',0
  671. aHiscore                    db      'Hiscore',0
  672. aChampion_name              db      'Champion_name',0
  673.  
  674. aPreferences                db      'Preferences',0
  675. aSpeed                      db      'Speed',0
  676. aDecorations                db      'Decorations',0
  677.  
  678. aColors                     db      'Colors',0
  679. aBackground_color           db      'Background_color',0
  680. aDecorations_color          db      'Decorations_color',0
  681. aSnake_color                db      'Snake_color',0
  682. aSnake_head_color           db      'Snake_head_color',0
  683. aSnake_picture_color        db      'Snake_picture_color',0
  684. aVersion_picture_color      db      'Version_picture_color',0
  685. aPause_picture_color        db      'Pause_picture_color',0
  686. aGame_over_picture_color    db      'Game_over_picture_color',0
  687. aEat_color                  db      'Eat_color',0
  688. aNavigation_strings_color   db      'Navigation_string_color',0
  689. aGame_over_strings_color    db      'Game_over_string_color',0
  690. aScore_string_color         db      'Score_string_color',0
  691. aHiscore_string_color       db      'Hiscore_string_color',0
  692. aChampion_string_color      db      'Champion_string_color',0
  693. aGame_over_hiscore_color    db      'Game_over_hiscore_color',0
  694. aScore_number_color         db      'Score_number_color',0
  695. aHiscore_number_color       db      'Hiscore_number_color',0
  696. aChampion_name_color        db      'Champion_name_color',0
  697. aEdit_box_selection_color   db      'Edit_box_selection_color',0
  698.  
  699. edit1 edit_box 100,397,278,0x000000,0x000000,0x000000,0x000000,0x80000000,15,hed,mouse_dd,ed_focus,hed_end-hed-1,hed_end-hed-1
  700.  
  701. hed                         db      '',0
  702. hed_end:
  703. rb  256
  704.  
  705. mouse_dd                    rd      1
  706.  
  707. i_end:
  708. cur_dir_path                rb      4096
  709. @PARAMS                     rb      4096
  710. ;;---Variables-------------------------------------------------------------------------------------------------------------
  711.  
  712. rb 4096
  713. stacktop:
  714. d_end: