Subversion Repositories Kolibri OS

Rev

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

  1. use32
  2.         org 0
  3.         db 'MENUET01'
  4.         dd 1,start,i_end,mem,stacktop,0,sys_path
  5.  
  6. include '../../../macros.inc'
  7. include '../../../proc32.inc'
  8. include '../../../KOSfuncs.inc'
  9. include '../../../load_img.inc'
  10. include '../../../develop/libraries/box_lib/load_lib.mac'
  11.  
  12. @use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
  13. hed db 'Life 31.10.18',0 ;¯®¤¯¨áì ®ª­ 
  14.  
  15. run_file_70 FileInfoBlock
  16. image_data dd 0 ;㪠§ â¥«ì ­  ¢à¥¬¥­­ãî ¯ ¬ïâì. ¤«ï ­ã¦¥­ ¯à¥®¡à §®¢ ­¨ï ¨§®¡à ¦¥­¨ï
  17.  
  18. IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3
  19. image_data_toolbar dd 0
  20.  
  21.  
  22. ;--------------------------------------
  23. struct Cell
  24.         x dd ? ;+0
  25.         y dd ? ;+4
  26.         tc  dd ? ;+8 ¯®ª®«¥­¨¥ ¢ ª®â®à®¬ த¨« áì ®á®¡ì
  27.         liv db ? ;+12 ¦¨¢ ï ï祩ª  ¨«¨ ­¥â
  28.         so  db ? ;+13 ç¨á«® á®á¥¤¥©
  29. ends
  30.  
  31. MAX_CELL equ 90000 ;¤®«¦­® ¡ëâì ªà â­® 4
  32. COL_MEM equ 64 ;ç¨á«® 梥⮢ ¤«ï ®â«¨ç¨ï ¬®«®¤ëå ¨ áâ àëå
  33.  
  34. cell dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì á® áâàãªâãà ¬¨ ï祥ª
  35. memCell dd 0
  36. CellColors dd 0
  37.  
  38. macro get_cell_offset reg,ind
  39. {
  40.         mov reg,ind
  41.         imul reg,sizeof.Cell
  42.         add reg,dword[cell]
  43. }
  44.  
  45. er_oom db 0 ;­  á«ãç © ¨áç¥à¯ ­¨ï ¯ ¬ïâ¨
  46. tim_ch db 0 ; ¢â®¬ â¨ç¥áª¨ ¯à®áç¨â뢠âì ¯®ª®«¥­¨ï
  47. poc_stop dd 1 ;¯à®áç¥â ­  ç¨á«® ¯®ª®«¥­¨©
  48. Cor_x dd 0
  49. Cor_y dd 0
  50. tim dd 0 ;¢à¥¬ï (¯®ª®«¥­¨¥)
  51. b_sort dd 0 ;£à ­¨æ  ¤«ï á®àâ¨à®¢ ­­ëå ï祥ª
  52. osob dd 0 ;ç¨á«® ®á®¡¥©
  53. zoom db 3 ;¬ áèâ ¡ ¯®«ï
  54. txt_zoom db 'Œ áèâ ¡:',0
  55. txt_gen db '®ª®«¥­¨¥:',0
  56. txt_osob db 'Žá®¡¥©:',0
  57.  
  58. ;­ áâனª  ¬ áᨢ  á 梥⠬¨
  59. ; col_pole - 梥⠯®«ï
  60. ; col_cell_n - 梥⠭®¢®© ï祩ª¨
  61. ; col_cell_o - 梥â áâ à®© ï祩ª¨
  62. align 4
  63. proc pole_init_colors uses eax ebx ecx edx esi edi, col_pole:dword, col_cell_n:dword, col_cell_o:dword
  64.         mov esi,[CellColors]
  65.         mov ebx,[col_pole]
  66.         mov dword[esi],ebx
  67.  
  68.         add esi,4
  69.         mov edi,COL_MEM
  70.         dec edi
  71.         shl edi,2
  72.         add edi,esi
  73.         ; esi - 㪠§ â¥«ì ­  1-© £à ¤¨¥­â­ë© 梥â
  74.         ; edi - 㪠§ â¥«ì ­  ¯®á«¥¤­¨© £à ¤¨¥­â­ë© 梥â
  75.         mov eax,[col_cell_n]
  76.         mov ebx,[col_cell_o]
  77.  
  78.         mov dword[esi],eax
  79.         mov dword[edi],ebx
  80.         ;need save ecx edx
  81.         stdcall middle_colors, esi,edi
  82.  
  83.         ret
  84. endp
  85.  
  86. ;¢á¯®¬®£ â¥«ì­ ï äã­ªæ¨ï ¤«ï ­ å®¤¦¥­¨ï á।­¥£® æ¢¥â  ¨ § ¯¨á¨ ¥£® ¢ ¬ áᨢ
  87. ;input:
  88. ; eax - 梥⠭ ç «ì­ë©
  89. ; ebx - 梥⠪®­¥ç­ë©
  90. ;§ §àãè îâìáï: ecx, edx
  91. align 4
  92. proc middle_colors uses edi esi, i0:dword, i1:dword
  93.         mov esi,[i0]
  94.         mov edi,[i1]
  95.         ;¯¥à¥¤ ¢ë§®¢®¬ ä㭪樨
  96.         ;dword[esi]=eax
  97.         ;dword[edi]=ebx
  98.         sub edi,esi
  99.         shr edi,1
  100.         btr edi,1 ;®ªà㣫塞 ¤® 4-å, â. ª. ­ã¦­® ¯®«ãç¨âì  ¤à¥á (®ªà㣫¥­¨¥ å¨â஥ - 㡨ࠥ¬ ®¤¨­ ¡¨â ¢¬¥áâ® ¯à¥¤¯®« £ ¥¬ëå 2-å)
  101.         add edi,esi
  102.         cmp edi,esi
  103.         je @f
  104.                 push eax ebx
  105.  
  106.                 mov ecx,eax
  107.                 mov edx,ebx
  108.  
  109.                 ;­ å®¤¨¬ á।­¨© 梥⠬¥¦¤ã eax ¨ ebx
  110.                 and ebx,111111101111111011111110b ;㡨ࠥ¬ ¯®á«¥¤­¨¥ ¡¨âë ¢ 梥â å r, g, b
  111.                 and eax,111111101111111011111110b
  112.                 add eax,ebx ;á㬨à㥬 æ¢¥â  ¨§ r, g, b
  113.                 shr eax,1   ;¤¥«¨¬ ­  2
  114.                 mov dword[edi],eax
  115.  
  116.                 ;४ãàᨢ­ë© ¢ë§®¢ ¤«ï ¤à®¡«¥­¨ï ¢¥àå­¥© ¯®«®¢¨­ë
  117.                 mov ebx,eax
  118.                 mov eax,ecx
  119.                 stdcall middle_colors, [i0],edi
  120.  
  121.                 ;४ãàᨢ­ë© ¢ë§®¢ ¤«ï ¤à®¡«¥­¨ï ­¨¦­¥© ¯®«®¢¨­ë
  122.                 mov eax,ebx
  123.                 mov ebx,edx
  124.                 stdcall middle_colors, edi,[i1]
  125.  
  126.                 pop ebx eax
  127.         @@:
  128.         ret
  129. endp
  130.  
  131. align 4
  132. proc pole_clear uses eax ecx edi
  133.         xor eax,eax
  134.         mov dword[tim],eax
  135.         mov dword[osob],eax
  136.         mov  byte[tim_ch],al
  137.         mov dword[Cor_x],eax
  138.         mov dword[Cor_y],eax
  139.         mov dword[b_sort],eax
  140.         mov  byte[er_oom],al
  141.         cld
  142.         mov ecx,(MAX_CELL*sizeof.Cell)/4
  143.         mov edi,[cell]
  144.         rep stosd ;memset(cell,0,sizeof(Cell)*MAX_CELL);
  145.         mov edi,[memCell]
  146.         mov ecx,MAX_CELL
  147.         @@:
  148.                 stosd ;for(i=0;i<MAX_CELL;i++) memCell[i]=i;
  149.                 inc eax
  150.                 loop @b
  151.         ret
  152. endp
  153. align 4
  154. proc pole_cell_creat, x:dword, y:dword, li:dword
  155.         pushad ;eax ebx ecx edx edi
  156.  
  157.         ; *** ¥á«¨ ª«¥âª  㦥 ¡ë«  ᮧ¤ ­ 
  158.         stdcall pole_cell_find, [x],[y]
  159.         cmp eax,0
  160.         je @f ;if(i){
  161.                 get_cell_offset ebx,eax
  162.                 cmp dword[li],0
  163.                 jne .else_if ;if(!li)
  164.                         ; ¥á«¨ ᮧ¤ ¥âáï ¯ãáâ ï ª«¥âª 
  165.                         inc byte[ebx+13] ;+13 = .so
  166.                         jmp .fun_e
  167.                 .else_if: ;else if(!(cell[i].liv&1) ){
  168.                 bt word[ebx+12],0 ;+12 = .liv
  169.                         ; ¥á«¨ ᮧ¤ ¥âáï ¦¨¢ ï ª«¥âª 
  170.                         ; ¨ à ­ìè¥ ª«¥âª  ¡ë«  ᮧ¤ ­  ­® ®ª § « áì ¯ãá⮩
  171.                         jae .creat_border_cells
  172.                 jmp .fun_e
  173.         @@:
  174.  
  175.         ; *** ᮧ¤ ­¨¥ ­®¢®© ï祩ª¨
  176.         ; ­ å®¤¨¬ ­®¬¥à ᢮¡®¤­®© ï祩ª¨ (i) ¤«ï ¤®¡ ¢«¥­¨ï ­®¢®©
  177.         mov edi,[memCell]
  178.         inc dword[edi]
  179.         cmp dword[edi],MAX_CELL
  180.         jne @f
  181.                 dec dword[edi]
  182.                 mov byte[tim_ch],0
  183.                 ;... need call message: "eror out of memory" ...
  184.                 ;... ¢ë¢®¤ á®®¡é¥­¨ï ¯¥à¥¯®«­¥­¨ï ­ ¤® ¤®¡ ¢¨âì  ...
  185.                 mov byte[er_oom],0
  186.                 jmp .fun_e ;return;
  187.         @@:
  188.         mov eax,[edi]
  189.         shl eax,2
  190.         add eax,[memCell] ;eax -> memCell[firstC]
  191.         get_cell_offset ebx,[eax]
  192.  
  193.         mov ecx,[x]
  194.         mov dword[ebx],ecx ;+0 = .x
  195.         mov edx,[y]
  196.         mov dword[ebx+4],edx ;+4 = .y
  197.         mov eax,[tim]
  198.         mov dword[ebx+8],eax ;+8 = .tc
  199.         mov byte[ebx+12],0 ;+12 = .liv
  200.  
  201.         cmp dword[li],0
  202.         jne @f
  203.                 mov byte[ebx+13],1 ;+13 = .so
  204.                 jmp .fun_e
  205.         @@:
  206.         mov byte[ebx+13],0 ;+13 = .so
  207.  
  208.         .creat_border_cells:
  209.                 inc dword[osob]
  210.                 or byte[ebx+12],1 ;+12 = .liv
  211.                 mov ecx,[x]
  212.                 dec ecx
  213.                 mov edx,[y]
  214.                 dec edx
  215.                 stdcall pole_cell_creat,ecx,edx,0
  216.                 inc edx
  217.                 stdcall pole_cell_creat,ecx,edx,0
  218.                 inc edx
  219.                 stdcall pole_cell_creat,ecx,edx,0
  220.                 inc ecx
  221.                 stdcall pole_cell_creat,ecx,edx,0
  222.                 sub edx,2
  223.                 stdcall pole_cell_creat,ecx,edx,0
  224.                 inc ecx
  225.                 stdcall pole_cell_creat,ecx,edx,0
  226.                 inc edx
  227.                 stdcall pole_cell_creat,ecx,edx,0
  228.                 inc edx
  229.                 stdcall pole_cell_creat,ecx,edx,0
  230.         .fun_e:
  231.         popad ;edi edx ecx ebx eax
  232.         ret
  233. endp
  234.  
  235. ;output:
  236. ; eax - index
  237. align 4
  238. proc pole_cell_find, x:dword, y:dword
  239.         mov eax,[memCell]
  240.         cmp dword[eax],0
  241.         jne @f
  242.                 xor eax,eax ;if(!fristC) return 0;
  243.                 jmp .fun_e
  244.         @@:
  245.  
  246.         xor eax,eax ;fnd=0;
  247.         cmp dword[b_sort],0
  248.         je @f
  249.                 stdcall pole_bin_find, [memCell], [x],[y], [b_sort] ;i=BinFind(memCell, x,y, b_sort);
  250.                 cmp eax,0
  251.                 je @f
  252.                         shl eax,2
  253.                         add eax,[memCell]
  254.                         mov eax,[eax] ;if(i) fnd=memCell[i];
  255.                         jmp .fun_e
  256.         @@:
  257.  
  258.         cmp eax,0
  259.         jne @f ;if(!fnd){ // ¯®¨áª ï祩ª¨ §  ¡¨­ à­ë¬ ¤¥à¥¢®¬
  260.                 push ebx ecx edx edi esi
  261.                 ;ebx -> i
  262.                 ;ecx -> firstC
  263.                 ;edx -> &memCell[i]
  264.                 ;edi -> cell[memCell[i]]
  265.                 mov ecx,[memCell]
  266.                 mov ebx,[b_sort]
  267.                 mov edx,ebx
  268.                 shl edx,2
  269.                 add edx,ecx
  270.                 mov ecx,[ecx]
  271.                 .cycle_b: ;for(i=b_sort+1;i<=fristC;i++)
  272.                         inc ebx
  273.                         cmp ebx,ecx
  274.                         jg .cycle_e
  275.                         add edx,4
  276.                         get_cell_offset edi,[edx]
  277.                         mov esi,[x]
  278.                         cmp dword[edi],esi ;+0 = .x
  279.                         jne .if_e
  280.                         mov esi,[y]
  281.                         cmp dword[edi+4],esi ;+4 = .y
  282.                         jne .if_e
  283.                                 ;if(cell[memCell[i]].x==x && cell[memCell[i]].y==y){
  284.                                 mov eax,[edx] ;fnd=memCell[i];
  285.                                 jmp .cycle_e ;break;
  286.                         .if_e:
  287.                         jmp .cycle_b
  288.                 .cycle_e:
  289.                 pop esi edi edx ecx ebx
  290.         @@:
  291.         .fun_e:
  292.         ret
  293. endp
  294.  
  295. ;output:
  296. ; eax - index
  297. align 4
  298. proc pole_bin_find, mas:dword, fx:dword, fy:dword, k:dword
  299.         push ebx ecx edx edi
  300.         xor eax,eax
  301.         mov ebx,1 ;ebx - ¬ ªá¨¬ «ì­ë© ¯®à冷ª ¤«ï ¤¥à¥¢ 
  302.         @@:
  303.         cmp dword[k],ebx
  304.         jle @f ;while(k>por)
  305.                 shl ebx,1 ;por<<=1;
  306.                 jmp @b
  307.         @@:
  308.         cmp dword[k],ebx
  309.         jge @f ;if(k<por)
  310.                 shr ebx,1 ;por>>=1;
  311.         @@:
  312.         mov ecx,ebx ;i=por;
  313.  
  314.         ;ecx -> i
  315.         ;edi -> mas[i]
  316.         .cycle_b: ;do{
  317.                 shr ebx,1 ;por>>=1;
  318.  
  319.                 mov edi,ecx
  320.                 shl edi,2
  321.                 add edi,[mas]
  322.                 ;if(compare_cells_mb(mas[i],fx,fy)){
  323.                 stdcall pole_compare_cells_mb_coords, dword[edi],[fx],[fy]
  324.                 cmp dl,0
  325.                 je .if_u0_e
  326.                         @@: ;while(i+por>k)
  327.                         mov edx,ecx
  328.                         add edx,ebx
  329.                         cmp edx,[k] ;i+por>k
  330.                         jle @f
  331.                                 shr ebx,1 ;por>>=1;
  332.                                 jmp @b
  333.                         @@:
  334.                         add ecx,ebx ;i+=por;
  335.                         jmp .if_e
  336.                 .if_u0_e:
  337.                 ;else if(compare_cells_bm(mas[i],fx,fy))i-=por;
  338.                 stdcall pole_compare_cells_bm_coords, dword[edi],[fx],[fy]
  339.                 cmp dl,0
  340.                 je .if_u1_e
  341.                         sub ecx,ebx
  342.                         jmp .if_e
  343.                 .if_u1_e:
  344.                 ;else { m=i; por=0; }
  345.                         mov eax,ecx
  346.                         xor ebx,ebx
  347.                 .if_e:
  348.         cmp ebx,0
  349.         jne .cycle_b ;}while(por);
  350.  
  351.         pop edi edx ecx ebx
  352.         ret
  353. endp
  354.  
  355. ;output:
  356. ; dl
  357. align 4
  358. proc pole_compare_cells_bm_coords, i0:dword, fx:dword, fy:dword
  359.         push eax ebx ecx
  360.         get_cell_offset eax,[i0]
  361.         ;eax -> cell[i0]
  362.         mov ebx,[fx]
  363.         cmp dword[eax],ebx
  364.         jle @f
  365.                 mov dl,1
  366.                 jmp .fun_e
  367.         @@:
  368.         mov ecx,[fy]
  369.         cmp dword[eax+4],ecx
  370.         jle @f
  371.         cmp dword[eax],ebx
  372.         jne @f
  373.                 mov dl,1
  374.                 jmp .fun_e
  375.         @@:
  376.         xor dl,dl
  377.         .fun_e:
  378.         pop ecx ebx eax
  379.         ret
  380. endp
  381.  
  382. ;output:
  383. ; dl
  384. align 4
  385. proc pole_compare_cells_mb_coords, i0:dword, fx:dword, fy:dword
  386.         push eax ebx ecx
  387.         get_cell_offset eax,[i0]
  388.         ;eax -> cell[i0]
  389.         mov ebx,[fx]
  390.         cmp dword[eax],ebx
  391.         jge @f
  392.                 mov dl,1
  393.                 jmp .fun_e
  394.         @@:
  395.         mov ecx,[fy]
  396.         cmp dword[eax+4],ecx
  397.         jge @f
  398.         cmp dword[eax],ebx
  399.         jne @f
  400.                 mov dl,1
  401.                 jmp .fun_e
  402.         @@:
  403.         xor dl,dl
  404.         .fun_e:
  405.         pop ecx ebx eax
  406.         ret
  407. endp
  408.  
  409. ;output:
  410. ; dl
  411. align 4
  412. proc pole_compare_cells_bm, i0:dword, i1:dword
  413.         push eax ebx ecx
  414.         get_cell_offset eax,[i0] ;eax -> cell[i0]
  415.         get_cell_offset ebx,[i1] ;ebx -> cell[i1]
  416.         mov ecx,[ebx] ;+0 = .x
  417.         cmp dword[eax],ecx
  418.         jle @f ;x0>x1
  419.                 mov dl,1
  420.                 jmp .fun_e
  421.         @@:
  422.         jne @f ;x0==x1
  423.         mov ecx,[ebx+4] ;+4 = .y
  424.         cmp dword[eax+4],ecx
  425.         jle @f ;y0>y1
  426.                 mov dl,1
  427.                 jmp .fun_e
  428.         @@:
  429.         xor dl,dl
  430.         .fun_e:
  431.         pop ecx ebx eax
  432.         ret
  433. endp
  434.  
  435. align 4
  436. pole_paint:
  437.         pushad
  438.         ;eax -> firstC
  439.         ;ebx -> i
  440.         ;ecx -> cell[memCell[i]]
  441.         ;edx -> color
  442.         ;edi -> coord_x
  443.         ;esi -> coord_y
  444.         mov eax,[memCell]
  445.         cmp dword[eax],0
  446.         je .no_draw
  447.  
  448.         mov eax,[eax]
  449.         mov ebx,1
  450.  
  451. ;---
  452.         @@: ;while(i<b_sort && Cor_x+cell[memCell[i]].x<0)
  453.                 cmp ebx,[b_sort]
  454.                 jge @f ;¯¥à¥å®¤¨¬ ­  ­ ç «® ­¨¦­¥£® 横« 
  455.                 mov ecx,ebx
  456.                 shl ecx,2
  457.                 add ecx,[memCell]
  458.                 get_cell_offset ecx,[ecx]
  459.                 mov edx,[ecx] ;+0 = .x
  460.                 add edx,[Cor_x]
  461.                 cmp edx,0
  462.                 jge @f ;¯¥à¥å®¤¨¬ ­  ­ ç «® ­¨¦­¥£® 横« 
  463.                         inc ebx ;i++; // ¤«ï ¯à®¯ã᪠ ï祥ª §  ®ª­®¬ á«¥¢ 
  464.                 jmp @b
  465.         @@:
  466.  
  467.         cmp byte[zoom],2
  468.         jge .zoom2
  469.         @@: ;for(;i<=fristC;i++){
  470.                 mov ecx,ebx
  471.                 shl ecx,2
  472.                 add ecx,[memCell]
  473.                 get_cell_offset ecx,[ecx]
  474. ;...
  475.                 mov edi,[Cor_x]
  476.                 add edi,[ecx] ;+0 = .x
  477.                 mov esi,[Cor_y]
  478.                 add esi,[ecx+4] ;+4 = .y
  479.                 bt word[ecx+12],0 ;+12 = .liv
  480.                 jc .cell_1
  481.                         ;­¥ ¦¨¢ ï ï祩ª 
  482.                         mov edx,[CellColors]
  483.                         mov edx,[edx]
  484.                         jmp .cell_0
  485.                 .cell_1:
  486.                         ;¦¨¢ ï ï祩ª 
  487.                         mov edx,[tim]
  488.                         inc edx
  489.                         sub edx,[ecx+8] ;+8 = .tc
  490.                         cmp edx,COL_MEM
  491.                         jle .in_color
  492.                                 mov edx,COL_MEM
  493.                         .in_color:
  494.                         shl edx,2
  495.                         add edx,[CellColors]
  496.                         mov edx,[edx]
  497.                 .cell_0:
  498.                 stdcall [buf2d_set_pixel], buf_0, edi, esi, edx
  499. ;...
  500.                 inc ebx
  501.                 cmp ebx,eax
  502.                 jle @b
  503.  
  504.         jmp .no_draw
  505.         .zoom2:
  506.  
  507.         @@: ;for(;i<=fristC;i++){
  508.                 mov ecx,ebx
  509.                 shl ecx,2
  510.                 add ecx,[memCell]
  511.                 get_cell_offset ecx,[ecx]
  512.  
  513.                 xor edx,edx
  514.                 mov dl,byte[zoom] ;edx ¨á¯®«ì§ã¥âáï ¤«ï ¢­¥á¥­¨ï zoom ¢ 4 ¡ ©â­®¥ ç¨á«®
  515.                 mov edi,[ecx] ;+0 = .x
  516.                 add edi,[Cor_x]
  517.                 imul edi,edx
  518.                 mov esi,[ecx+4] ;+4 = .y
  519.                 add esi,[Cor_y]
  520.                 imul esi,edx
  521.                 bt word[ecx+12],0 ;+12 = .liv
  522.                 jc .z2_cell_1
  523.                         ;­¥ ¦¨¢ ï ï祩ª 
  524.                         mov edx,[CellColors]
  525.                         mov edx,[edx]
  526.                         jmp .z2_cell_0
  527.                 .z2_cell_1:
  528.                         ;¦¨¢ ï ï祩ª 
  529.                         mov edx,[tim]
  530.                         inc edx
  531.                         sub edx,[ecx+8] ;+8 = .tc
  532.                         cmp edx,COL_MEM
  533.                         jle .z2_in_color
  534.                                 mov edx,COL_MEM
  535.                         .z2_in_color:
  536.                         shl edx,2
  537.                         add edx,[CellColors]
  538.                         mov edx,[edx]
  539.                 .z2_cell_0:
  540.                 xor ecx,ecx
  541.                 mov cl,byte[zoom] ;ecx ¨á¯®«ì§ã¥âáï ¤«ï ¢­¥á¥­¨ï zoom ¢ 4 ¡ ©â­®¥ ç¨á«®
  542.                 ;;;dec ecx
  543.                 stdcall [buf2d_filled_rect_by_size], buf_0, edi, esi, ecx, ecx, edx
  544.                 inc ebx
  545.                 cmp ebx,eax
  546.                 jle @b
  547.  
  548.         .no_draw:
  549.         popad
  550.         ret
  551.  
  552. align 4
  553. pole_next_gen:
  554.         pushad
  555.         ;eax -> firstC
  556.         ;ebx -> i
  557.         ;ecx -> &memCell[i]
  558.         ;edx -> cell[memCell[i]]
  559.  
  560.         mov eax,[memCell]
  561.         mov ecx,eax
  562.         mov eax,[eax]
  563.         cmp eax,1
  564.         jl .fun_e
  565.         inc dword[tim]
  566.         mov ebx,1
  567.         @@: ;for(i=1;i<=firstC;i++)
  568.                 add ecx,4
  569.                 get_cell_offset edx,[ecx]
  570.                 bt word[edx+12],0 ;+12 = .liv
  571.                 jae .if_0_e
  572.                         ; á®åà ­¥­¨¥ ï祩ª¨ (á®á¥¤¥© 2 ¨«¨ 3)
  573.                         cmp byte[edx+13],2 ;+13 = .so
  574.                         je .if_2_e
  575.                         cmp byte[edx+13],3 ;+13 = .so
  576.                         je .if_2_e
  577.                         jmp .change
  578.                 .if_0_e:
  579.                         ; ᮧ¤ ­¨¥ ï祩ª¨ (á®á¥¤¥© 3)
  580.                         cmp byte[edx+13],3 ;+13 = .so
  581.                         jne .if_1_e
  582.                         .change:
  583.                                 or byte[edx+12],2 ;+12 = .liv
  584.                                 jmp .if_2_e
  585.                 .if_1_e:
  586.                         ; 㤠«¥­¨¥ ¯ãá⮩ ï祩ª¨ ¤«ï ®á¢®¡®¦¤¥­¨ï ¯ ¬ïâ¨
  587.                         cmp byte[edx+13],0 ;+13 = .so
  588.                         jne .if_2_e
  589.                         mov edi,[edx+8] ;+8 = .tc
  590.                         add edi,5 ; 5 - ¢à¥¬ï á®åà ­¥­¨ï ¯ãá⮩ ï祩ª¨, ¤® ¥ñ 㤠«¥­¨ï
  591.                         cmp edi,[tim]
  592.                         jge .if_2_e
  593.                                 mov edi,eax
  594.                                 shl edi,2
  595.                                 add edi,[memCell] ;edi -> &memCell[fristC]
  596.                                 mov esi,[edi] ;swp=memCell[fristC];
  597.                                 mov edx,[ecx] ;edx - 㦥 ­¥ ¨á¯®«ì§ã¥¬, ¯®â®¬ã ¬®¦¥¬ ¯®àâ¨âì
  598.                                 mov dword[edi],edx ;memCell[fristC]=memCell[i];
  599.                                 mov dword[ecx],esi ;memCell[i]=swp;
  600.                                 dec eax
  601.                                 dec ebx
  602.                                 sub ecx,4
  603.                 .if_2_e:
  604.  
  605.                 inc ebx
  606.                 cmp ebx,eax
  607.                 jle @b
  608.         mov ebx,[memCell]
  609.         mov dword[ebx],eax ;firstC <- eax
  610.  
  611.         mov dword[b_sort],eax
  612.         stdcall pole_fl_sort, dword[memCell],eax
  613.  
  614.         mov ecx,[memCell]
  615.         mov ebx,1
  616.         @@: ;for(i=1;i<=firstC;i++)
  617.                 add ecx,4
  618.                 get_cell_offset edx,[ecx]
  619.                 bt word[edx+12],1 ;+12 = .liv
  620.                 jae .no_change
  621.                         xor byte[edx+12],3 ;+12 = .liv
  622.                         mov edi,[tim]
  623.                         mov dword[edx+8],edi ;+8 = .tc
  624.                         bt word[edx+12],0 ;+12 = .liv
  625.                         jc .new_cell
  626.                                 push eax
  627.                                 mov edi,[edx]
  628.                                 dec edi
  629.                                 mov esi,[edx+4]
  630.                                 dec esi
  631.                                 dec dword[osob]
  632.                                 ;¤ «ìè¥ §­ ç¥­¨¥ edx ¯®àâ¨âáï
  633.                                 stdcall pole_cell_find,edi,esi
  634.                                 get_cell_offset edx,eax
  635.                                 dec byte[edx+13] ;+13 = .so
  636.                                 inc esi
  637.                                 stdcall pole_cell_find,edi,esi
  638.                                 get_cell_offset edx,eax
  639.                                 dec byte[edx+13] ;+13 = .so
  640.                                 inc esi
  641.                                 stdcall pole_cell_find,edi,esi
  642.                                 get_cell_offset edx,eax
  643.                                 dec byte[edx+13] ;+13 = .so
  644.                                 inc edi
  645.                                 stdcall pole_cell_find,edi,esi
  646.                                 get_cell_offset edx,eax
  647.                                 dec byte[edx+13] ;+13 = .so
  648.                                 sub esi,2
  649.                                 stdcall pole_cell_find,edi,esi
  650.                                 get_cell_offset edx,eax
  651.                                 dec byte[edx+13] ;+13 = .so
  652.                                 inc edi
  653.                                 stdcall pole_cell_find,edi,esi
  654.                                 get_cell_offset edx,eax
  655.                                 dec byte[edx+13] ;+13 = .so
  656.                                 inc esi
  657.                                 stdcall pole_cell_find,edi,esi
  658.                                 get_cell_offset edx,eax
  659.                                 dec byte[edx+13] ;+13 = .so
  660.                                 inc esi
  661.                                 stdcall pole_cell_find,edi,esi
  662.                                 get_cell_offset edx,eax
  663.                                 dec byte[edx+13] ;+13 = .so
  664.                                 pop eax
  665.                                 jmp .no_change
  666.                         .new_cell: ; ¯®ï¢¨« áì ­®¢ ï ï祩ª 
  667.                                 inc dword[osob]
  668.                                 mov edi,[edx]
  669.                                 dec edi
  670.                                 mov esi,[edx+4]
  671.                                 dec esi
  672.                                 stdcall pole_cell_creat,edi,esi,0
  673.                                 inc esi
  674.                                 stdcall pole_cell_creat,edi,esi,0
  675.                                 inc esi
  676.                                 stdcall pole_cell_creat,edi,esi,0
  677.                                 inc edi
  678.                                 stdcall pole_cell_creat,edi,esi,0
  679.                                 sub esi,2
  680.                                 stdcall pole_cell_creat,edi,esi,0
  681.                                 inc edi
  682.                                 stdcall pole_cell_creat,edi,esi,0
  683.                                 inc esi
  684.                                 stdcall pole_cell_creat,edi,esi,0
  685.                                 inc esi
  686.                                 stdcall pole_cell_creat,edi,esi,0
  687.                 .no_change:
  688.                 inc ebx
  689.                 cmp ebx,eax
  690.                 jle @b
  691.         .fun_e:
  692.         popad
  693.         ret
  694.  
  695. ;‘®àâ¨à®¢ª  ¢¥ªâ®à  a[1..n] ¬¥â®¤®¬ ”«®©¤ 
  696. align 4
  697. proc pole_fl_sort, a:dword, n:dword
  698.         pushad
  699.         mov ecx,[a]
  700.         ;”®à¬¨à®¢ âì ¨á室­®¥ ç áâ¨ç­® 㯮à冷祭­®¥ ¤¥à¥¢®
  701.         mov eax,[n]
  702.         shr eax,1
  703.         @@: ;for(i=n>>1; i>=2; i--)
  704.                 stdcall pole_fl_surface, ecx,eax,[n] ;(a,i,n)
  705.                 dec eax
  706.                 cmp eax,2
  707.                 jge @b
  708.         ;‚믮«­¨âì ¯à®æ¥¤ãà㠢ᯫëâ¨ï ”«®©¤  ¤«ï ª ¦¤®£® ¯®¤¤¥à¥¢ 
  709.         mov eax,[n]
  710.         @@: ;for(i=n; i>=2; i--){
  711.                 stdcall pole_fl_surface, ecx,1,eax ;(a,1,i)
  712.                 ;®¬¥áâ¨âì ­ ©¤¥­­ë© ¬ ªá¨¬ «ì­ë© í«¥¬¥­â ¢ ª®­¥æ ᯨ᪠
  713.                 mov edi,eax
  714.                 shl edi,2
  715.                 add edi,ecx ;edi -> &a[i]
  716.                 mov esi,[edi] ;w=a[i];
  717.                 mov edx,[ecx+4]
  718.                 mov dword[edi],edx ;a[i]=a[1];
  719.                 mov dword[ecx+4],esi ;a[1]=w;
  720.  
  721.                 dec eax
  722.                 cmp eax,2
  723.                 jge @b
  724.         popad
  725.         ret
  726. endp
  727.  
  728. ;à®æ¥¤ãà  ¢á¯«ëâ¨ï ”«®©¤  ¯® ¤¥à¥¢ã a[1..k]
  729. align 4
  730. proc pole_fl_surface, a:dword, i:dword, k:dword
  731. locals
  732.         copy dd ?
  733. endl
  734.         pushad
  735.         ;edx -> ...
  736.         ;edi -> m
  737.         ;esi -> j
  738.         mov eax,[a]
  739.         mov ebx,[i]
  740.         mov ecx,[k]
  741.  
  742.         mov edx,ebx
  743.         shl edx,2
  744.         add edx,eax
  745.         mov edx,[edx]
  746.         mov dword[copy],edx ;copy=a[i];
  747.         mov edi,ebx
  748.         shl edi,1 ;m=i<<1;
  749.         .cycle_b: ;while (m<=k) {
  750.                 cmp edi,ecx
  751.                 jg .cycle_e
  752.                 jne @f ;if (m==k) j=m;
  753.                         mov esi,edi
  754.                         jmp .else_e
  755.                 @@: ;else if (pole_compare_cells_bm(a[m],a[m+1])) j=m;
  756.                 mov edx,edi
  757.                 shl edx,2
  758.                 add edx,eax
  759.                 stdcall pole_compare_cells_bm, dword[edx],dword[edx+4]
  760.                 cmp dl,0
  761.                 je @f
  762.                         mov esi,edi
  763.                         jmp .else_e
  764.                 @@: ;else j=m+1;
  765.                         mov esi,edi
  766.                         inc esi
  767.                 .else_e:
  768.  
  769.                 ;if (pole_compare_cells_bm(a[j],copy)) {
  770.                 mov edx,esi
  771.                 shl edx,2
  772.                 add edx,eax
  773.                 stdcall pole_compare_cells_bm, dword[edx],dword[copy]
  774.                 cmp dl,0
  775.                 je .cycle_e ;} else break; //¢ë室 ¨§ 横« 
  776.  
  777.                 mov edx,esi
  778.                 shl edx,2
  779.                 add edx,eax
  780.                 push dword[edx] ;push a[j];
  781.                 mov edx,ebx
  782.                 shl edx,2
  783.                 add edx,eax
  784.                 pop dword[edx] ;a[i]=a[j];
  785.                 mov ebx,esi ;i=j;
  786.                 mov edi,ebx
  787.                 shl edi,1 ;m=i<<1;
  788.  
  789.                 jmp .cycle_b
  790.         .cycle_e:
  791.  
  792.         ;§­ ç¥­¨ï ¬­®£¨å ॣ¨áâ஢ 㦥 ­¥ ¢ ¦­ë â. ª. ª®­¥æ ä㭪樨
  793.         shl ebx,2
  794.         add eax,ebx
  795.         mov edx,[copy]
  796.         mov dword[eax],edx ;a[i]=copy;
  797.  
  798.         popad
  799.         ret
  800. endp
  801. ;--------------------------------------
  802.  
  803.  
  804. align 4
  805. start:
  806.         load_libraries l_libs_start,l_libs_end
  807.         ;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ­ è  «¨¡ 
  808.         mov     ebp,lib_7
  809.         cmp     dword [ebp+ll_struc_size-4],0
  810.         jz      @f
  811.                 mcall SF_TERMINATE_PROCESS ;exit not correct
  812.         @@:
  813.         mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
  814.         mcall SF_SET_EVENTS_MASK,0x27
  815.         stdcall [OpenDialog_Init],OpenDialog_data ;¯®¤£®â®¢ª  ¤¨ «®£ 
  816.  
  817.         stdcall [buf2d_create], buf_0 ;ᮧ¤ ­¨¥ ¡ãä¥à 
  818.  
  819.         stdcall mem.Alloc,MAX_CELL*sizeof.Cell
  820.         mov [cell],eax
  821.         stdcall mem.Alloc,MAX_CELL*4
  822.         mov [memCell],eax
  823.         stdcall mem.Alloc,(COL_MEM+1)*4
  824.         mov [CellColors],eax
  825.         include_image_file 'toolbar.png', image_data_toolbar
  826.  
  827.         ;­ áâனª  梥⮢ ï祥ª
  828.         stdcall pole_init_colors, 0xffffd0,0xff0000,0x0000ff
  829.         call pole_clear
  830.         call pole_paint ;à¨á®¢ ­¨¥ ¯®«ï ¢ ¡ãä¥à¥ (­¥ ­  íªà ­¥)
  831.  
  832.         ;xor eax,eax
  833.         ;mov edi,txt_zoom.zi
  834.         ;mov al,byte[zoom]
  835.         ;call tl_convert_to_str
  836.  
  837.         mcall SF_SYSTEM_GET,SSF_TIME_COUNT
  838.         mov [last_time],eax
  839.  
  840. align 4
  841. red_win:
  842.         call draw_window
  843.  
  844. align 4
  845. still:
  846.         mcall SF_SYSTEM_GET,SSF_TIME_COUNT
  847.         mov ebx,[last_time]
  848.         add ebx,10 ;§ ¤¥à¦ª 
  849.         cmp ebx,eax
  850.         jge @f
  851.                 mov ebx,eax
  852.         @@:
  853.         sub ebx,eax
  854.         mcall SF_WAIT_EVENT_TIMEOUT
  855.         cmp eax,0
  856.         je timer_funct
  857.  
  858.         cmp al,1
  859.         jz red_win
  860.         cmp al,2
  861.         jz key
  862.         cmp al,3
  863.         jz button
  864.  
  865.         jmp still
  866.  
  867. align 4
  868. timer_funct:
  869.         pushad
  870.         mcall SF_SYSTEM_GET,SSF_TIME_COUNT
  871.         mov [last_time],eax
  872.  
  873.         cmp byte[tim_ch],0
  874.         je @f
  875.                 ;call but_next_gen
  876.                 cld
  877.                 mov ecx,[poc_stop]
  878.                 cmp ecx,1
  879.                 jg .clear
  880.                         mov ecx,1 ;¨á¯à ¢«¥­¨¥ ecx ­  á«ãç © ç¨á¥« ¬¥­ìè¨å 1
  881.                         jmp .cycle
  882.                 .clear: ;ç¨á⨬ ¯®«¥ ¥á«¨ ¥áâì ¯à®áç¥â ­  ­¥áª®«ìª® ¯®ª®«¥­¨© §  1 â ªâ â ©¬¥à 
  883.                         stdcall [buf2d_clear], buf_0, [buf_0.color]
  884.                 .cycle:
  885.                         call pole_next_gen
  886.                         loop .cycle
  887.                 call pole_paint
  888.                 stdcall [buf2d_draw], buf_0
  889.                 call draw_pok
  890.         @@:
  891.         popad
  892.         jmp still
  893.  
  894. align 4
  895. draw_window:
  896. pushad
  897.         mcall SF_REDRAW,SSF_BEGIN_DRAW
  898.         mov edx,[sc.work]
  899.         or  edx,0x33000000
  900.         mov edi,hed
  901.         mcall SF_CREATE_WINDOW,(20 shl 16)+485,(20 shl 16)+415
  902.  
  903.         mcall SF_DEFINE_BUTTON,(5 shl 16)+20,(5 shl 16)+20,3, [sc.work_button]
  904.  
  905.         mov ebx,(30 shl 16)+20
  906.         mov edx,4
  907.         int 0x40
  908.  
  909.         mov ebx,(55 shl 16)+20
  910.         mov edx,5
  911.         int 0x40
  912.  
  913.         mov ebx,(85 shl 16)+20
  914.         mov edx,6
  915.         int 0x40
  916.  
  917.         mov ebx,(110 shl 16)+20
  918.         mov edx,7
  919.         int 0x40
  920.  
  921.         mov ebx,(135 shl 16)+20
  922.         mov edx,8
  923.         int 0x40
  924.  
  925.         mov ebx,(165 shl 16)+20
  926.         mov edx,9
  927.         int 0x40
  928.  
  929.         mov ebx,(190 shl 16)+20
  930.         mov edx,10
  931.         int 0x40
  932.  
  933.         mov ebx,(220 shl 16)+20
  934.         mov edx,11
  935.         int 0x40
  936.  
  937.         mov ebx,(245 shl 16)+20
  938.         mov edx,12
  939.         int 0x40
  940.  
  941.         mov ebx,(270 shl 16)+20
  942.         mov edx,13
  943.         int 0x40
  944.  
  945.         mov ebx,(295 shl 16)+20
  946.         mov edx,14
  947.         int 0x40
  948.  
  949.         mcall SF_PUT_IMAGE,[image_data_toolbar],(16 shl 16)+16,(32 shl 16)+7
  950.  
  951.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  952.         mov edx,(87 shl 16)+7 ;run once
  953.         int 0x40
  954.  
  955.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  956.         mov edx,(112 shl 16)+7 ;run auto
  957.         int 0x40
  958.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  959.         mov edx,(137 shl 16)+7 ;stop
  960.         int 0x40
  961.  
  962.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  963.         mov edx,(167 shl 16)+7 ;-
  964.         int 0x40
  965.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  966.         mov edx,(192 shl 16)+7 ;+
  967.         int 0x40
  968.  
  969.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  970.         mov edx,(222 shl 16)+7 ;move up
  971.         int 0x40
  972.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  973.         mov edx,(247 shl 16)+7 ;move doun
  974.         int 0x40
  975.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  976.         mov edx,(272 shl 16)+7 ;move left
  977.         int 0x40
  978.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  979.         mov edx,(297 shl 16)+7 ;move up
  980.         int 0x40
  981.  
  982.         call draw_pok
  983.  
  984.         stdcall [buf2d_draw], buf_0
  985.  
  986.         mcall SF_REDRAW,SSF_END_DRAW
  987. popad
  988.         ret
  989.  
  990. align 4
  991. draw_pok:
  992.         mov eax,SF_DRAW_TEXT
  993.         mov ebx,325*65536+5
  994.         mov ecx,[sc.work_text]
  995.         or  ecx,0x80000000 ;or (1 shl 30)
  996.         mov edx,txt_zoom
  997.         ;mov edi,[sc.work]
  998.         int 0x40
  999.         add bx,9
  1000.         mov edx,txt_gen
  1001.         int 0x40
  1002.         add bx,9
  1003.         mov edx,txt_osob
  1004.         int 0x40
  1005.  
  1006.         mov eax,SF_DRAW_NUMBER
  1007.         xor ecx,ecx
  1008.         mov cl,byte[zoom]
  1009.         mov ebx,(2 shl 16)
  1010.         mov edx,(325+6*9)*65536+5
  1011.         mov esi,[sc.work_button_text]
  1012.         or  esi,(1 shl 30)
  1013.         mov edi,[sc.work_button]
  1014.         int 0x40 ;¬ áèâ ¡
  1015.         mov ebx,(5 shl 16)
  1016.         mov ecx,[tim]
  1017.         add edx,(6*2)*65536+9
  1018.         int 0x40 ;¢à¥¬ï
  1019.         mov ebx,(5 shl 16)
  1020.         mov ecx,[osob]
  1021.         add edx,(6*0)*65536+9
  1022.         int 0x40 ;¯®¯ã«ïæ¨ï
  1023.         ret
  1024.  
  1025. align 4
  1026. key:
  1027.         mcall SF_GET_KEY
  1028.         jmp still
  1029.  
  1030.  
  1031. align 4
  1032. button:
  1033.         mcall SF_GET_BUTTON
  1034.         cmp ah,3
  1035.         jne @f
  1036.                 call but_new_file
  1037.                 jmp still
  1038.         @@:
  1039.         cmp ah,4
  1040.         jne @f
  1041.                 call but_open_file
  1042.                 jmp still
  1043.         @@:
  1044.         cmp ah,5
  1045.         jne @f
  1046.                 call but_save_file
  1047.                 jmp still
  1048.         @@:
  1049.         cmp ah,6
  1050.         jne @f
  1051.                 call but_next_gen
  1052.                 jmp still
  1053.         @@:
  1054.         cmp ah,7
  1055.         jne @f
  1056.                 call but_run
  1057.                 jmp still
  1058.         @@:
  1059.         cmp ah,8
  1060.         jne @f
  1061.                 call but_stop
  1062.                 jmp still
  1063.         @@:
  1064.         cmp ah,9
  1065.         jne @f
  1066.                 call but_zoom_p
  1067.                 jmp still
  1068.         @@:
  1069.         cmp ah,10
  1070.         jne @f
  1071.                 call but_zoom_m
  1072.                 jmp still
  1073.         @@:
  1074.         cmp ah,11
  1075.         jne @f
  1076.                 call but_pole_up
  1077.                 jmp still
  1078.         @@:
  1079.         cmp ah,12
  1080.         jne @f
  1081.                 call but_pole_dn
  1082.                 jmp still
  1083.         @@:
  1084.         cmp ah,13
  1085.         jne @f
  1086.                 call but_pole_left
  1087.                 jmp still
  1088.         @@:
  1089.         cmp ah,14
  1090.         jne @f
  1091.                 call but_pole_right
  1092.                 jmp still
  1093.         @@:
  1094.         cmp ah,1
  1095.         jne still
  1096. .exit:
  1097.         stdcall [buf2d_delete],buf_0
  1098.         stdcall mem.Free,[open_file_lif]
  1099.         stdcall mem.Free,[cell]
  1100.         stdcall mem.Free,[memCell]
  1101.         stdcall mem.Free,[CellColors]
  1102.         stdcall mem.Free,[image_data_toolbar]
  1103.         mcall SF_TERMINATE_PROCESS
  1104.  
  1105.  
  1106. align 4
  1107. but_new_file:
  1108.         ret
  1109.  
  1110. align 4
  1111. open_file_lif dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï ®âªàëâ¨ï ä ©«®¢
  1112. open_file_size dd 0 ;à §¬¥à ®âªàë⮣® ä ©« 
  1113.  
  1114. align 4
  1115. but_open_file:
  1116.         pushad
  1117.         copy_path open_dialog_name,communication_area_default_path,file_name,0
  1118.         mov [OpenDialog_data.type],0
  1119.         stdcall [OpenDialog_Start],OpenDialog_data
  1120.         cmp [OpenDialog_data.status],2
  1121.         je .end_open_file
  1122.         ;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
  1123.  
  1124.         mov [run_file_70.Function], SSF_GET_INFO
  1125.         mov [run_file_70.Position], 0
  1126.         mov [run_file_70.Flags], 0
  1127.         mov dword[run_file_70.Count], 0
  1128.         mov dword[run_file_70.Buffer], open_b
  1129.         mov byte[run_file_70+20], 0
  1130.         mov dword[run_file_70.FileName], openfile_path
  1131.         mcall SF_FILE,run_file_70
  1132.  
  1133.         mov ecx,dword[open_b+32] ;+32 qword: à §¬¥à ä ©«  ¢ ¡ ©â å
  1134.         inc ecx ;for text files
  1135.         stdcall mem.ReAlloc,[open_file_lif],ecx
  1136.         mov [open_file_lif],eax
  1137.         dec ecx ;for text files
  1138.         mov byte[eax+ecx],0 ;for text files
  1139.        
  1140.         mov [run_file_70.Function], SSF_READ_FILE
  1141.         mov [run_file_70.Position], 0
  1142.         mov [run_file_70.Flags], 0
  1143.         mov [run_file_70.Count], ecx
  1144.         m2m dword[run_file_70.Buffer], dword[open_file_lif]
  1145.         mov byte[run_file_70+20], 0
  1146.         mov dword[run_file_70.FileName], openfile_path
  1147.         mcall SF_FILE,run_file_70 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
  1148.         test eax,eax
  1149.         jnz .end_open_file
  1150.         cmp ebx,0xffffffff
  1151.         je .end_open_file
  1152.  
  1153.         mov [open_file_size],ebx
  1154.         mcall SF_SET_CAPTION,1,openfile_path
  1155.  
  1156.         call pole_clear
  1157.         mov eax,[buf_0.w]
  1158.         shr eax,1
  1159.         xor ecx,ecx
  1160.         mov cl,byte[zoom]
  1161.         cmp cx,2
  1162.         jl @f ;¤¥«¥­¨¥ ­  ¢¥«¨ç¨­ã zoom
  1163.                 xor edx,edx
  1164.                 div ecx
  1165.         @@:
  1166.         add [Cor_x],eax
  1167.         mov eax,[buf_0.h]
  1168.         shr eax,1
  1169.         cmp cx,2
  1170.         jl @f ;¤¥«¥­¨¥ ­  ¢¥«¨ç¨­ã zoom
  1171.                 xor edx,edx
  1172.                 div ecx
  1173.         @@:
  1174.         add [Cor_y],eax
  1175.  
  1176.         ;eax - first x position
  1177.         ;ebx - x position
  1178.         ;ecx - y position
  1179.         ;edx - ª®­¥æ ä ©« 
  1180.         mov edi,[open_file_lif]
  1181.         xor ebx,ebx
  1182.         xor ecx,ecx
  1183.         mov eax,ebx
  1184.         mov edx,[open_file_lif]
  1185.         add edx,[open_file_size]
  1186.         @@:
  1187.                 cmp byte[edi],'*'
  1188.                 jne .no_cell
  1189.                         stdcall pole_cell_creat, ebx,ecx,1
  1190.                         inc ebx
  1191.                 .no_cell:
  1192.                 cmp byte[edi],'.'
  1193.                 jne .cell_move
  1194.                         inc ebx
  1195.                 .cell_move:
  1196.                 cmp byte[edi],13
  1197.                 jne .cell_nl
  1198.                         mov ebx,eax
  1199.                         inc ecx
  1200.                 .cell_nl:
  1201.                 cmp word[edi],'#P' ;ᬥ­  ¯®§¨æ¨¨
  1202.                 jne .pos
  1203.                         inc edi ;¯à®¯ã᪠'#'
  1204.                         .space:
  1205.                                 inc edi ;¯à®¯ã᪠'P' ¨ ' '
  1206.                                 cmp byte[edi],' '
  1207.                                 je .space
  1208.                         stdcall conv_str_to_int,edi
  1209.                         mov ebx,eax
  1210.                         cmp byte[edi],'-'
  1211.                         jne .digit
  1212.                                 inc edi
  1213.                         .digit:
  1214.                                 cmp byte[edi],'0'
  1215.                                 jl .digit_no
  1216.                                 cmp byte[edi],'9'
  1217.                                 jg .digit_no
  1218.                                 inc edi
  1219.                                 jmp .digit
  1220.                         .digit_no:
  1221.                         ;.space_1:
  1222.                                 inc edi ;¯à®¯ã᪠'P' ¨ ' '
  1223.                                 cmp byte[edi],' '
  1224.                                 je .digit_no ;.space_1
  1225.                         stdcall conv_str_to_int,edi
  1226.                         mov ecx,eax
  1227.                         mov eax,ebx ;¢®ááâ ­®¢«¥­¨¥ «¥¢®£® ®âáâ㯠 ¢ eax
  1228.                 .pos:
  1229.                 inc edi
  1230.                 cmp edi,edx
  1231.                 jl @b
  1232.         ;---
  1233.         stdcall [buf2d_clear], buf_0, [buf_0.color] ;ç¨á⨬ ¡ãä¥à
  1234.         call pole_paint ;à¨á㥬 ¯®«¥ (­  á«ãç © ¥á«¨ ¥áâì á¥âª  ¨«¨ ⥪áâ®¢ë¥ ¯®¤¯¨á¨)
  1235.         stdcall [buf2d_draw], buf_0 ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
  1236.         .end_open_file:
  1237.         popad
  1238.         ret
  1239.  
  1240. align 4
  1241. but_save_file:
  1242.         ret
  1243.  
  1244. align 4
  1245. but_next_gen:
  1246.         call pole_next_gen
  1247.         call pole_paint
  1248.         stdcall [buf2d_draw], buf_0
  1249.         pushad
  1250.                 call draw_pok
  1251.         popad
  1252.         ret
  1253.  
  1254. align 4
  1255. but_run:
  1256.         mov byte[tim_ch],1
  1257.         ret
  1258.  
  1259. align 4
  1260. but_stop:
  1261.         mov byte[tim_ch],0
  1262.         ;cld
  1263.         ;mov ecx,100
  1264.         ;@@:
  1265.         ;       call pole_next_gen
  1266.         ;loop @b
  1267.         ;stdcall [buf2d_clear], buf_0, [buf_0.color]
  1268.         ;call pole_paint
  1269.         ;stdcall [buf2d_draw], buf_0
  1270.         ret
  1271.  
  1272. align 4
  1273. but_zoom_p:
  1274.         cmp byte[zoom],16
  1275.         jge @f
  1276.                 pushad
  1277.                 ;¢ëç¨á«¥­¨¥ ᤢ¨£®¢ ¤«ï ¯®«ï, ª®â®àë¥ ®¡¥á¯¥ç â 業â஢ªã ¯®«ï ¯à¨ 㢥«¨ç¥­¨¨ ¬ áèâ ¡ 
  1278.                 xor ecx,ecx
  1279.                 mov cl,byte[zoom]
  1280.                 xor edx,edx
  1281.                 mov eax,[buf_0.w]
  1282.                 shr eax,1 ;¢ eax ¯®«®¢¨­  è¨à¨­ë ¯®«ï
  1283.                 mov ebx,eax ;¤¥« ¥¬ १¥à¢­ãî ª®¯¨î eax
  1284.                 div ecx ;¤¥«¨¬ eax ­  ⥪ã騩 ¬ áèâ ¡
  1285.                 xchg eax,ebx
  1286.                 xor edx,edx
  1287.                 inc ecx
  1288.                 div ecx ;¤¥«¨¬ eax ­  ­®¢ë© ¬ áèâ ¡
  1289.                 sub ebx,eax ;¢ëç¨á«ï¥âáï ᤢ¨£ ¯®«ï ª®â®àë© ®¡¥á¯¥ç¨â 業â஢ªã ¯®«ï
  1290.                 sub dword[Cor_x],ebx ;ᤢ¨£ ¥¬ ¯®«¥ §à¥­¨ï ¯® ®á¨ x
  1291.                 xor ecx,ecx
  1292.                 mov cl,byte[zoom]
  1293.                 xor edx,edx
  1294.                 mov eax,[buf_0.h]
  1295.                 shr eax,1
  1296.                 mov ebx,eax
  1297.                 div ecx
  1298.                 xchg eax,ebx
  1299.                 xor edx,edx
  1300.                 inc ecx
  1301.                 div ecx
  1302.                 sub ebx,eax
  1303.                 sub dword[Cor_y],ebx ;ᤢ¨£ ¥¬ ¯®«¥ §à¥­¨ï ¯® ®á¨ y
  1304.  
  1305.                 inc byte[zoom]
  1306.                 ;xor eax,eax
  1307.                 ;mov edi,txt_zoom.zi
  1308.                 ;mov al,byte[zoom]
  1309.                 ;call tl_convert_to_str
  1310.                 call draw_pok
  1311.                 popad
  1312.  
  1313.                 cmp dword[poc_stop],1
  1314.                 jle .buf_clear
  1315.                 cmp byte[tim_ch],0
  1316.                 jne @f
  1317.                         .buf_clear:
  1318.                         stdcall [buf2d_clear], buf_0, [buf_0.color]
  1319.                         call pole_paint
  1320.                         stdcall [buf2d_draw], buf_0
  1321.         @@:
  1322.         ret
  1323.  
  1324. align 4
  1325. but_zoom_m:
  1326.         cmp byte[zoom],1
  1327.         jle @f
  1328.                 pushad
  1329.                 ;¢ëç¨á«¥­¨¥ ᤢ¨£®¢ ¤«ï ¯®«ï, ª®â®àë¥ ®¡¥á¯¥ç â 業â஢ªã ¯®«ï ¯à¨ 㬥­ì襭¨¨ ¬ áèâ ¡ 
  1330.                 xor ecx,ecx
  1331.                 mov cl,byte[zoom]
  1332.                 xor edx,edx
  1333.                 mov eax,[buf_0.w]
  1334.                 shr eax,1 ;¢ eax ¯®«®¢¨­  è¨à¨­ë ¯®«ï
  1335.                 mov ebx,eax ;¤¥« ¥¬ १¥à¢­ãî ª®¯¨î eax
  1336.                 div ecx ;¤¥«¨¬ eax ­  ⥪ã騩 ¬ áèâ ¡
  1337.                 xchg eax,ebx
  1338.                 xor edx,edx
  1339.                 dec ecx
  1340.                 div ecx ;¤¥«¨¬ eax ­  ­®¢ë© ¬ áèâ ¡
  1341.                 sub ebx,eax ;¢ëç¨á«ï¥âáï ᤢ¨£ ¯®«ï ª®â®àë© ®¡¥á¯¥ç¨â 業â஢ªã ¯®«ï
  1342.                 sub dword[Cor_x],ebx ;ᤢ¨£ ¥¬ ¯®«¥ §à¥­¨ï ¯® ®á¨ x
  1343.                 xor ecx,ecx
  1344.                 mov cl,byte[zoom]
  1345.                 xor edx,edx
  1346.                 mov eax,[buf_0.h]
  1347.                 shr eax,1
  1348.                 mov ebx,eax
  1349.                 div ecx
  1350.                 xchg eax,ebx
  1351.                 xor edx,edx
  1352.                 dec ecx
  1353.                 div ecx
  1354.                 sub ebx,eax
  1355.                 sub dword[Cor_y],ebx ;ᤢ¨£ ¥¬ ¯®«¥ §à¥­¨ï ¯® ®á¨ y
  1356.  
  1357.                 dec byte[zoom]
  1358.                 ;xor eax,eax
  1359.                 ;mov edi,txt_zoom.zi
  1360.                 ;mov al,byte[zoom]
  1361.                 ;call tl_convert_to_str
  1362.                 call draw_pok
  1363.                 popad
  1364.  
  1365.                 cmp dword[poc_stop],1
  1366.                 jle .buf_clear
  1367.                 cmp byte[tim_ch],0
  1368.                 jne @f
  1369.                         .buf_clear:
  1370.                         stdcall [buf2d_clear], buf_0, [buf_0.color]
  1371.                         call pole_paint
  1372.                         stdcall [buf2d_draw], buf_0
  1373.         @@:
  1374.         ret
  1375.  
  1376. align 4
  1377. but_pole_up:
  1378.         push eax ecx edx
  1379.         mov eax,[buf_0.h]
  1380.         shr eax,2
  1381.         xor ecx,ecx
  1382.         mov cl,byte[zoom]
  1383.         cmp cx,2
  1384.         jl @f ;¤¥«¥­¨¥ ­  ¢¥«¨ç¨­ã zoom
  1385.                 xor edx,edx
  1386.                 div ecx
  1387.         @@:
  1388.         add dword[Cor_y],eax
  1389.         pop edx ecx eax
  1390.         stdcall [buf2d_clear], buf_0, [buf_0.color]
  1391.         call pole_paint
  1392.         stdcall [buf2d_draw], buf_0
  1393.         ret
  1394.  
  1395. align 4
  1396. but_pole_dn:
  1397.         push eax ecx edx
  1398.         mov eax,[buf_0.h]
  1399.         shr eax,2
  1400.         xor ecx,ecx
  1401.         mov cl,byte[zoom]
  1402.         cmp cx,2
  1403.         jl @f ;¤¥«¥­¨¥ ­  ¢¥«¨ç¨­ã zoom
  1404.                 xor edx,edx
  1405.                 div ecx
  1406.         @@:
  1407.         sub dword[Cor_y],eax
  1408.         pop edx ecx eax
  1409.         stdcall [buf2d_clear], buf_0, [buf_0.color]
  1410.         call pole_paint
  1411.         stdcall [buf2d_draw], buf_0
  1412.         ret
  1413.  
  1414. align 4
  1415. but_pole_left:
  1416.         push eax ecx edx
  1417.         mov eax,[buf_0.w]
  1418.         shr eax,2
  1419.         xor ecx,ecx
  1420.         mov cl,byte[zoom]
  1421.         cmp cx,2
  1422.         jl @f ;¤¥«¥­¨¥ ­  ¢¥«¨ç¨­ã zoom
  1423.                 xor edx,edx
  1424.                 div ecx
  1425.         @@:
  1426.         add dword[Cor_x],eax
  1427.         pop edx ecx eax
  1428.         stdcall [buf2d_clear], buf_0, [buf_0.color]
  1429.         call pole_paint
  1430.         stdcall [buf2d_draw], buf_0
  1431.         ret
  1432.  
  1433. align 4
  1434. but_pole_right:
  1435.         push eax ecx edx
  1436.         mov eax,[buf_0.w]
  1437.         shr eax,2
  1438.         xor ecx,ecx
  1439.         mov cl,byte[zoom]
  1440.         cmp cx,2
  1441.         jl @f ;¤¥«¥­¨¥ ­  ¢¥«¨ç¨­ã zoom
  1442.                 xor edx,edx
  1443.                 div ecx
  1444.         @@:
  1445.         sub dword[Cor_x],eax
  1446.         pop edx ecx eax
  1447.         stdcall [buf2d_clear], buf_0, [buf_0.color]
  1448.         call pole_paint
  1449.         stdcall [buf2d_draw], buf_0
  1450.         ret
  1451.  
  1452. ;align 4
  1453. ;but_bru_clear:
  1454. ;        ret
  1455.  
  1456. ;input:
  1457. ; buf - 㪠§ â¥«ì ­  áâபã, ç¨á«® ¤®«¦­® ¡ëâì ¢ 10 ¨«¨ 16 à¨ç­®¬ ¢¨¤¥
  1458. ;output:
  1459. ; eax - ç¨á«®
  1460. align 4
  1461. proc conv_str_to_int, buf:dword
  1462.         xor eax,eax
  1463.         push ebx ecx esi
  1464.         xor ebx,ebx
  1465.         mov esi,[buf]
  1466.         ;®¯à¥¤¥«¥­¨¥ ®âà¨æ â¥«ì­ëå ç¨á¥«
  1467.         xor ecx,ecx
  1468.         inc ecx
  1469.         cmp byte[esi],'-'
  1470.         jne @f
  1471.                 dec ecx
  1472.                 inc esi
  1473.         @@:
  1474.  
  1475.         cmp word[esi],'0x'
  1476.         je .load_digit_16
  1477.  
  1478.         .load_digit_10: ;áç¨â뢠­¨¥ 10-â¨ç­ëå æ¨äà
  1479.                 mov bl,byte[esi]
  1480.                 cmp bl,'0'
  1481.                 jl @f
  1482.                 cmp bl,'9'
  1483.                 jg @f
  1484.                         sub bl,'0'
  1485.                         imul eax,10
  1486.                         add eax,ebx
  1487.                         inc esi
  1488.                         jmp .load_digit_10
  1489.         jmp @f
  1490.  
  1491.         .load_digit_16: ;áç¨â뢠­¨¥ 16-à¨ç­ëå æ¨äà
  1492.                 add esi,2
  1493.         .cycle_16:
  1494.                 mov bl,byte[esi]
  1495.                 cmp bl,'0'
  1496.                 jl @f
  1497.                 cmp bl,'f'
  1498.                 jg @f
  1499.                 cmp bl,'9'
  1500.                 jle .us1
  1501.                         cmp bl,'A'
  1502.                         jl @f ;®âᥨ¢ ¥¬ ᨬ¢®«ë >'9' ¨ <'A'
  1503.                 .us1: ;á®áâ ¢­®¥ ãá«®¢¨¥
  1504.                 cmp bl,'F'
  1505.                 jle .us2
  1506.                         cmp bl,'a'
  1507.                         jl @f ;®âᥨ¢ ¥¬ ᨬ¢®«ë >'F' ¨ <'a'
  1508.                         sub bl,32 ;¯¥à¥¢®¤¨¬ ᨬ¢®«ë ¢ ¢¥àå­¨© ॣ¨áâà, ¤«ï ã¯à®é¥­¨ï ¨å ¯®á«¥¤ã饩 ®¡à ¡®âª¨
  1509.                 .us2: ;á®áâ ¢­®¥ ãá«®¢¨¥
  1510.                         sub bl,'0'
  1511.                         cmp bl,9
  1512.                         jle .cor1
  1513.                                 sub bl,7 ;convert 'A' to '10'
  1514.                         .cor1:
  1515.                         shl eax,4
  1516.                         add eax,ebx
  1517.                         inc esi
  1518.                         jmp .cycle_16
  1519.         @@:
  1520.         cmp ecx,0 ;¥á«¨ ç¨á«® ®âà¨æ â¥«ì­®¥
  1521.         jne @f
  1522.                 sub ecx,eax
  1523.                 mov eax,ecx
  1524.         @@:
  1525.         pop esi ecx ebx
  1526.         ret
  1527. endp
  1528.  
  1529. ;¤ ­­ë¥ ¤«ï ¤¨ «®£  ®âªàëâ¨ï ä ©«®¢
  1530. align 4
  1531. OpenDialog_data:
  1532. .type                   dd 0 ;0 - ®âªàëâì, 1 - á®åà ­¨âì, 2 - ¢ë¡à âì ¤â४â®à¨î
  1533. .procinfo               dd procinfo     ;+4
  1534. .com_area_name          dd communication_area_name      ;+8
  1535. .com_area               dd 0    ;+12
  1536. .opendir_path           dd plugin_path  ;+16
  1537. .dir_default_path       dd default_dir ;+20
  1538. .start_path             dd file_name ;+24 ¯ãâì ª ¤¨ «®£ã ®âªàëâ¨ï ä ©«®¢
  1539. .draw_window            dd draw_window  ;+28
  1540. .status                 dd 0    ;+32
  1541. .openfile_path          dd openfile_path        ;+36 ¯ãâì ª ®âªà뢠¥¬®¬ã ä ©«ã
  1542. .filename_area          dd filename_area        ;+40
  1543. .filter_area            dd Filter
  1544. .x:
  1545. .x_size                 dw 420 ;+48 ; Window X size
  1546. .x_start                dw 10 ;+50 ; Window X position
  1547. .y:
  1548. .y_size                 dw 320 ;+52 ; Window y size
  1549. .y_start                dw 10 ;+54 ; Window Y position
  1550.  
  1551. default_dir db '/rd/1',0
  1552.  
  1553. communication_area_name:
  1554.         db 'FFFFFFFF_open_dialog',0
  1555. open_dialog_name:
  1556.         db 'opendial',0
  1557. communication_area_default_path:
  1558.         db '/rd/1/File managers/',0
  1559.  
  1560. Filter:
  1561. dd Filter.end - Filter ;.1
  1562. .1:
  1563. db 'LIF',0
  1564. db 'RLE',0
  1565. .end:
  1566. db 0
  1567.  
  1568.  
  1569.  
  1570. head_f_i:
  1571. head_f_l db '‘¨á⥬­ ï ®è¨¡ª ',0
  1572.  
  1573. system_dir_0 db '/sys/lib/'
  1574. lib_name_0 db 'proc_lib.obj',0
  1575. err_message_found_lib_0 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'proc_lib.obj',39,0
  1576. err_message_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,0
  1577.  
  1578. system_dir_1 db '/sys/lib/'
  1579. lib_name_1 db 'libimg.obj',0
  1580. err_message_found_lib_1 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'libimg.obj',39,0
  1581. err_message_import_1 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'libimg.obj',39,0
  1582.  
  1583. system_dir_7 db '/sys/lib/'
  1584. lib_name_7 db 'buf2d.obj',0
  1585. err_msg_found_lib_7 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'buf2d.obj',39,0
  1586. err_msg_import_7 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'buf2d',39,0
  1587.  
  1588. l_libs_start:
  1589.         lib0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
  1590.                 err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i
  1591.         lib1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\
  1592.                 err_message_found_lib_1, head_f_l, import_libimg, err_message_import_1, head_f_i
  1593.         lib_7 l_libs lib_name_7, sys_path, library_path, system_dir_7,\
  1594.                 err_msg_found_lib_7,head_f_l,import_buf2d,err_msg_import_7,head_f_i
  1595. l_libs_end:
  1596.  
  1597. align 4
  1598. import_libimg:
  1599.         dd alib_init1
  1600.         img_is_img  dd aimg_is_img
  1601.         img_info    dd aimg_info
  1602.         img_from_file dd aimg_from_file
  1603.         img_to_file dd aimg_to_file
  1604.         img_from_rgb dd aimg_from_rgb
  1605.         img_to_rgb  dd aimg_to_rgb
  1606.         img_to_rgb2 dd aimg_to_rgb2
  1607.         img_decode  dd aimg_decode
  1608.         img_encode  dd aimg_encode
  1609.         img_create  dd aimg_create
  1610.         img_destroy dd aimg_destroy
  1611.         img_destroy_layer dd aimg_destroy_layer
  1612.         img_count   dd aimg_count
  1613.         img_lock_bits dd aimg_lock_bits
  1614.         img_unlock_bits dd aimg_unlock_bits
  1615.         img_flip    dd aimg_flip
  1616.         img_flip_layer dd aimg_flip_layer
  1617.         img_rotate  dd aimg_rotate
  1618.         img_rotate_layer dd aimg_rotate_layer
  1619.         img_draw    dd aimg_draw
  1620.  
  1621.         dd 0,0
  1622.         alib_init1   db 'lib_init',0
  1623.         aimg_is_img  db 'img_is_img',0 ;®¯à¥¤¥«ï¥â ¯® ¤ ­­ë¬, ¬®¦¥â «¨ ¡¨¡«¨®â¥ª  ᤥ« âì ¨§ ­¨å ¨§®¡à ¦¥­¨¥
  1624.         aimg_info    db 'img_info',0
  1625.         aimg_from_file db 'img_from_file',0
  1626.         aimg_to_file db 'img_to_file',0
  1627.         aimg_from_rgb db 'img_from_rgb',0
  1628.         aimg_to_rgb  db 'img_to_rgb',0 ;¯à¥®¡à §®¢ ­¨¥ ¨§®¡à ¦¥­¨ï ¢ ¤ ­­ë¥ RGB
  1629.         aimg_to_rgb2 db 'img_to_rgb2',0
  1630.         aimg_decode  db 'img_decode',0 ; ¢â®¬ â¨ç¥áª¨ ®¯à¥¤¥«ï¥â ä®à¬ â £à ä¨ç¥áª¨å ¤ ­­ëå
  1631.         aimg_encode  db 'img_encode',0
  1632.         aimg_create  db 'img_create',0
  1633.         aimg_destroy db 'img_destroy',0
  1634.         aimg_destroy_layer db 'img_destroy_layer',0
  1635.         aimg_count   db 'img_count',0
  1636.         aimg_lock_bits db 'img_lock_bits',0
  1637.         aimg_unlock_bits db 'img_unlock_bits',0
  1638.         aimg_flip    db 'img_flip',0
  1639.         aimg_flip_layer db 'img_flip_layer',0
  1640.         aimg_rotate  db 'img_rotate',0
  1641.         aimg_rotate_layer db 'img_rotate_layer',0
  1642.         aimg_draw    db 'img_draw',0
  1643.  
  1644. align 4
  1645. proclib_import: ;®¯¨á ­¨¥ íªá¯®àâ¨à㥬ëå ä㭪権
  1646.         OpenDialog_Init dd aOpenDialog_Init
  1647.         OpenDialog_Start dd aOpenDialog_Start
  1648. dd 0,0
  1649.         aOpenDialog_Init db 'OpenDialog_init',0
  1650.         aOpenDialog_Start db 'OpenDialog_start',0
  1651.  
  1652. align 4
  1653. import_buf2d:
  1654.         init dd sz_init
  1655.         buf2d_create dd sz_buf2d_create
  1656.         buf2d_create_f_img dd sz_buf2d_create_f_img
  1657.         buf2d_clear dd sz_buf2d_clear
  1658.         buf2d_draw dd sz_buf2d_draw
  1659.         buf2d_delete dd sz_buf2d_delete
  1660.         buf2d_line dd sz_buf2d_line
  1661.         buf2d_rect_by_size dd sz_buf2d_rect_by_size
  1662.         buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size
  1663.         buf2d_circle dd sz_buf2d_circle
  1664.         buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
  1665.         buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
  1666.         buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
  1667.         buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
  1668.         buf2d_bit_blt dd sz_buf2d_bit_blt
  1669.         buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
  1670.         buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
  1671.         buf2d_curve_bezier dd sz_buf2d_curve_bezier
  1672.         buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
  1673.         buf2d_draw_text dd sz_buf2d_draw_text
  1674.         buf2d_crop_color dd sz_buf2d_crop_color
  1675.         buf2d_offset_h dd sz_buf2d_offset_h
  1676.         buf2d_flood_fill dd sz_buf2d_flood_fill
  1677.         buf2d_set_pixel dd sz_buf2d_set_pixel
  1678.         dd 0,0
  1679.         sz_init db 'lib_init',0
  1680.         sz_buf2d_create db 'buf2d_create',0
  1681.         sz_buf2d_create_f_img db 'buf2d_create_f_img',0
  1682.         sz_buf2d_clear db 'buf2d_clear',0
  1683.         sz_buf2d_draw db 'buf2d_draw',0
  1684.         sz_buf2d_delete db 'buf2d_delete',0
  1685.         sz_buf2d_line db 'buf2d_line',0
  1686.         sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0
  1687.         sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0
  1688.         sz_buf2d_circle db 'buf2d_circle',0
  1689.         sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
  1690.         sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
  1691.         sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
  1692.         sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
  1693.         sz_buf2d_bit_blt db 'buf2d_bit_blt',0
  1694.         sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
  1695.         sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
  1696.         sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
  1697.         sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
  1698.         sz_buf2d_draw_text db 'buf2d_draw_text',0
  1699.         sz_buf2d_crop_color db 'buf2d_crop_color',0
  1700.         sz_buf2d_offset_h db 'buf2d_offset_h',0
  1701.         sz_buf2d_flood_fill db 'buf2d_flood_fill',0
  1702.         sz_buf2d_set_pixel db 'buf2d_set_pixel',0
  1703.  
  1704. mouse_dd dd 0x0
  1705. sc system_colors
  1706. last_time dd 0
  1707.  
  1708. align 16
  1709. procinfo process_information
  1710.  
  1711. align 4
  1712. buf_0: dd 0 ;a? § a?«i ­  ?aa?a ?§®?a ¦?­?i
  1713.         dw 5 ;+4 left
  1714.         dw 35 ;+6 top
  1715. .w: dd 460 ;+8 w
  1716. .h: dd 340 ;+12 h
  1717. .color: dd 0xffffd0 ;+16 color
  1718.         db 24 ;+20 bit in pixel
  1719.  
  1720. ;íâ®â ª®¤ ­¥ ¬®©, ®­ ¯à¥®¡à §ã¥â ç¨á«® ¢ áâபã
  1721. ;input:
  1722. ; eax = value
  1723. ; edi = string buffer
  1724. ;output:
  1725. align 4
  1726. tl_convert_to_str:
  1727.         pushad
  1728.                 mov dword[edi+1],0
  1729.                 call .str
  1730.         popad
  1731.         ret
  1732.  
  1733. align 4
  1734. .str:
  1735.         mov ecx,0x0a ;§ ¤ ¥âáï á¨á⥬  áç¨á«¥­¨ï ¨§¬¥­ïîâáï ॣ¨áâàë ebx,eax,ecx,edx ¢å®¤­ë¥ ¯ à ¬¥âàë eax - ç¨á«®
  1736.     ;¯à¥à¥¢®¤ ç¨á«  ¢ ASCII áâப㠢§®¤­ë¥ ¤ ­­ë¥ ecx=á¨á⥬  áç¨á«¥­ï edi  ¤à¥á ªã¤  § ¯¨á뢠âì, ¡ã¤¥¬ áâபã, ¯à¨ç¥¬ ª®­¥æ ¯¥à¥¬¥­­®©
  1737.         cmp eax,ecx  ;áà ¢­¨âì ¥á«¨ ¢ eax ¬¥­ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ ­  @@-1 â.¥. ­  pop eax
  1738.         jb @f
  1739.                 xor edx,edx  ;®ç¨áâ¨âì edx
  1740.                 div ecx      ;à §¤¥«¨âì - ®áâ â®ª ¢ edx
  1741.                 push edx     ;¯®«®¦¨âì ¢ á⥪
  1742.                 ;dec edi             ;ᬥ饭¨¥ ­¥®¡å®¤¨¬®¥ ¤«ï § ¯¨á¨ á ª®­æ  áâப¨
  1743.                 call .str ;¯¥à¥©â¨ ­  á ¬ã ᥡï â.¥. ¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥­â  ¯®ª  ¢ eax ­¥ áâ ­¥â ¬¥­ìè¥ ç¥¬ ¢ ecx
  1744.                 pop eax
  1745.         @@: ;cmp al,10 ;¯à®¢¥à¨âì ­¥ ¬¥­ìè¥ «¨ §­ ç¥­¨¥ ¢ al 祬 10 (¤«ï á¨á⥬ë áç¨á«¥­ï 10 ¤ ­­ ï ª®¬ ­¤  - «¨è­ ï))
  1746.         or al,0x30  ;¤ ­­ ï ª®¬ ­¤  ª®à®ç¥  ç¥¬ ¤¢¥ ¢ëè¥
  1747.         stosb       ;§ ¯¨á âì í«¥¬¥­â ¨§ ॣ¨áâà  al ¢ ï祪㠯 ¬ï⨠es:edi
  1748.         ret           ;¢¥à­ãâìáï ç¥­ì ¨­â¥à¥á­ë© 室 â.ª. ¯®ª  ¢ á⥪¥ åà ­¨âìáï ª®«-¢® ¢ë§®¢®¢ â® á⮫쪮 à § ¬ë ¨ ¡ã¤¥¬ ¢ë§ë¢ âìáï
  1749.  
  1750. i_end:
  1751.         rb 1024
  1752. stacktop:
  1753.         sys_path rb 1024
  1754.         file_name:
  1755.                 rb 1024 ;4096
  1756.         library_path rb 1024
  1757.         plugin_path rb 4096
  1758.         openfile_path rb 4096
  1759.         filename_area rb 256
  1760. mem:
  1761.