Subversion Repositories Kolibri OS

Rev

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