Subversion Repositories Kolibri OS

Rev

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