Subversion Repositories Kolibri OS

Rev

Rev 5916 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;
  2. ; äã­ªæ¨ ¤«ï ᮧ¤ ­¨ï ¨ । ªâ¨à®¢ ­¨ï ¯à®¢®¤®¢
  3. ;
  4.  
  5. ;--------------------------------------
  6. struct Cell
  7.         x dd ? ;+0
  8.         y dd ? ;+4
  9.         liv db ? ;+8
  10.         napr db ? ;+9
  11. ends
  12.  
  13. offs_cell_x equ 0
  14. offs_cell_y equ 4
  15. offs_cell_liv equ 8
  16. offs_cell_napr equ 9
  17.  
  18. ;áâàãªâãà  ¤«ï ᮧ¤ ­¨ï ¯®«ï
  19. align 4
  20. pole:
  21. .index dd 0
  22. cell dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì á® áâàãªâãà ¬¨ ï祥ª
  23. .max_cell dd 90000
  24. .b_sort dd 0 ;£à ­¨æ  ¤«ï á®àâ¨à®¢ ­­ëå ï祥ª
  25.  
  26. pole_index    equ dword[edi]
  27. pole_data     equ dword[edi +4] ;㪠§ â¥«ì ­  ¯ ¬ïâì á® áâàãªâãà ¬¨ ï祥ª
  28. pole_max_cell equ dword[edi +8]
  29. pole_b_sort   equ dword[edi+12] ;£à ­¨æ  ¤«ï á®àâ¨à®¢ ­­ëå ï祥ª
  30. offs_pole_b_sort equ 12
  31.  
  32. macro get_cell_offset reg,ind
  33. {
  34.         mov reg,ind
  35.         imul reg,sizeof.Cell
  36.         add reg,dword[cell]
  37. }
  38.  
  39. er_oom db 0 ;­  á«ãç © ¨áç¥à¯ ­¨ï ¯ ¬ïâ¨
  40. Cor_x dd 0
  41. Cor_y dd 0
  42. zoom db 3 ;¬ áèâ ¡ ¯®«ï
  43. txt_zoom db 'Œ áèâ ¡:',0
  44. txt_osob db '’®ç¥ª:',0
  45. txt_info: db ' §¬¥à: '
  46. .size: rb 16
  47. txt_mull db '*',0
  48. txt_space db ' ',0
  49. txt_nl db 13,10,0
  50. txt_buf rb 32
  51.  
  52.  
  53. align 4
  54. proc pole_init uses eax ebx edi, pole:dword
  55.         mov edi,dword[pole]
  56.  
  57.         ;*** ª®¤ á ®¤­®© ®¡« áâìî ¢ ¯ ¬ï⨠***
  58.         mov ebx,4
  59.         add ebx,sizeof.Cell
  60.         imul ebx,pole_max_cell
  61.         stdcall mem.Alloc,ebx
  62.         mov pole_index,eax
  63.  
  64.         mov ebx,pole_max_cell
  65.         shl ebx,2
  66.         add eax,ebx
  67.         mov pole_data,eax
  68.  
  69.         stdcall pole_clear, edi
  70.         stdcall pole_paint, edi ;à¨á®¢ ­¨¥ ¯®«ï ¢ ¡ãä¥à¥ (­¥ ­  íªà ­¥)
  71.         ret
  72. endp
  73.  
  74. align 4
  75. proc pole_delete uses edi, pole:dword
  76.         mov edi,dword[pole]
  77.         stdcall mem.Free,pole_index
  78.         ret
  79. endp
  80.  
  81. ;ç¨á⪠ ¯à®¢®¤®¢ ­  á奬¥
  82. align 4
  83. proc pole_clear uses eax ecx edi, pole:dword
  84.         mov edi,dword[pole]
  85.  
  86.         xor eax,eax
  87.         mov pole_b_sort,eax
  88.         mov byte[er_oom],al
  89.         cld
  90.         mov ecx,pole_max_cell
  91.         imul ecx,sizeof.Cell
  92.         mov edi,pole_data
  93.         repne stosb ;memset(cell,0,sizeof(Cell)*pole_max_cell);
  94.  
  95.         mov edi,dword[pole]
  96.         mov ecx,pole_max_cell
  97.         mov edi,pole_index
  98.         @@:
  99.                 stosd ;for(i=0;i<pole_max_cell;i++) pole_index[i]=i;
  100.                 inc eax
  101.                 loop @b
  102.         ret
  103. endp
  104.  
  105. align 4
  106. proc pole_cell_creat, pole:dword, x:dword, y:dword, li:dword
  107.         pushad
  108.         mov edi,dword[pole]
  109.         mov esi,pole_index
  110.  
  111.         ; *** ¥á«¨ ª«¥âª  㦥 ¡ë«  ᮧ¤ ­ 
  112.         stdcall pole_cell_find, [pole], [x],[y]
  113.         cmp eax,0
  114.         je @f
  115.                 get_cell_offset ebx,eax
  116.                 jmp .change
  117.         @@:
  118.  
  119.         ; *** ᮧ¤ ­¨¥ ­®¢®© ï祩ª¨
  120.         ; ­ å®¤¨¬ ­®¬¥à ᢮¡®¤­®© ï祩ª¨ (i) ¤«ï ¤®¡ ¢«¥­¨ï ­®¢®©
  121.         ;mov esi,pole_index
  122.         inc dword[esi]
  123.         mov ebx,pole_max_cell
  124.         cmp dword[esi],ebx
  125.         jne @f
  126.                 dec dword[esi]
  127.                 ;... need call message: "eror out of memory" ...
  128.                 ;... ¢ë¢®¤ á®®¡é¥­¨ï ¯¥à¥¯®«­¥­¨ï ­ ¤® ¤®¡ ¢¨âì  ...
  129.                 mov byte[er_oom],0
  130.                 jmp .fun_e ;return;
  131.         @@:
  132.         mov eax,dword[esi] ;eax - ­®¬¥à ¤«ï ¯®á«¥¤­¥© ï祩ª¨
  133.         shl eax,2
  134.         add eax,pole_index ;eax - 㪠§ â¥«ì ­  ¤®¡ ¢«ï¥¬ãî ï祩ªã (¢ ª®­¥æ ¬ áᨢ )
  135.         get_cell_offset ebx,dword[eax]
  136.         mov ecx,dword[x]
  137.         mov dword[ebx],ecx ;+0 = .x
  138.         mov edx,dword[y]
  139.         mov dword[ebx+4],edx ;+4 = .y
  140.         .change:
  141.                 mov ecx,[li]
  142.                 mov byte[ebx+offs_cell_liv],cl
  143.         .fun_e:
  144.         popad
  145.         ret
  146. endp
  147.  
  148. ;㤠«¥­¨¥ ï祩ª¨
  149. align 4
  150. proc pole_cell_delete, pole:dword, x:dword, y:dword
  151.         pushad
  152.         mov edi,dword[pole]
  153.         mov ebx,edi
  154.         add ebx,offs_pole_b_sort
  155.         mov esi,pole_index
  156.  
  157.         mov ecx,[esi]
  158.         cmp ecx,1
  159.         jl .fun_e
  160.  
  161.         stdcall pole_cell_find, [pole], [x],[y]
  162.         cmp eax,0
  163.         je .fun_e ;¥á«¨ ª«¥âª  ­¥ ¡ë«  ᮧ¤ ­ 
  164.  
  165.         dec dword[esi]
  166.  
  167.         mov edi,esi
  168.         add edi,4
  169.         mov edx,ecx
  170.         cld
  171.         repnz scasd ;¯®¨áª
  172.         sub edi,4
  173.  
  174.         cmp dword[ebx],1 ;[ebx]=pole_b_sort
  175.         jl @f
  176.         mov eax,edi
  177.         sub eax,esi ;esi=pole_index
  178.         shr eax,2
  179.         dec eax
  180.         cmp [ebx],eax ;eax - ¯®§¨æ¨ï 㪠§ â¥«ï 㤠«ï¥¬®© ï祩ª¨
  181.         jle @f ;¡ë«® jl @f
  182.                 dec dword[ebx]
  183.         @@:
  184.  
  185.         shl edx,2
  186.         add edx,esi ;ª®­¥ç­ë© í«¥¬¥­â ¬ áᨢ 
  187.         sub edx,edi
  188.         shr edx,2
  189.         mov ecx,edx
  190.  
  191.         bt ecx,31
  192.         jc .fun_e
  193.                 mov esi,edi
  194.                 add esi,4
  195.                 mov edx,[edi] ;á®åà ­¥­¨¥ ⥪ã饣® 㪠§ â¥«ï
  196.                 cld
  197.                 rep movsd
  198.                 mov [edi],edx ;¢®ááâ ­®¢«¥­¨¥ ⥪ã饣® 㪠§ â¥«ï (¢ ª®­æ¥ ¬ áᨢ )
  199.         .fun_e:
  200.         popad
  201.         ret
  202. endp
  203.  
  204. if debug
  205. align 4
  206. proc but_test_pole, pole:dword
  207.         pushad
  208.         stdcall [buf2d_clear], buf_0, [buf_0.color]
  209.  
  210.         mov edi,dword[pole]
  211.         stdcall pole_paint,edi
  212.         mov ebx,5
  213.  
  214.         mov esi,pole_index
  215.         mov ecx,[esi]
  216.  
  217.         mov eax,pole_b_sort
  218.         mov edi,open_file_lif
  219.         stdcall convert_int_to_str
  220.         stdcall [buf2d_draw_text], buf_0, buf_font,edi,5,ebx,[shem_colors] ;à¨á㥬 b_sort
  221.         add ebx,18
  222.  
  223.         mov eax,[esi]
  224.         add esi,4
  225.         stdcall convert_int_to_str
  226.         stdcall [buf2d_draw_text], buf_0, buf_font,edi,5,ebx,[shem_colors] ;à¨á㥬 ç¨á«® â®ç¥ª
  227.         add ebx,9
  228.  
  229.         cmp ecx,1
  230.         jl .end_dr
  231.         cld
  232.         @@:
  233.                 mov eax,[esi]
  234.                 add esi,4
  235.                 stdcall convert_int_to_str
  236.                 stdcall [buf2d_draw_text], buf_0, buf_font,edi,5,ebx,[color_captions] ;à¨á㥬 㪠§ â¥«¨ ­  ¬ áᨢë â®ç¥ª
  237.                 add ebx,9
  238.                 loop @b
  239.         .end_dr:
  240.         mov ecx,4
  241.         cld
  242.         @@:
  243.                 mov eax,[esi]
  244.                 add esi,4
  245.                 stdcall convert_int_to_str
  246.                 stdcall [buf2d_draw_text], buf_0, buf_font,edi,5,ebx,[color_border] ;à¨á㥬 4 áâப¨ 㪠§ â¥«¥©
  247.                 add ebx,9
  248.                 loop @b
  249.  
  250.         stdcall [buf2d_draw], buf_0
  251.  
  252.         ;call redraw_pole
  253.         popad
  254.         ret
  255. endp
  256. end if
  257.  
  258. ;output:
  259. ; eax - index
  260. align 4
  261. proc pole_cell_find uses edi, pole:dword, x:dword, y:dword
  262.         mov edi,dword[pole]
  263.  
  264.         mov eax,pole_index
  265.         cmp dword[eax],0
  266.         jne @f
  267.                 xor eax,eax ;if(!fristC) return 0;
  268.                 jmp .fun_e
  269.         @@:
  270.  
  271.         xor eax,eax ;fnd=0;
  272.         cmp pole_b_sort,0
  273.         je @f
  274.                 stdcall pole_bin_find, pole_index, [x],[y], pole_b_sort ;i=BinFind(pole_index, x,y, pole_b_sort);
  275.                 cmp eax,0
  276.                 je @f
  277.                         shl eax,2
  278.                         add eax,pole_index
  279.                         mov eax,dword[eax] ;if(i) fnd=pole_index[i];
  280.                         jmp .fun_e
  281.         @@:
  282.  
  283.         cmp eax,0
  284.         jne @f ;¯®¨áª ï祩ª¨ §  ¡¨­ à­ë¬ ¤¥à¥¢®¬
  285.                 push ebx ecx edx esi
  286.                 ;ebx -> i
  287.                 ;ecx -> firstC
  288.                 ;edx -> &pole_index[i]
  289.                 ;esi -> cell[pole_index[i]]
  290.                 mov ecx,pole_index
  291.                 mov ebx,pole_b_sort
  292.                 mov edx,ebx
  293.                 shl edx,2
  294.                 add edx,ecx
  295.                 mov ecx,dword[ecx]
  296.                 .cycle_b: ;for(i=pole_b_sort+1;i<=fristC;i++)
  297.                         inc ebx
  298.                         cmp ebx,ecx
  299.                         jg .not_found
  300.                         add edx,4
  301.                         get_cell_offset esi,dword[edx]
  302.                         mov eax,dword[x]
  303.                         cmp dword[esi],eax ;+0 = .x
  304.                         jne .if_e
  305.                         mov eax,dword[y]
  306.                         cmp dword[esi+4],eax ;+4 = .y
  307.                         jne .if_e
  308.                                 ;if(cell[pole_index[i]].x==x && cell[pole_index[i]].y==y){
  309.                                 mov eax,dword[edx] ;fnd=pole_index[i];
  310.                                 jmp .cycle_e ;break;
  311.                         .if_e:
  312.                         jmp .cycle_b
  313.                         .not_found:
  314.                 xor eax,eax ;¢®ááâ ­ ¢«¨¢ ¥¬ ­ã«¥¢®¥ §­ ç¥­¨¥ ¥á«¨ ­¥ ­ è«¨ ï祩ªã (¢ 横«¥ eax ¯®àâ¨âáï ¯à¨ ¯à®¢¥àª¥ ª®®à¤¨­ â)
  315.                 .cycle_e:
  316.                 pop esi edx ecx ebx
  317.         @@:
  318.         .fun_e:
  319.         ret
  320. endp
  321.  
  322. ;output:
  323. ; eax - index
  324. align 4
  325. proc pole_bin_find uses ebx ecx edx edi, mas:dword, fx:dword, fy:dword, k:dword
  326.         xor eax,eax
  327.         mov ebx,1 ;ebx - ¬ ªá¨¬ «ì­ë© ¯®à冷ª ¤«ï ¤¥à¥¢ 
  328.         @@:
  329.         cmp dword[k],ebx
  330.         jle @f ;while(k>por)
  331.                 shl ebx,1 ;por<<=1;
  332.                 jmp @b
  333.         @@:
  334.         cmp dword[k],ebx
  335.         jge @f ;if(k<por)
  336.                 shr ebx,1 ;por>>=1;
  337.         @@:
  338.         mov ecx,ebx ;i=por;
  339.  
  340.         ;ecx -> i
  341.         ;edi -> mas[i]
  342.         .cycle_b: ;do{
  343.                 shr ebx,1 ;por>>=1;
  344.  
  345.                 mov edi,ecx
  346.                 shl edi,2
  347.                 add edi,dword[mas]
  348.                 ;if(compare_cells_mb(mas[i],fx,fy)){
  349.                 stdcall pole_compare_cells_mb_coords, dword[edi],[fx],[fy]
  350.                 cmp dl,0
  351.                 je .if_u0_e
  352.                         @@: ;while(i+por>k)
  353.                         mov edx,ecx
  354.                         add edx,ebx
  355.                         cmp edx,dword[k] ;i+por>k
  356.                         jle @f
  357.                                 shr ebx,1 ;por>>=1;
  358.                                 jmp @b
  359.                         @@:
  360.                         add ecx,ebx ;i+=por;
  361.                         jmp .if_e
  362.                 .if_u0_e:
  363.                 ;else if(compare_cells_bm(mas[i],fx,fy))i-=por;
  364.                 stdcall pole_compare_cells_bm_coords, dword[edi],[fx],[fy]
  365.                 cmp dl,0
  366.                 je .if_u1_e
  367.                         sub ecx,ebx
  368.                         jmp .if_e
  369.                 .if_u1_e:
  370.                 ;else { m=i; por=0; }
  371.                         mov eax,ecx
  372.                         xor ebx,ebx
  373.                 .if_e:
  374.         cmp ebx,0
  375.         jne .cycle_b ;}while(por);
  376.  
  377.         ret
  378. endp
  379.  
  380. ;ᤢ¨£ ¢á¥å ï祥ª (¨ ®¡ê¥ªâ®¢)
  381. align 4
  382. proc pole_move_all, pole:dword, m_d_x:dword, m_d_y:dword
  383. pushad
  384.         mov edi,dword[pole]
  385.         mov edx,[m_d_x]
  386.         mov esi,[m_d_y]
  387.  
  388.         mov eax,pole_index
  389.         cmp dword[eax],0
  390.         je .end_0 ;¥á«¨ ­¥â ï祥ª (¯à®¢®¤®¢) â® ¢ë室
  391.  
  392.         mov ecx,dword[eax]
  393.         cld
  394.         @@: ;横« ¯® ¢á¥¬ ï祩ª ¬
  395.                 add eax,4
  396.                 mov ebx,[eax]
  397.                 imul ebx,sizeof.Cell
  398.                 add ebx,pole_data
  399.  
  400.                 add dword[ebx+offs_cell_x],edx
  401.                 add dword[ebx+offs_cell_y],esi
  402.                 loop @b
  403.         .end_0:
  404.  
  405.         ;横« ¯® «®£¨ç¥áª¨¬ í«¥¬¥­â ¬ ¨ ¯®¤¯¨áï¬
  406.         stdcall dword[tl_node_poi_get_info], tree1,0
  407.         @@:
  408.                 cmp eax,0
  409.                 je .end_1
  410.                 cmp word[eax],el_icon_elems ;¯®«ã祭¨¥ ç¥à¥§ eax ⨯ ¨ª®­ª¨
  411.                 je .mov_1
  412.                 cmp word[eax],el_icon_captions
  413.                 je .mov_1
  414.                         jmp .end_mov_1
  415.                 .mov_1:
  416.                         mov ecx,eax
  417.                         stdcall [tl_node_poi_get_data], tree1,eax
  418.                         add [eax],edx ;coord x
  419.                         add [eax+4],esi ;coord y
  420.                         mov eax,ecx
  421.                 .end_mov_1:
  422.                 stdcall dword[tl_node_poi_get_next_info], tree1,eax ;¯¥à¥å®¤¨¬ ª á«¥¤ã饬ã 㧫ã
  423.                 jmp @b
  424.         .end_1:
  425.  
  426. popad
  427.         ret
  428. endp
  429.  
  430. ;output:
  431. ; dl
  432. align 4
  433. proc pole_compare_cells_bm_coords uses eax ebx ecx, i0:dword, fx:dword, fy:dword
  434.         get_cell_offset eax,[i0]
  435.         ;eax -> cell[i0]
  436.         mov ebx,dword[fx]
  437.         cmp dword[eax],ebx
  438.         jle @f
  439.                 mov dl,1
  440.                 jmp .fun_e
  441.         @@:
  442.         mov ecx,dword[fy]
  443.         cmp dword[eax+4],ecx
  444.         jle @f
  445.         cmp dword[eax],ebx
  446.         jne @f
  447.                 mov dl,1
  448.                 jmp .fun_e
  449.         @@:
  450.         xor dl,dl
  451.         .fun_e:
  452.         ret
  453. endp
  454.  
  455. ;output:
  456. ; dl
  457. align 4
  458. proc pole_compare_cells_mb_coords uses eax ebx ecx, i0:dword, fx:dword, fy:dword
  459.         get_cell_offset eax,[i0]
  460.         ;eax -> cell[i0]
  461.         mov ebx,dword[fx]
  462.         cmp dword[eax],ebx
  463.         jge @f
  464.                 mov dl,1
  465.                 jmp .fun_e
  466.         @@:
  467.         mov ecx,dword[fy]
  468.         cmp dword[eax+4],ecx
  469.         jge @f
  470.         cmp dword[eax],ebx
  471.         jne @f
  472.                 mov dl,1
  473.                 jmp .fun_e
  474.         @@:
  475.         xor dl,dl
  476.         .fun_e:
  477.         ret
  478. endp
  479.  
  480. ;output:
  481. ; dl
  482. align 4
  483. proc pole_compare_cells_bm, i0:dword, i1:dword
  484.         push eax ebx ecx
  485.         get_cell_offset eax,[i0] ;eax -> cell[i0]
  486.         get_cell_offset ebx,[i1] ;ebx -> cell[i1]
  487.         mov ecx,dword[ebx] ;+0 = .x
  488.         cmp dword[eax],ecx
  489.         jle @f ;x0>x1
  490.                 mov dl,1
  491.                 jmp .fun_e
  492.         @@:
  493.         jne @f ;x0==x1
  494.         mov ecx,dword[ebx+4] ;+4 = .y
  495.         cmp dword[eax+4],ecx
  496.         jle @f ;y0>y1
  497.                 mov dl,1
  498.                 jmp .fun_e
  499.         @@:
  500.         xor dl,dl
  501.         .fun_e:
  502.         pop ecx ebx eax
  503.         ret
  504. endp
  505.  
  506. ;description:
  507. ; ç¨á⪠ ï祥ª (¯à®¢®¤®¢), ãáâ ­®¢ª  ­  ¢á¥å ¯à®¢®¤ å 0-£® ᨣ­ « 
  508. ; ­ã¦­® ¢ë§ë¢ âì ¯à¨ ä®à¬¨à®¢ ­¨¨ ¨«¨ ¯¥à¥¤ § ¯ã᪮¬ á奬ë
  509. align 4
  510. proc pole_reset_cells uses eax ebx ecx edi, pole:dword
  511.         mov edi,dword[pole]
  512.         mov eax,pole_index
  513.         cmp dword[eax],0
  514.         je .fun_e ;¥á«¨ ­¥â ï祥ª (¯à®¢®¤®¢) â® ¢ë室
  515.  
  516.         mov ecx,dword[eax]
  517.         cld
  518.         @@: ;横« ¯® ¢á¥¬ ï祩ª ¬
  519.                 add eax,4
  520.                 mov ebx,[eax]
  521.                 imul ebx,sizeof.Cell
  522.                 add ebx,pole_data
  523.                 ;and byte[ebx+offs_cell_liv],0xfe ;á¡à®á ¬« ¤è¥£® ¡¨â 
  524.                 cmp byte[ebx+offs_cell_liv],2
  525.                 je .no_clear
  526.                         mov byte[ebx+offs_cell_liv],0
  527.                 .no_clear:
  528.                 loop @b
  529.         .fun_e:
  530.         ret
  531. endp
  532.  
  533. align 4
  534. proc p_paint_elems uses eax esi
  535.         stdcall dword[tl_node_poi_get_info], tree1,0
  536.         @@:
  537.                 cmp eax,0
  538.                 je @f
  539.                 mov esi,eax
  540.                 cmp word[esi],el_icon_elems ;¯®«ã祭¨¥ ç¥à¥§ esi ⨯ ¨ª®­ª¨
  541.                 jne .end_element
  542.                         stdcall [tl_node_poi_get_data], tree1,esi
  543.                         stdcall el_draw, eax
  544.                 .end_element:
  545.                 cmp word[esi],el_icon_captions ;¯®«ã祭¨¥ ç¥à¥§ esi ⨯ ¨ª®­ª¨
  546.                 jne .end_caption
  547.                         stdcall [tl_node_poi_get_data], tree1,esi
  548.                         stdcall capt_draw, eax
  549.                 .end_caption:
  550.                 stdcall dword[tl_node_poi_get_next_info], tree1,esi
  551.                 jmp @b
  552.         @@:
  553.         ret
  554. endp
  555.  
  556. ;description:
  557. ; äã­ªæ¨ï à¨á®¢ ­¨ï í«¥¬¥­â  ­  ¯®«¥
  558. align 4
  559. proc el_draw, h_elem:dword
  560.         pushad
  561.  
  562.         mov edi,[h_elem]
  563.         mov eax,[edi] ;coord x
  564.         mov ebx,[edi+4] ;coord y
  565.  
  566.         movzx edi,byte[edi+sp_offs_el_type]
  567.         imul edi,size_el_opt
  568.         add edi,el_opt_beg ;edi - 㪠§ â¥«ì ­  áâàãªâãàã ᮠ᢮©á⢠¬¨ í«¥¬¥­â 
  569.  
  570.         movzx ecx,byte[edi+el_offs_box_x]
  571.         movzx edx,byte[edi+el_offs_box_y]
  572.         dec ecx
  573.         dec edx
  574.  
  575.         push eax ebx
  576.                 mov esi,[h_elem]
  577.                 movzx esi,byte[esi+8]
  578.                 push dword[edi+el_offs_col]
  579.                 push ebx
  580.                 push eax
  581.                 stdcall move_rotate_n90, ecx,edx,esi
  582.                 stdcall draw_scaled_rect, eax,ebx ;à¨á®¢ ­¨ ª®à¯ãá  í«¥¬¥­â 
  583.         pop ebx eax
  584.  
  585.         ;***  «£®à¨â¬ à¨á®¢ ­¨ï ­®£ ***
  586.         movzx esi,byte[zoom]
  587.         cmp esi,1
  588.         jne .end_m1
  589.                 ;*** à¨á®¢ ­¨¥ ­®£ ¯à¨ 1-¬ ¬ áèâ ¡¥ ***
  590.                 ;¢å®¤­ë¥ ­®£¨
  591.                 mov esi,[h_elem]
  592.                 stdcall el_get_leg_coords,esi,0 ;ãáâ ­®¢ª  ¯ à ¬¥â஢ 0-© ­®£¨
  593.                 add eax,[Cor_x]
  594.                 add ebx,[Cor_y]
  595.                 movzx esi,byte[esi+8]
  596.                 stdcall move_rotate_n90, 1,0,esi
  597.                 mov edx,1
  598.                 @@:
  599.                         stdcall [buf2d_set_pixel], buf_0, eax,ebx,dword[edi+el_offs_col]
  600.                         mov ecx,[edi+el_offs_legs_inp]
  601.                         movzx ecx,byte[ecx+edx]
  602.                         cmp ecx,0
  603.                         je @f
  604.                         stdcall move_rotate_n90, 0,ecx,esi
  605.                         inc edx
  606.                         jmp @b
  607.                 @@:
  608.  
  609.                 ;¢ë室­ë¥ ­®£¨
  610.                 mov esi,[h_elem]
  611.                 stdcall el_get_leg_coords,esi,(1 shl 16) ;ãáâ ­®¢ª  ¯ à ¬¥â஢ 0-© ­®£¨
  612.                 add eax,[Cor_x] ;¤«ï à ¡®âë á buf2d_line
  613.                 add ebx,[Cor_y] ;¤«ï à ¡®âë á buf2d_line
  614.                 movzx esi,byte[esi+8]
  615.                 stdcall move_rotate_n90, -2,0,esi
  616.                 mov edx,el_offs_legs_out
  617.                 inc edx
  618.                 @@:
  619.                         push dword[edi+el_offs_col]
  620.                         stdcall move_rotate_n90, 1,0,esi
  621.                         push ebx
  622.                         push eax
  623.                         stdcall move_rotate_n90, -1,0,esi
  624.                         ;stdcall draw_scaled_rect, eax,ebx
  625.                         stdcall [buf2d_line], buf_0, eax,ebx
  626.                         movzx ecx,byte[edi+edx]
  627.                         cmp ecx,0
  628.                         je @f
  629.                         stdcall move_rotate_n90, 0,ecx,esi
  630.                         inc edx
  631.                         jmp @b
  632.                 @@:
  633.  
  634.                 jmp .end_mn
  635.         .end_m1:
  636.                 ;*** à¨á®¢ ­¨¥ ­®£ ¯à¨ n-¬ ¬ áèâ ¡¥ ***
  637.                 ;¢å®¤­ë¥ ­®£¨
  638.                 xor edx,edx
  639.                 @@:
  640.                         stdcall el_get_leg_coords,[h_elem],edx
  641.                         mov ecx,eax
  642.                         or ecx,ebx
  643.                         jz @f
  644.                         mov ecx,[h_elem]
  645.                         movzx ecx,byte[ecx+8]
  646.                         stdcall move_rotate_n90, 1,0,ecx
  647.                         add eax,[Cor_x]
  648.                         add ebx,[Cor_y]
  649.                         imul eax,esi
  650.                         imul ebx,esi
  651.                         stdcall [buf2d_filled_rect_by_size], buf_0, eax,ebx,esi,esi, dword[edi+el_offs_col]
  652.                         inc edx
  653.                         jmp @b
  654.                 @@:
  655.  
  656.                 ;¢ë室­ë¥ ­®£¨
  657.                 mov edx,(1 shl 16)
  658.                 @@:
  659.                         stdcall el_get_leg_coords,[h_elem],edx
  660.                         mov ecx,eax
  661.                         or ecx,ebx
  662.                         jz @f
  663.                         mov ecx,[h_elem]
  664.                         movzx ecx,byte[ecx+8]
  665.  
  666.                         push dword[edi+el_offs_col]
  667.                         stdcall move_rotate_n90, -2,0,ecx
  668.                         push ebx
  669.                         push eax
  670.                         stdcall move_rotate_n90, 1,0,ecx
  671.                         stdcall draw_scaled_rect, eax,ebx
  672.  
  673.                         inc edx
  674.                         jmp @b
  675.                 @@:            
  676.         .end_mn:
  677.         popad
  678.         ret
  679. endp
  680.  
  681. ;description:
  682. ;à¨á®¢ ­¨¥ ¯®¤¯¨á¥©
  683. align 4
  684. proc capt_draw uses eax ebx edi esi, h_capt:dword
  685.         mov edi,[h_capt]
  686.         mov eax,[edi] ;coord x
  687.         mov ebx,[edi+4] ;coord y
  688.  
  689.         movzx esi,byte[zoom]
  690.         cmp esi,3
  691.         jl @f
  692.                 ;à¨á®¢ ­¨¥ à ¬ª¨, ¢®ªà㣠§ ­ï⮩ â®çª¨
  693.                 stdcall draw_point_border, eax,ebx, [color_captions]
  694.         @@:
  695.  
  696.         add eax,[Cor_x]
  697.         add ebx,[Cor_y]
  698.  
  699.         cmp esi,1
  700.         jle @f
  701.                 imul eax,esi
  702.                 imul ebx,esi
  703.         @@:
  704.  
  705.         cmp esi,3
  706.         jl @f
  707.                 ;ᤢ¨£ ­ ¤¯¨á¨ á ãç¥â®¬ à ¬ª¨
  708.                 add eax,esi
  709.                 inc eax
  710.         @@:
  711.  
  712.         add edi,capt_offs ;edi - 㪠§ â¥«ì ­  ¯®«­ãî ¯®¤¯¨áì (á ª®®à¤¨­ â ¬¨)
  713.         call str_next_val
  714.         call str_next_val
  715.         stdcall [buf2d_draw_text], buf_0, buf_font,edi,eax,ebx,[color_captions] ;à¨á㥬 áâபã á ⥪á⮬
  716.         ret
  717. endp
  718.  
  719. ;description:
  720. ; äã­ªæ¨ï ¤«ï ¢ë¤¥«¥­¨ï â®ç¥ç­ëå ®¡ê¥ªâ®¢ ­  ªà㯭ëå ¬ áèâ ¡ å
  721. ; ¤ ­­ ï äã­ªæ¨ï ®ç¥­ì ¯®å®¦  ­  draw_signal_rect
  722. align 4
  723. proc draw_point_border uses eax ebx edi, x0:dword,y0:dword, color:dword
  724.         movzx edi,byte[zoom]
  725.         mov ebx,[y0]
  726.         mov eax,[x0]
  727.  
  728.         add ebx,[Cor_y]
  729.         imul ebx,edi
  730.         add eax,[Cor_x]
  731.         imul eax,edi
  732.  
  733.         stdcall [buf2d_rect_by_size], buf_0, eax,ebx,edi,edi, dword[color]
  734.         ret
  735. endp
  736.  
  737. ;description:
  738. ; ¯®¤äã­ªæ¨ï ¤«ï à¨á®¢ ­¨ï 㢥«¨ç¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ­  á奬¥
  739. align 4
  740. proc draw_scaled_rect uses eax ebx ecx edx edi, x0:dword,y0:dword,x1:dword,y1:dword, color:dword
  741.         movzx edi,byte[zoom]
  742.         mov edx,[y1]
  743.         mov ecx,[x1]
  744.         mov ebx,[y0]
  745.         mov eax,[x0]
  746.  
  747.         cmp eax,ecx
  748.         jle @f
  749.                 xchg eax,ecx
  750.         @@:
  751.         sub ecx,eax
  752.         cmp ebx,edx
  753.         jle @f
  754.                 xchg ebx,edx
  755.         @@:
  756.         sub edx,ebx
  757.  
  758.         inc ecx
  759.         inc edx
  760.  
  761.         imul edx,edi
  762.         imul ecx,edi
  763.         add ebx,[Cor_y]
  764.         imul ebx,edi
  765.         add eax,[Cor_x]
  766.         imul eax,edi
  767.  
  768.         stdcall [buf2d_filled_rect_by_size], buf_0, eax,ebx,ecx,edx, dword[color]
  769.         ret
  770. endp
  771.  
  772. align 4
  773. proc pole_paint, pole:dword
  774.         pushad
  775.  
  776.         ;*** நᮢ ­¨¥ à ¬ª¨
  777.         mov eax,[Cor_x]
  778.         mov ebx,[Cor_y]
  779.         mov ecx,[shem_w]
  780.         mov edx,[shem_h]
  781.         movzx esi,byte[zoom]
  782.         cmp esi,1
  783.         jle @f
  784.                 imul eax,esi
  785.                 imul ebx,esi
  786.                 imul ecx,esi
  787.                 imul edx,esi
  788.         @@:
  789.         dec eax
  790.         dec ebx
  791.         add ecx,2
  792.         add edx,2
  793.         stdcall [buf2d_rect_by_size], buf_0, eax,ebx, ecx,edx, [color_border]
  794.  
  795.         ;eax -> firstC
  796.         ;ebx -> i
  797.         ;ecx -> cell[pole_index[i]]
  798.         ;edx -> color
  799.  
  800.         mov edi,dword[pole]
  801.         mov eax,pole_index
  802.         cmp dword[eax],0
  803.         je .no_draw
  804.  
  805.         mov eax,dword[eax]
  806.         mov ebx,1
  807.  
  808. ;---
  809.         @@: ;while(i<pole_b_sort && Cor_x+cell[pole_index[i]].x<0)
  810.                 cmp ebx,pole_b_sort
  811.                 jge @f ;¯¥à¥å®¤¨¬ ­  ­ ç «® ­¨¦­¥£® 横« 
  812.                 mov ecx,ebx
  813.                 shl ecx,2
  814.                 add ecx,pole_index
  815.                 get_cell_offset ecx,dword[ecx]
  816.                 mov edx,dword[ecx] ;+0 = .x
  817.                 add edx,dword[Cor_x]
  818.                 cmp edx,0
  819.                 jge @f ;¯¥à¥å®¤¨¬ ­  ­ ç «® ­¨¦­¥£® 横« 
  820.                         inc ebx ;i++; // ¤«ï ¯à®¯ã᪠ ï祥ª §  ®ª­®¬ á«¥¢ 
  821.                 jmp @b
  822.         @@:
  823.  
  824.         ;eax -> pole_index[firstC]
  825.         ;ebx -> pole_index[i]
  826.         ;edi -> coord_x
  827.         ;esi -> coord_y
  828.         shl eax,2
  829.         shl ebx,2
  830.         add eax,pole_index
  831.         add ebx,pole_index
  832.  
  833.         cmp byte[zoom],2
  834.         jge .zoom2
  835.         @@: ;for(;i<=fristC;i++){
  836.                 get_cell_offset ecx,dword[ebx]
  837. ;...
  838.                 mov edi,dword[Cor_x]
  839.                 add edi,dword[ecx] ;+0 = .x
  840.                 mov esi,dword[Cor_y]
  841.                 add esi,dword[ecx+4] ;+4 = .y
  842.                 movzx edx,byte[ecx+offs_cell_liv]
  843.                 and edx,3 ;®£à ­¨ç¥­¨¥
  844.                 shl edx,2
  845.                 add edx,shem_colors
  846.                 stdcall [buf2d_set_pixel], buf_0, edi, esi, [edx]
  847. ;...
  848.                 add ebx,4
  849.                 cmp ebx,eax
  850.                 jle @b
  851.  
  852.         jmp .no_draw
  853.         .zoom2:
  854.  
  855.         @@: ;for(;i<=fristC;i++){
  856.                 get_cell_offset ecx,dword[ebx]
  857.  
  858.                 movzx edx,byte[zoom] ;edx ¨á¯®«ì§ã¥âáï ¤«ï ¢­¥á¥­¨ï zoom ¢ 4 ¡ ©â­®¥ ç¨á«®
  859.                 mov edi,dword[ecx] ;+0 = .x
  860.                 add edi,dword[Cor_x]
  861.                 imul edi,edx
  862.                 mov esi,dword[ecx+4] ;+4 = .y
  863.                 add esi,dword[Cor_y]
  864.                 imul esi,edx
  865.  
  866.                 movzx edx,byte[ecx+offs_cell_liv]
  867.                 and edx,3 ;®£à ­¨ç¥­¨¥
  868.                 shl edx,2
  869.                 add edx,shem_colors
  870.  
  871.                 movzx ecx,byte[zoom]
  872.                 ;;;dec ecx
  873.                 stdcall [buf2d_filled_rect_by_size], buf_0, edi, esi, ecx, ecx, [edx]
  874.                 add ebx,4
  875.                 cmp ebx,eax
  876.                 jle @b
  877.  
  878.         .no_draw:
  879.         popad
  880.         call p_paint_elems
  881.         ret
  882. endp
  883.  
  884. ;‘®àâ¨à®¢ª  ï祥ª ¯®«ï, ­ã¦­  ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª 
  885. align 4
  886. proc pole_sort uses eax edi, pole:dword
  887.         mov edi,dword[pole]
  888.         mov eax,pole_index
  889.         mov eax,dword[eax] ;firstC -> eax
  890.         stdcall pole_fl_sort, pole_index,eax ;á®àâ¨à㥬 ¢á¥ ï祩ª¨
  891.         mov pole_b_sort,eax ;áâ ¢¨¬ ç¨á«® ®âá®àâ¨à®¢ ­­ëå ï祥ª à ¢­®¥ ç¨á«ã ¢á¥å áãé¥áâ¢ãîé¨å ï祥ª
  892.         ret
  893. endp
  894.  
  895. ;‘®àâ¨à®¢ª  ¢¥ªâ®à  a[1..n] ¬¥â®¤®¬ ”«®©¤ 
  896. ;«¥¬¥­â a[0] ¢ á®àâ¨à®¢ª¥ ­¥ ãç áâ¢ã¥â
  897. align 4
  898. proc pole_fl_sort uses eax ecx edx edi esi, a:dword, n:dword
  899.         mov ecx,dword[a]
  900.         ;”®à¬¨à®¢ âì ¨á室­®¥ ç áâ¨ç­® 㯮à冷祭­®¥ ¤¥à¥¢®
  901.         mov eax,dword[n]
  902.         shr eax,1
  903.         @@: ;for(i=n>>1; i>=2; i--)
  904.                 stdcall pole_fl_surface, ecx,eax,[n] ;(a,i,n)
  905.                 dec eax
  906.                 cmp eax,2
  907.                 jge @b
  908.         ;‚믮«­¨âì ¯à®æ¥¤ãà㠢ᯫëâ¨ï ”«®©¤  ¤«ï ª ¦¤®£® ¯®¤¤¥à¥¢ 
  909.         mov eax,dword[n]
  910.         @@: ;for(i=n; i>=2; i--){
  911.                 stdcall pole_fl_surface, ecx,1,eax ;(a,1,i)
  912.                 ;®¬¥áâ¨âì ­ ©¤¥­­ë© ¬ ªá¨¬ «ì­ë© í«¥¬¥­â ¢ ª®­¥æ ᯨ᪠
  913.                 mov edi,eax
  914.                 shl edi,2
  915.                 add edi,ecx ;edi -> &a[i]
  916.                 mov esi,dword[edi] ;w=a[i];
  917.                 mov edx,dword[ecx+4]
  918.                 mov dword[edi],edx ;a[i]=a[1];
  919.                 mov dword[ecx+4],esi ;a[1]=w;
  920.  
  921.                 dec eax
  922.                 cmp eax,2
  923.                 jge @b
  924.         ret
  925. endp
  926.  
  927. ;à®æ¥¤ãà  ¢á¯«ëâ¨ï ”«®©¤  ¯® ¤¥à¥¢ã a[1..k]
  928. align 4
  929. proc pole_fl_surface, a:dword, i:dword, k:dword
  930. locals
  931.         copy dd ?
  932. endl
  933.         pushad
  934.         ;edx -> ...
  935.         ;edi -> m
  936.         ;esi -> j
  937.         mov eax,dword[a]
  938.         mov ebx,dword[i]
  939.         mov ecx,dword[k]
  940.  
  941.         mov edx,ebx
  942.         shl edx,2
  943.         add edx,eax
  944.         mov edx,dword[edx]
  945.         mov dword[copy],edx ;copy=a[i];
  946.         mov edi,ebx
  947.         shl edi,1 ;m=i<<1;
  948.         .cycle_b: ;while (m<=k) {
  949.                 cmp edi,ecx
  950.                 jg .cycle_e
  951.                 jne @f ;if (m==k) j=m;
  952.                         mov esi,edi
  953.                         jmp .else_e
  954.                 @@: ;else if (pole_compare_cells_bm(a[m],a[m+1])) j=m;
  955.                 mov edx,edi
  956.                 shl edx,2
  957.                 add edx,eax
  958.                 stdcall pole_compare_cells_bm, dword[edx],dword[edx+4]
  959.                 cmp dl,0
  960.                 je @f
  961.                         mov esi,edi
  962.                         jmp .else_e
  963.                 @@: ;else j=m+1;
  964.                         mov esi,edi
  965.                         inc esi
  966.                 .else_e:
  967.  
  968.                 ;if (pole_compare_cells_bm(a[j],copy)) {
  969.                 mov edx,esi
  970.                 shl edx,2
  971.                 add edx,eax
  972.                 stdcall pole_compare_cells_bm, dword[edx],dword[copy]
  973.                 cmp dl,0
  974.                 je .cycle_e ;} else break; //¢ë室 ¨§ 横« 
  975.  
  976.                 mov edx,esi
  977.                 shl edx,2
  978.                 add edx,eax
  979.                 push dword[edx] ;push a[j];
  980.                 mov edx,ebx
  981.                 shl edx,2
  982.                 add edx,eax
  983.                 pop dword[edx] ;a[i]=a[j];
  984.                 mov ebx,esi ;i=j;
  985.                 mov edi,ebx
  986.                 shl edi,1 ;m=i<<1;
  987.  
  988.                 jmp .cycle_b
  989.         .cycle_e:
  990.  
  991.         ;§­ ç¥­¨ï ¬­®£¨å ॣ¨áâ஢ 㦥 ­¥ ¢ ¦­ë â. ª. ª®­¥æ ä㭪樨
  992.         shl ebx,2
  993.         add eax,ebx
  994.         mov edx,dword[copy]
  995.         mov dword[eax],edx ;a[i]=copy;
  996.  
  997.         popad
  998.         ret
  999. endp
  1000. ;--------------------------------------
  1001.  
  1002. align 4
  1003. proc pole_draw_pok, pole:dword
  1004. pushad
  1005.         ;mov edi,dword[pole]
  1006.  
  1007.         mov ecx,[sc.work_text]
  1008.         or  ecx,0x80000000 ;or (1 shl 30)
  1009.         ;mov edi,[sc.work]
  1010.         mcall SF_DRAW_TEXT,(400 shl 16)+5,,txt_zoom
  1011.  
  1012.         add bx,9
  1013.         mov edx,txt_osob
  1014.         int 0x40
  1015.  
  1016.         add bx,9
  1017.         mov edx,txt_info
  1018.         int 0x40
  1019.  
  1020.         movzx ecx,byte[zoom]
  1021.         mov edx,(400+6*9)*65536+5
  1022.         mov esi,[sc.work_button_text]
  1023.         or  esi,(1 shl 30)
  1024.         mov edi,[sc.work_button]
  1025.         mcall SF_DRAW_NUMBER,(2 shl 16) ;¬ áèâ ¡
  1026.  
  1027.         mov edi,dword[pole]
  1028.         mov ecx,pole_index
  1029.         mov ecx,[ecx]
  1030.         mov edi,[sc.work_button]
  1031.         add edx,(6*0)*65536+9
  1032.         mcall ,(5 shl 16) ;ç¨á«® â®ç¥ª
  1033. popad
  1034.         ret
  1035. endp
  1036.  
  1037. align 4
  1038. but_zoom_p:
  1039.         cmp byte[zoom],16
  1040.         jge @f
  1041.                 pushad
  1042.                 ;¢ëç¨á«¥­¨¥ ᤢ¨£®¢ ¤«ï ¯®«ï, ª®â®àë¥ ®¡¥á¯¥ç â 業â஢ªã ¯®«ï ¯à¨ 㢥«¨ç¥­¨¨ ¬ áèâ ¡ 
  1043.                 movzx ecx,byte[zoom]
  1044.                 xor edx,edx
  1045.                 mov eax,dword[buf_0.w]
  1046.                 shr eax,1 ;¢ eax ¯®«®¢¨­  è¨à¨­ë ¯®«ï
  1047.                 mov ebx,eax ;¤¥« ¥¬ १¥à¢­ãî ª®¯¨î eax
  1048.                 div ecx ;¤¥«¨¬ eax ­  ⥪ã騩 ¬ áèâ ¡
  1049.                 xchg eax,ebx
  1050.                 xor edx,edx
  1051.                 inc ecx
  1052.                 div ecx ;¤¥«¨¬ eax ­  ­®¢ë© ¬ áèâ ¡
  1053.                 sub ebx,eax ;¢ëç¨á«ï¥âáï ᤢ¨£ ¯®«ï ª®â®àë© ®¡¥á¯¥ç¨â 業â஢ªã ¯®«ï
  1054.                 sub dword[Cor_x],ebx ;ᤢ¨£ ¥¬ ¯®«¥ §à¥­¨ï ¯® ®á¨ x
  1055.                 xor ecx,ecx
  1056.                 mov cl,byte[zoom]
  1057.                 xor edx,edx
  1058.                 mov eax,dword[buf_0.h]
  1059.                 shr eax,1
  1060.                 mov ebx,eax
  1061.                 div ecx
  1062.                 xchg eax,ebx
  1063.                 xor edx,edx
  1064.                 inc ecx
  1065.                 div ecx
  1066.                 sub ebx,eax
  1067.                 sub dword[Cor_y],ebx ;ᤢ¨£ ¥¬ ¯®«¥ §à¥­¨ï ¯® ®á¨ y
  1068.  
  1069.                 inc byte[zoom]
  1070.                 stdcall pole_draw_pok, pole
  1071.                 popad
  1072.  
  1073.                 .buf_clear:
  1074.                         call redraw_pole
  1075.         @@:
  1076.         ret
  1077.  
  1078. align 4
  1079. but_zoom_m:
  1080.         cmp byte[zoom],1
  1081.         jle @f
  1082.                 pushad
  1083.                 ;¢ëç¨á«¥­¨¥ ᤢ¨£®¢ ¤«ï ¯®«ï, ª®â®àë¥ ®¡¥á¯¥ç â 業â஢ªã ¯®«ï ¯à¨ 㬥­ì襭¨¨ ¬ áèâ ¡ 
  1084.                 movzx ecx,byte[zoom]
  1085.                 xor edx,edx
  1086.                 mov eax,dword[buf_0.w]
  1087.                 shr eax,1 ;¢ eax ¯®«®¢¨­  è¨à¨­ë ¯®«ï
  1088.                 mov ebx,eax ;¤¥« ¥¬ १¥à¢­ãî ª®¯¨î eax
  1089.                 div ecx ;¤¥«¨¬ eax ­  ⥪ã騩 ¬ áèâ ¡
  1090.                 xchg eax,ebx
  1091.                 xor edx,edx
  1092.                 dec ecx
  1093.                 div ecx ;¤¥«¨¬ eax ­  ­®¢ë© ¬ áèâ ¡
  1094.                 sub ebx,eax ;¢ëç¨á«ï¥âáï ᤢ¨£ ¯®«ï ª®â®àë© ®¡¥á¯¥ç¨â 業â஢ªã ¯®«ï
  1095.                 sub dword[Cor_x],ebx ;ᤢ¨£ ¥¬ ¯®«¥ §à¥­¨ï ¯® ®á¨ x
  1096.                 xor ecx,ecx
  1097.                 mov cl,byte[zoom]
  1098.                 xor edx,edx
  1099.                 mov eax,dword[buf_0.h]
  1100.                 shr eax,1
  1101.                 mov ebx,eax
  1102.                 div ecx
  1103.                 xchg eax,ebx
  1104.                 xor edx,edx
  1105.                 dec ecx
  1106.                 div ecx
  1107.                 sub ebx,eax
  1108.                 sub dword[Cor_y],ebx ;ᤢ¨£ ¥¬ ¯®«¥ §à¥­¨ï ¯® ®á¨ y
  1109.  
  1110.                 dec byte[zoom]
  1111.                 stdcall pole_draw_pok, pole
  1112.                 popad
  1113.  
  1114.                 .buf_clear:
  1115.                         call redraw_pole
  1116.         @@:
  1117.         ret
  1118.  
  1119. ;業â஢ª  áå¥¬ë ¯® 業âàã íªà ­ 
  1120. align 4
  1121. proc but_center uses eax ebx ecx edx
  1122.         movzx ecx,byte[zoom]
  1123.         cmp ecx,1
  1124.         jle .end_m_1
  1125.                 mov eax,[buf_0.w]
  1126.                 mov ebx,[shem_w]
  1127.                 imul ebx,ecx
  1128.  
  1129.                 sub eax,ebx
  1130.                 xor edx,edx
  1131.                 shl ecx,1
  1132.                 cmp eax,0
  1133.                 jge @f
  1134.                         neg eax
  1135.                         inc eax
  1136.                         div ecx
  1137.                         neg eax
  1138.                         inc eax
  1139.                         jmp .set_x
  1140.                 @@:
  1141.                         div ecx
  1142.                 .set_x:
  1143.                 mov [Cor_x],eax
  1144.                 mov eax,[buf_0.h]
  1145.                 mov ebx,[shem_h]
  1146.                 shr ecx,1
  1147.                 imul ebx,ecx
  1148.                 sub eax,ebx
  1149.                 xor edx,edx
  1150.                 shl ecx,1
  1151.                 cmp eax,0
  1152.                 jge @f
  1153.                         neg eax
  1154.                         inc eax
  1155.                         div ecx
  1156.                         neg eax
  1157.                         inc eax
  1158.                         jmp .set_y
  1159.                 @@:
  1160.                         div ecx
  1161.                 .set_y:
  1162.                 mov [Cor_y],eax
  1163.                 jmp .end_m_n
  1164.         .end_m_1:
  1165.                 mov eax,[buf_0.w]
  1166.                 sub eax,[shem_w]
  1167.                 shr eax,1
  1168.                 bt eax,30
  1169.                 jnc @f
  1170.                         bts eax,31
  1171.                 @@:
  1172.                 mov [Cor_x],eax
  1173.                 mov eax,[buf_0.h]
  1174.                 sub eax,[shem_h]
  1175.                 shr eax,1
  1176.                 bt eax,30
  1177.                 jnc @f
  1178.                         bts eax,31
  1179.                 @@:
  1180.                 mov [Cor_y],eax
  1181.         .end_m_n:
  1182.         call redraw_pole
  1183.         ret
  1184. endp
  1185.  
  1186. align 4
  1187. but_pole_up:
  1188.         push eax ecx edx
  1189.         mov eax,dword[buf_0.h]
  1190.         shr eax,2
  1191.         movzx ecx,byte[zoom]
  1192.         cmp cx,2
  1193.         jl @f ;¤¥«¥­¨¥ ­  ¢¥«¨ç¨­ã zoom
  1194.                 xor edx,edx
  1195.                 div ecx
  1196.         @@:
  1197.         add dword[Cor_y],eax
  1198.         pop edx ecx eax
  1199.         call redraw_pole
  1200.         ret
  1201.  
  1202. align 4
  1203. but_pole_dn:
  1204.         push eax ecx edx
  1205.         mov eax,dword[buf_0.h]
  1206.         shr eax,2
  1207.         xor ecx,ecx
  1208.         mov cl,byte[zoom]
  1209.         cmp cx,2
  1210.         jl @f ;¤¥«¥­¨¥ ­  ¢¥«¨ç¨­ã zoom
  1211.                 xor edx,edx
  1212.                 div ecx
  1213.         @@:
  1214.         sub dword[Cor_y],eax
  1215.         pop edx ecx eax
  1216.         call redraw_pole
  1217.         ret
  1218.  
  1219. align 4
  1220. but_pole_left:
  1221.         push eax ecx edx
  1222.         mov eax,dword[buf_0.w]
  1223.         shr eax,2
  1224.         xor ecx,ecx
  1225.         mov cl,byte[zoom]
  1226.         cmp cx,2
  1227.         jl @f ;¤¥«¥­¨¥ ­  ¢¥«¨ç¨­ã zoom
  1228.                 xor edx,edx
  1229.                 div ecx
  1230.         @@:
  1231.         add dword[Cor_x],eax
  1232.         pop edx ecx eax
  1233.         call redraw_pole
  1234.         ret
  1235.  
  1236. align 4
  1237. but_pole_right:
  1238.         push eax ecx edx
  1239.         mov eax,dword[buf_0.w]
  1240.         shr eax,2
  1241.         xor ecx,ecx
  1242.         mov cl,byte[zoom]
  1243.         cmp cx,2
  1244.         jl @f ;¤¥«¥­¨¥ ­  ¢¥«¨ç¨­ã zoom
  1245.                 xor edx,edx
  1246.                 div ecx
  1247.         @@:
  1248.         sub dword[Cor_x],eax
  1249.         pop edx ecx eax
  1250.         call redraw_pole
  1251.         ret
  1252.  
  1253. ;output:
  1254. ; edx - count created points
  1255. align 4
  1256. proc shem_create_line uses eax ebx ecx edi, x:dword, y:dword, opt:dword
  1257.         mov edi,pole
  1258.         xor edx,edx
  1259.  
  1260.         mov ebx,[x]
  1261.         mov ecx,[y]
  1262.         bt dword[opt],0
  1263.         jnc @f
  1264.         .line_lr:
  1265.                 inc ebx
  1266.                 cmp ebx,[shem_w]
  1267.                 jge @f
  1268.                 stdcall pole_cell_find, pole,ebx,ecx
  1269.                 cmp eax,0
  1270.                 je .u0
  1271.                         imul eax,sizeof.Cell
  1272.                         add eax,pole_data
  1273.                         cmp byte[eax+offs_cell_liv],1
  1274.                         jne @f
  1275.                 .u0:
  1276.                 stdcall pole_cell_creat, pole,ebx,ecx,1
  1277.                 inc edx
  1278.                 jmp .line_lr
  1279.         @@:
  1280.  
  1281.         mov ebx,[x]
  1282.         ;mov ecx,[y]
  1283.         bt dword[opt],2
  1284.         jnc @f
  1285.         .line_rl:
  1286.                 dec ebx
  1287.                 cmp ebx,0
  1288.                 jl @f
  1289.                 stdcall pole_cell_find, pole,ebx,ecx
  1290.                 cmp eax,0
  1291.                 je .u1
  1292.                         imul eax,sizeof.Cell
  1293.                         add eax,pole_data
  1294.                         cmp byte[eax+offs_cell_liv],1
  1295.                         jne @f
  1296.                 .u1:
  1297.                 stdcall pole_cell_creat, pole,ebx,ecx,1
  1298.                 inc edx
  1299.                 jmp .line_rl
  1300.         @@:
  1301.  
  1302.         mov ebx,[x]
  1303.         mov ecx,[y]
  1304.         bt dword[opt],3
  1305.         jnc @f
  1306.         .line_du:
  1307.                 dec ecx
  1308.                 cmp ecx,0
  1309.                 jl @f
  1310.                 stdcall pole_cell_find, pole,ebx,ecx
  1311.                 cmp eax,0
  1312.                 je .u2
  1313.                         imul eax,sizeof.Cell
  1314.                         add eax,pole_data
  1315.                         cmp byte[eax+offs_cell_liv],1
  1316.                         jne @f
  1317.                 .u2:
  1318.                 stdcall pole_cell_creat, pole,ebx,ecx,1
  1319.                 inc edx
  1320.                 jmp .line_du
  1321.         @@:
  1322.  
  1323.         ;mov ebx,[x]
  1324.         mov ecx,[y]
  1325.         bt dword[opt],1
  1326.         jnc @f
  1327.         .line_ud:
  1328.                 inc ecx
  1329.                 cmp ecx,[shem_h]
  1330.                 jge @f
  1331.                 stdcall pole_cell_find, pole,ebx,ecx
  1332.                 cmp eax,0
  1333.                 je .u3
  1334.                         imul eax,sizeof.Cell
  1335.                         add eax,pole_data
  1336.                         cmp byte[eax+offs_cell_liv],1
  1337.                         jne @f
  1338.                 .u3:
  1339.                 stdcall pole_cell_creat, pole,ebx,ecx,1
  1340.                 inc edx
  1341.                 jmp .line_ud
  1342.         @@:
  1343.  
  1344.         ret
  1345. endp
  1346.  
  1347. align 4
  1348. redraw_pole:
  1349.         stdcall [buf2d_clear], buf_0, [buf_0.color]
  1350.         stdcall pole_paint, pole
  1351.         stdcall [buf2d_draw], buf_0
  1352.         ret
  1353.