Subversion Repositories Kolibri OS

Rev

Rev 8090 | 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,openfile_path,sys_path
  5.  
  6. include 'lang.inc'
  7. include '../../macros.inc'
  8. include '../../proc32.inc'
  9. include '../../KOSfuncs.inc'
  10. include '../../load_img.inc'
  11. include '../../load_lib.mac'
  12. include '../../develop/libraries/TinyGL/asm_fork/opengl_const.inc'
  13. include '../../develop/libraries/TinyGL/asm_fork/zbuffer.inc'
  14. include '../../develop/libraries/libs-dev/libimg/libimg.inc'
  15. include '../../develop/info3ds/info_fun_float.inc'
  16.  
  17. @use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
  18. caption db 'Image transform 08.12.20',0 ;¯®¤¯¨áì ®ª­ 
  19.  
  20. BUF_STRUCT_SIZE equ 21
  21. buf2d_data equ dword[edi] ;¤ ­­ë¥ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
  22. buf2d_w equ dword[edi+8] ;è¨à¨­  ¡ãä¥à 
  23. buf2d_h equ dword[edi+12] ;¢ëá®â  ¡ãä¥à 
  24. buf2d_l equ word[edi+4]
  25. buf2d_t equ word[edi+6] ;®âáâ㯠ᢥàåã
  26. buf2d_size_lt equ dword[edi+4] ;®âáâ㯠᫥¢  ¨ á¯à ¢  ¤«ï ¡ãä¥à 
  27. buf2d_color equ dword[edi+16] ;梥â ä®­  ¡ãä¥à 
  28. buf2d_bits equ byte[edi+20] ;ª®«¨ç¥á⢮ ¡¨â ¢ 1-© â®çª¥ ¨§®¡à ¦¥­¨ï
  29.  
  30. NAV_WND_L equ 145
  31. NAV_WND_T equ 1
  32.  
  33. include 'select_points.inc'
  34.  
  35. IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3
  36. image_data_toolbar dd 0
  37.  
  38. align 4
  39. start:
  40.         load_libraries l_libs_start,l_libs_end
  41.         ;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ¡¨¡«¨®â¥ª 
  42.         mov     ebp,lib_0
  43.         cmp     dword [ebp+ll_struc_size-4],0
  44.         jz      @f
  45.                 mcall SF_TERMINATE_PROCESS
  46.         @@:
  47.         mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
  48.         mcall SF_SET_EVENTS_MASK,0xC0000027
  49.         stdcall [OpenDialog_Init],OpenDialog_data ;¯®¤£®â®¢ª  ¤¨ «®£ 
  50.  
  51.         stdcall [buf2d_create], buf_0 ;ᮧ¤ ­¨¥ ¡ãä¥à 
  52.  
  53.         include_image_file '../../../programs/fs/kfar/trunk/font6x9.bmp', image_data_toolbar, buf_font.w,buf_font.h
  54.         stdcall [buf2d_create_f_img], buf_font,[image_data_toolbar] ;ᮧ¤ ¥¬ ¡ãä¥à
  55.         stdcall mem.Free,[image_data_toolbar] ;®á¢®¡®¦¤ ¥¬ ¯ ¬ïâì
  56.         stdcall [buf2d_conv_24_to_8], buf_font,1 ;¤¥« ¥¬ ¡ãä¥à ¯à®§à ç­®á⨠8 ¡¨â
  57.         stdcall [buf2d_convert_text_matrix], buf_font
  58.  
  59.         include_image_file 'toolbar.png', image_data_toolbar
  60.  
  61.         mcall SF_SYSTEM_GET,SSF_TIME_COUNT
  62.         mov [last_time],eax
  63.  
  64.         ;­ áâனª  â®ç¥ª
  65.         call points_init
  66.  
  67.         ;open file from cmd line
  68.         cmp dword[openfile_path],0
  69.         je @f
  70.                 call but_open_file.no_dlg
  71.         @@:
  72.  
  73. align 4
  74. red_win:
  75.         call draw_window
  76.  
  77. align 16
  78. still:
  79.         mcall SF_SYSTEM_GET,SSF_TIME_COUNT
  80.         mov ebx,[last_time]
  81.         add ebx,10 ;§ ¤¥à¦ª 
  82.         cmp ebx,eax
  83.         jge @f
  84.                 mov ebx,eax
  85.         @@:
  86.         sub ebx,eax
  87.         mcall SF_WAIT_EVENT_TIMEOUT
  88.         cmp eax,0
  89.         je timer_funct
  90.  
  91.         cmp al,1
  92.         jz red_win
  93.         cmp al,2
  94.         jz key
  95.         cmp al,3
  96.         jz button
  97.         cmp al,6
  98.         jne @f
  99.                 mcall SF_THREAD_INFO,procinfo,-1
  100.                 cmp ax,word[procinfo.window_stack_position]
  101.                 jne @f ;®ª­® ­¥  ªâ¨¢­®
  102.                 call mouse
  103.         @@:
  104.         jmp still
  105.  
  106. align 4
  107. timer_funct:
  108.         push eax ebx
  109.                 mcall SF_SYSTEM_GET,SSF_TIME_COUNT
  110.                 mov [last_time],eax
  111.         pop ebx eax
  112.         cmp byte[calc],0
  113.         je still
  114.                 call draw_nav_wnd
  115.                 call draw_buffers
  116.         jmp still
  117.  
  118. align 16
  119. draw_window:
  120. pushad
  121.         mcall SF_REDRAW,SSF_BEGIN_DRAW
  122.  
  123.         ; *** à¨á®¢ ­¨¥ £« ¢­®£® ®ª­  (¢ë¯®«­ï¥âáï 1 à § ¯à¨ § ¯ã᪥) ***
  124.         mov edx,[sc.work]
  125.         or  edx,(3 shl 24)+0x30000000
  126.         mcall SF_CREATE_WINDOW,(20 shl 16)+410,(20 shl 16)+520,,,caption
  127.  
  128.         mcall SF_THREAD_INFO,procinfo,-1
  129.         mov eax,dword[procinfo.box.height]
  130.         cmp eax,120
  131.         jge @f
  132.                 mov eax,120 ;min size
  133.         @@:
  134.         sub eax,65
  135.         mov ebx,dword[procinfo.box.width]
  136.         cmp ebx,270
  137.         jge @f
  138.                 mov ebx,270
  139.         @@:
  140.         sub ebx,19
  141.         cmp eax,dword[buf_0.h] ;ᬮâਬ à §¬¥à ¡ãä¥à 
  142.         jne @f
  143.         cmp ebx,dword[buf_0.w]
  144.         jne @f
  145.                 jmp .end0
  146.         @@:
  147.                 stdcall [buf2d_resize],buf_0,ebx,eax,1
  148.                 call calc_nav_params
  149.                 mov eax,[nav_x]
  150.                 call nav_x_corect
  151.                 mov [nav_x],eax
  152.                 mov eax,[nav_y]
  153.                 call nav_y_corect
  154.                 mov [nav_y],eax
  155.                 mov byte[calc],1
  156.         .end0:
  157.  
  158.         ; *** ᮧ¤ ­¨¥ ª­®¯®ª ­  ¯ ­¥«ì ***
  159.         mcall SF_DEFINE_BUTTON,(5 shl 16)+20,(5 shl 16)+20,3, [sc.work_button]
  160.  
  161.         add ebx,25 shl 16
  162.         mcall ,,,4
  163.         add ebx,30 shl 16
  164.         mcall ,,,5
  165.         add ebx,25 shl 16
  166.         mcall ,,,6
  167.         add ebx,25 shl 16
  168.         mcall ,,,7
  169.  
  170.         ; *** à¨á®¢ ­¨¥ ¨ª®­®ª ­  ª­®¯ª å ***
  171.         mov edx,(7 shl 16)+7 ;icon open
  172.         mcall SF_PUT_IMAGE,[image_data_toolbar],(16 shl 16)+16
  173.  
  174.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  175.         add edx,(25 shl 16) ;icon save
  176.         int 0x40
  177.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  178.         add edx,(30 shl 16) ;icon view
  179.         int 0x40
  180.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  181.         add edx,(25 shl 16) ;icon mode
  182.         int 0x40
  183.         add ebx,IMAGE_TOOLBAR_ICON_SIZE
  184.         add edx,(25 shl 16) ;
  185.         int 0x40
  186.  
  187.         call draw_nav_wnd
  188.         call draw_buffers
  189.  
  190.         mcall SF_REDRAW,SSF_END_DRAW
  191. popad
  192.         ret
  193.  
  194. ;à¨á®¢ ­¨¥ ­ ¢¨£ æ¨®­­®£® ®ª­ 
  195. align 4
  196. proc draw_nav_wnd
  197.         cmp dword[buf_i0],0
  198.         je .end0
  199.         bt dword[nav_x_min],31
  200.         jnc .end0
  201.         bt dword[nav_y_min],31
  202.         jnc .end0
  203. pushad
  204.                 mov ebx,(NAV_WND_L shl 16)
  205.                 add ebx,[nav_wnd_w]
  206.                 mov ecx,(NAV_WND_T shl 16)
  207.                 add ecx,[nav_wnd_h]
  208.                 mcall SF_DRAW_RECT,,,0 ;¨§®¡à ¦¥­¨¥
  209.                 mov ecx,[nav_wnd_zoom]
  210.                 mov ebx,[nav_x]
  211.                 neg ebx
  212.                 sar ebx,cl
  213.                 add ebx,NAV_WND_L
  214.                 shl ebx,16
  215.                 add ebx,[buf_0.w]
  216.                 shr bx,cl
  217.                 mov edx,[nav_y]
  218.                 neg edx
  219.                 sar edx,cl
  220.                 add edx,NAV_WND_T
  221.                 shl edx,16
  222.                 add edx,[buf_0.h]
  223.                 shr dx,cl
  224.                 mov ecx,edx
  225.                 mcall ,,,0x404080 ;ç áâì ¨§®¡à ¦¥­¨ï ¯®¯ ¤ îé ï ¢ ®ª­®
  226.                
  227.                 mov edi,sel_pt
  228.                 @@:
  229.                         mov ecx,[nav_wnd_zoom]
  230.                         mov ebx,[edi+point2d.x]
  231.                         shr ebx,cl
  232.                         add ebx,NAV_WND_L
  233.                         mov edx,[edi+point2d.y]
  234.                         shr edx,cl
  235.                         add edx,NAV_WND_T
  236.                         mov ecx,edx
  237.                         mcall SF_PUT_PIXEL,,,0xffff00
  238.                         add edi,sizeof.point2d
  239.                         cmp edi,sel_pt+4*sizeof.point2d
  240.                         jl @b
  241. popad
  242.         .end0:
  243.         ret
  244. endp
  245.  
  246. align 4
  247. proc draw_buffers
  248. pushad
  249.         cmp byte[calc],0
  250.         je .end0
  251.                 ; *** ®¡­®¢«¥­¨¥ ¡ãä¥à  ***
  252.                 bt dword[nav_x_min],31
  253.                 jnc .beg0
  254.                 bt dword[nav_y_min],31
  255.                 jc @f
  256.                 .beg0:
  257.                         stdcall [buf2d_clear], buf_0, [buf_0.color] ;ç¨á⨬ ¡ãä¥à
  258.                 @@:
  259.                 cmp byte[view_b],1
  260.                 je .end1
  261.                         push buf_i0
  262.                         jmp .end2
  263.                 .end1:
  264.                         push buf_ogl
  265.                 .end2:
  266.                 stdcall [buf2d_bit_blt], buf_0, [nav_x],[nav_y] ;,...
  267.  
  268.                 call points_draw
  269.                 xor eax,eax
  270.                 cmp [u_line_v],eax
  271.                 je @f
  272.                         mov eax,[u_line_v]
  273.                         add eax,[nav_x]
  274.                         stdcall [buf2d_line], buf_0, eax,0, eax,[buf_0.h], 0xffffff
  275.                         inc eax
  276.                         stdcall [buf2d_line], buf_0, eax,0, eax,[buf_0.h], 0
  277.                 @@:
  278.                 xor eax,eax
  279.                 cmp [u_line_h],eax
  280.                 je @f
  281.                         mov eax,[u_line_h]
  282.                         add eax,[nav_y]
  283.                         stdcall [buf2d_line], buf_0, 0,eax, [buf_0.w],eax, 0xffffff
  284.                         inc eax
  285.                         stdcall [buf2d_line], buf_0, 0,eax, [buf_0.w],eax, 0
  286.                 @@:
  287.  
  288.                 ; *** ®¡­®¢«¥­¨¥ ¯®¤¯¨á¨ à §¬¥à  ä ©«  ***
  289.                 mov edi,txt_f_size.size
  290.                 mov eax,[open_file_size]
  291.                 mov ebx,txt_pref
  292.                 .cycle:
  293.                         cmp eax,1024
  294.                         jl @f
  295.                         shr eax,10
  296.                         add ebx,4
  297.                         jmp .cycle
  298.                 @@:
  299.                 stdcall convert_int_to_str, 16
  300.                 stdcall str_cat, edi,ebx
  301.                 stdcall str_cat, edi,txt_space ;§ ¢¥àè î騩 ¯à®¡¥«
  302.                 ;è¨à¨­  ¨ ¢ëá®â  ¨§®¡à ¦¥­¨ï
  303.                 mov eax,[buf_i0.w]
  304.                 mov edi,txt_img_w.size
  305.                 stdcall convert_int_to_str, 16
  306.                 mov eax,[buf_i0.h]
  307.                 mov edi,txt_img_h.size
  308.                 stdcall convert_int_to_str, 16
  309.                 mov byte[calc],0
  310.         .end0:
  311.         ; *** à¨á®¢ ­¨¥ ¡ãä¥à  ***
  312.         stdcall [buf2d_draw], buf_0
  313.         ; *** à¨á®¢ ­¨¥ ¯®¤¯¨á¨ à §¬¥à  ä ©«  ***
  314.         mov ecx,[sc.work_text]
  315.         or  ecx,0x80000000 or (1 shl 30)
  316.         mov edi,[sc.work] ;梥â ä®­  ®ª­ 
  317.         mcall SF_DRAW_TEXT,(275 shl 16)+4,,txt_f_size
  318.         add ebx,9
  319.         mcall ,,,txt_img_w
  320.         add ebx,9
  321.         mcall ,,,txt_img_h
  322. popad
  323.         ret
  324. endp
  325.  
  326. align 16
  327. key:
  328.         push eax ebx ecx
  329.         mcall SF_GET_KEY
  330.         cmp byte[view_b],1
  331.         je .end1
  332.         cmp ah,49 ;1
  333.         jne @f
  334.                 mov edi,sel_pt
  335.                 call set_point_coords
  336.                 jmp .end0
  337.         @@:
  338.         cmp ah,50 ;2
  339.         jne @f
  340.                 mov edi,sel_pt+sizeof.point2d
  341.                 call set_point_coords
  342.                 jmp .end0
  343.         @@:
  344.         cmp ah,51 ;3
  345.         jne @f
  346.                 mov edi,sel_pt+sizeof.point2d*2
  347.                 call set_point_coords
  348.                 jmp .end0
  349.         @@:
  350.         cmp ah,52 ;4
  351.         jne @f
  352.                 mov edi,sel_pt+sizeof.point2d*3
  353.                 call set_point_coords
  354.                 jmp .end0
  355.         @@:
  356.         .end1:
  357.  
  358.         cmp ah,178 ;Up
  359.         jne @f
  360.                 call but_img_move_up
  361.                 jmp .end0
  362.         @@:
  363.         cmp ah,177 ;Down
  364.         jne @f
  365.                 call but_img_move_down
  366.                 jmp .end0
  367.         @@:
  368.         cmp ah,176 ;Left
  369.         jne @f
  370.                 call but_img_move_left
  371.                 jmp .end0
  372.         @@:
  373.         cmp ah,179 ;Right
  374.         jne @f
  375.                 call but_img_move_right
  376.                 jmp .end0
  377.         @@:
  378.         cmp ah,104 ;H
  379.         jne @f
  380.                 call set_user_line_h
  381.                 mov byte[calc],1
  382.                 jmp .end0
  383.         @@:
  384.         cmp ah,118 ;V
  385.         jne @f
  386.                 call set_user_line_w
  387.                 mov byte[calc],1
  388.                 jmp .end0
  389.         @@:
  390.  
  391.         mov ecx,eax
  392.         mcall SF_KEYBOARD,SSF_GET_CONTROL_KEYS
  393.         bt eax,2 ;left Ctrl
  394.         jc .key_Ctrl
  395.         bt eax,3 ;right Ctrl
  396.         jc .key_Ctrl
  397.         jmp .end0
  398.         .key_Ctrl:
  399.                 cmp ch,15 ;Ctrl+O
  400.                 jne @f
  401.                         call but_open_file
  402.                 @@:
  403.                 cmp ch,19 ;Ctrl+S
  404.                 jne @f
  405.                         call but_save_file
  406.                 @@:
  407.  
  408.         .end0:
  409.         pop ecx ebx eax
  410.         jmp still
  411.  
  412. ;input:
  413. ; edi - 㪠§ â¥«ì ­  áâàãªâãàã point2d
  414. align 4
  415. set_point_coords:
  416.         call buf_get_mouse_coord
  417.         cmp eax,-1
  418.         je .end0
  419.                 sub eax,[nav_x]
  420.                 cmp eax,0
  421.                 jge @f
  422.                         xor eax,eax
  423.                 @@:
  424.                 cmp eax,[buf_i0.w]
  425.                 jle @f
  426.                         mov eax,[buf_i0.w]
  427.                 @@:
  428.                 mov [edi+point2d.x],eax
  429.                 sub ebx,[nav_y]
  430.                 cmp ebx,0
  431.                 jge @f
  432.                         xor ebx,ebx
  433.                 @@:
  434.                 cmp ebx,[buf_i0.h]
  435.                 jle @f
  436.                         mov ebx,[buf_i0.h]
  437.                 @@:
  438.                 mov [edi+point2d.y],ebx
  439.                 call points_update_prop
  440.                 mov byte[calc],1
  441.         .end0:
  442.         ret
  443.  
  444. align 16
  445. button:
  446.         mcall SF_GET_BUTTON
  447.         cmp ah,3
  448.         jne @f
  449.                 call but_open_file
  450.                 jmp still
  451.         @@:
  452.         cmp ah,4
  453.         jne @f
  454.                 call but_save_file
  455.                 jmp still
  456.         @@:
  457.         cmp ah,5
  458.         jne @f
  459.                 call but_2
  460.                 jmp still
  461.         @@:
  462.         cmp ah,6
  463.         jne @f
  464.                 call but_3
  465.                 jmp still
  466.         @@:
  467.         cmp ah,7
  468.         jne @f
  469.                 call but_about
  470.                 jmp still
  471.         @@:
  472.         cmp ah,1
  473.         jne still
  474. .exit:
  475.         stdcall [buf2d_delete],buf_0
  476.         stdcall [buf2d_delete],buf_i0
  477.         ;stdcall [buf2d_delete],buf_ogl
  478.         stdcall mem.Free,[image_data_toolbar]
  479.         stdcall mem.Free,[open_file_img]
  480.         mcall SF_TERMINATE_PROCESS
  481.  
  482. align 4
  483. mouse:
  484.         push eax ebx ecx
  485.         mcall SF_MOUSE_GET,SSF_BUTTON_EXT
  486.         bt eax,8
  487.         jnc @f
  488.                 ;mouse l. but. press
  489.                 call mouse_left_d
  490.                 jmp .end_l
  491.         @@:
  492.         ;bt eax,0
  493.         ;jnc @f
  494.                 ;mouse l. but. move
  495.                 ;call mouse_left_m
  496.                 ;jmp .end_l
  497.         ;@@:
  498.         bt eax,16
  499.         jnc .end_l
  500.                 ;mouse l. but. up
  501.                 call mouse_left_u
  502.                 ;jmp .end_l
  503.         .end_l:
  504.         ;bt eax,9
  505.         ;jnc @f
  506.                 ;mouse r. but. press
  507.                 ;call mouse_right_d
  508.                 ;jmp .end_r
  509.         ;@@:
  510.         ;bt eax,1
  511.         ;jnc @f
  512.                 ;mouse r. but. move
  513.                 ;call mouse_right_m
  514.                 ;jmp .end_r
  515.         ;@@:
  516.         ;.end_r:
  517.  
  518.         pop ecx ebx eax
  519.         ret
  520.  
  521. ;output:
  522. ; eax - buffer coord X (¥á«¨ ªãàá®à §  ¡ãä¥à®¬ -1)
  523. ; ebx - buffer coord Y (¥á«¨ ªãàá®à §  ¡ãä¥à®¬ -1)
  524. align 4
  525. proc buf_get_mouse_coord
  526.         mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
  527.         cmp ax,word[buf_0.t]
  528.         jl .no_buf ;­¥ ¯®¯ «¨ ¢ ®ª­® ¡ãä¥à  ¯® ®á¨ y
  529.         mov ebx,eax
  530.         shr ebx,16
  531.         cmp bx,word[buf_0.l]
  532.         jl .no_buf ;­¥ ¯®¯ «¨ ¢ ®ª­® ¡ãä¥à  ¯® ®á¨ x
  533.  
  534.         and eax,0xffff ;®áâ ¢«ï¥¬ ª®®à¤¨­ âã y
  535.         sub ax,word[buf_0.t]
  536.         cmp eax,[buf_0.h]
  537.         jg .no_buf
  538.         sub bx,word[buf_0.l]
  539.         cmp ebx,[buf_0.w]
  540.         jg .no_buf
  541.         xchg eax,ebx
  542.         jmp .end_f
  543.         .no_buf:
  544.                 xor eax,eax
  545.                 not eax
  546.                 xor ebx,ebx
  547.                 not ebx
  548.         .end_f:
  549.         ret
  550. endp
  551.  
  552. ;output:
  553. ; eax - buffer coord X (¥á«¨ ªãàá®à §  ¡ãä¥à®¬ -1)
  554. ; ebx - buffer coord Y (¥á«¨ ªãàá®à §  ¡ãä¥à®¬ -1)
  555. align 4
  556. proc nav_wnd_get_mouse_coord
  557.         mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
  558.         cmp ax,NAV_WND_T
  559.         jl .no_buf ;­¥ ¯®¯ «¨ ¢ ®ª­® ¡ãä¥à  ¯® ®á¨ y
  560.         cmp eax,NAV_WND_L shl 16
  561.         jl .no_buf ;­¥ ¯®¯ «¨ ¢ ®ª­® ¡ãä¥à  ¯® ®á¨ x
  562.         mov ebx,eax
  563.         shr ebx,16
  564.  
  565.         and eax,0xffff ;®áâ ¢«ï¥¬ ª®®à¤¨­ âã y
  566.         sub ax,NAV_WND_T
  567.         cmp eax,[nav_wnd_h]
  568.         jg .no_buf
  569.         sub bx,NAV_WND_L
  570.         cmp ebx,[nav_wnd_w]
  571.         jg .no_buf
  572.         xchg eax,ebx
  573.         jmp .end_f
  574.         .no_buf:
  575.                 xor eax,eax
  576.                 not eax
  577.                 xor ebx,ebx
  578.                 not ebx
  579.         .end_f:
  580.         ret
  581. endp
  582.  
  583. align 4
  584. mouse_left_d:
  585. pushad
  586.         call buf_get_mouse_coord
  587.         cmp eax,-1
  588.         je .end0
  589.                 mov [mouse_down_x],eax
  590.                 mov [mouse_down_y],ebx
  591.                 sub eax,[nav_x]
  592.                 sub ebx,[nav_y]
  593.                
  594.                 mov edi,sel_pt
  595.                 xor ecx,ecx
  596.                 .cycle0:
  597.                         mov edx,[edi+point2d.x]
  598.                         sub edx,eax
  599.                         bt edx,31
  600.                         jnc @f
  601.                                 neg edx
  602.                         @@:
  603.                         cmp edx,5 ;à §¬¥à ¤«ï ¢ë¤¥«¥­¨ï â®çª¨ ¯® ®á¨ x
  604.                         jg .end1
  605.                         mov edx,[edi+point2d.y]
  606.                         sub edx,ebx
  607.                         bt edx,31
  608.                         jnc @f
  609.                                 neg edx
  610.                         @@:
  611.                         cmp edx,5 ;à §¬¥à ¤«ï ¢ë¤¥«¥­¨ï â®çª¨ ¯® ®á¨ y
  612.                         jg .end1
  613.                                 mov [sel_act],ecx
  614.                                 jmp .end0
  615.                         .end1:
  616.                         add edi,sizeof.point2d
  617.                         inc ecx
  618.                         cmp ecx,4
  619.                         jl .cycle0
  620.                         mov dword[sel_act],-1
  621.                 jmp .end2
  622.         .end0:
  623.         call nav_wnd_get_mouse_coord
  624.         cmp eax,-1
  625.         je .end2
  626.                 mov ecx,[nav_wnd_zoom]
  627.                 shl eax,cl
  628.                 shl ebx,cl
  629.                 stdcall nav_to_point, eax,ebx
  630.                 mov byte[calc],1
  631.         .end2:
  632. popad
  633.         ret
  634.  
  635. align 4
  636. proc mouse_left_u uses eax ebx
  637.         call buf_get_mouse_coord
  638.         cmp eax,-1
  639.         je .end0
  640.                 sub [mouse_down_x],eax
  641.                 sub [mouse_down_y],ebx
  642.  
  643.                 cmp dword[sel_act],-1
  644.                 je .end1
  645.                         ;¤¢¨£ ¥¬ â®çª¨
  646.                         mov eax,[sel_act]
  647.                         imul eax,sizeof.point2d
  648.                         add eax,sel_pt
  649.                         ;coord x
  650.                         mov ebx,dword[eax+point2d.x]
  651.                         sub ebx,[mouse_down_x]
  652.                         cmp ebx,0
  653.                         jge @f
  654.                                 xor ebx,ebx
  655.                         @@:
  656.                         cmp ebx,[buf_i0.w]
  657.                         jle @f
  658.                                 mov ebx,[buf_i0.w]
  659.                         @@:
  660.                         mov dword[eax+point2d.x],ebx
  661.                         ;coord y
  662.                         mov ebx,dword[eax+point2d.y]
  663.                         sub ebx,[mouse_down_y]
  664.                         cmp ebx,0
  665.                         jge @f
  666.                                 xor ebx,ebx
  667.                         @@:
  668.                         cmp ebx,[buf_i0.h]
  669.                         jle @f
  670.                                 mov ebx,[buf_i0.h]
  671.                         @@:
  672.                         mov dword[eax+point2d.y],ebx
  673.                         call points_update_prop
  674.                         jmp .end2
  675.                 .end1:
  676.  
  677.                 ;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥
  678.                 mov eax,[nav_y]
  679.                 sub eax,[mouse_down_y]
  680.                 call nav_y_corect
  681.                 mov [nav_y],eax
  682.  
  683.                 mov eax,[nav_x]
  684.                 sub eax,[mouse_down_x]
  685.                 call nav_x_corect
  686.                 mov [nav_x],eax
  687.         .end2:
  688.                 mov byte[calc],1
  689.         .end0:
  690.         ret
  691. endp
  692.  
  693. align 4
  694. set_user_line_h:
  695. pushad
  696.         call buf_get_mouse_coord
  697.         cmp eax,-1
  698.         je .end0
  699.                 mov [mouse_down_y],ebx
  700.                 sub ebx,[nav_y]
  701.                 cmp eax,[buf_i0.h]
  702.                 jle @f
  703.                         mov eax,[buf_i0.h]
  704.                 @@:
  705.                 cmp [u_line_h],ebx
  706.                 jne @f
  707.                         xor ebx,ebx ;line on/off
  708.                 @@:
  709.                 mov [u_line_h],ebx
  710.         .end0:
  711. popad
  712.         ret
  713.  
  714. align 4
  715. set_user_line_w:
  716. pushad
  717.         call buf_get_mouse_coord
  718.         cmp eax,-1
  719.         je .end0
  720.                 mov [mouse_down_x],eax
  721.                 sub eax,[nav_x]
  722.                 cmp eax,[buf_i0.w]
  723.                 jle @f
  724.                         mov eax,[buf_i0.w]
  725.                 @@:
  726.                 cmp [u_line_v],eax
  727.                 jne @f
  728.                         xor eax,eax ;line on/off
  729.                 @@:
  730.                 mov [u_line_v],eax
  731.         .end0:
  732. popad
  733.         ret
  734.  
  735. align 4
  736. proc but_new_file uses eax edi esi
  737.         xor eax,eax
  738.         mov [open_file_size],eax
  739.         mov edi,[open_file_img]
  740.         stosd
  741.         ret
  742. endp
  743.  
  744. align 4
  745. open_file_img dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï ®âªàëâ¨ï ⥪áâãà
  746. open_file_size dd 0 ;à §¬¥à
  747.  
  748. ;¢ëç¨á«¥­¨¥ ¯ à ¬¥â஢ ¤«ï ­ ¢¨£ æ¨¨ ¯® ¨§®¡à ¦¥­¨î
  749. align 4
  750. proc calc_nav_params uses eax ecx edi
  751.         mov dword[nav_x_max],0
  752.         mov edi,buf_0
  753.         mov eax,buf2d_w
  754.         mov [nav_sx],eax
  755.         mov edi,buf_i0
  756.         sub eax,buf2d_w
  757.         bt eax,31
  758.         jc @f
  759.                 mov [nav_x_max],eax
  760.                 xor eax,eax
  761.         @@:
  762.         mov [nav_x_min],eax
  763.         mov edi,buf2d_w
  764.         cmp [nav_sx],edi
  765.         jle @f
  766.                 mov [nav_sx],edi
  767.         @@:
  768.         shr dword[nav_sx],1
  769.  
  770.         mov dword[nav_y_max],0
  771.         mov edi,buf_0
  772.         mov eax,buf2d_h
  773.         mov [nav_sy],eax
  774.         mov edi,buf_i0
  775.         sub eax,buf2d_h
  776.         bt eax,31
  777.         jc @f
  778.                 mov [nav_y_max],eax
  779.                 xor eax,eax
  780.         @@:
  781.         mov [nav_y_min],eax
  782.         mov edi,buf2d_h
  783.         cmp [nav_sy],edi
  784.         jle @f
  785.                 mov [nav_sy],edi
  786.         @@:
  787.         shr dword[nav_sy],1
  788.  
  789.         xor ecx,ecx
  790.         mov [u_line_v],ecx
  791.         mov eax,[buf_i0.w]
  792.         @@:
  793.                 inc ecx
  794.                 shr eax,1
  795.                 cmp eax,100
  796.                 jg @b
  797.         mov [nav_wnd_zoom],ecx
  798.         xor ecx,ecx
  799.         mov [u_line_h],ecx
  800.         mov eax,[buf_i0.h]
  801.         @@:
  802.                 inc ecx
  803.                 shr eax,1
  804.                 cmp eax,32
  805.                 jg @b
  806.         cmp [nav_wnd_zoom],ecx
  807.         jg @f
  808.                 mov [nav_wnd_zoom],ecx
  809.         @@:
  810.         mov ecx,[nav_wnd_zoom]
  811.         mov eax,[buf_i0.w]
  812.         shr eax,cl
  813.         mov [nav_wnd_w],eax
  814.         mov eax,[buf_i0.h]
  815.         shr eax,cl
  816.         mov [nav_wnd_h],eax
  817.         ret
  818. endp
  819.  
  820. align 4
  821. proc but_open_file
  822.         copy_path open_dialog_name,communication_area_default_path,file_name,0
  823.         pushad
  824.         mov [OpenDialog_data.type],0
  825.         stdcall [OpenDialog_Start],OpenDialog_data
  826.         cmp [OpenDialog_data.status],2
  827.         je .end_open_file
  828.         jmp .end0
  829. .no_dlg: ;¥á«¨ ¬¨­ã¥¬ ¤¨ «®£ ®âªàëâ¨ï ä ©« 
  830.                 pushad
  831.                 mov esi,openfile_path
  832.                 stdcall str_len,esi
  833.                 add esi,eax
  834.                 @@: ;横« ¤«ï ¯®¨áª  ­ ç «  ¨¬¥­¨ ä ©« 
  835.                         dec esi
  836.                         cmp byte[esi],'/'
  837.                         je @f
  838.                         cmp byte[esi],0x5c ;'\'
  839.                         je @f
  840.                         cmp esi,openfile_path
  841.                         jg @b
  842.                 @@:
  843.                 inc esi
  844.                 stdcall [OpenDialog_Set_file_name],OpenDialog_data,esi ;ª®¯¨à㥬 ¨¬ï ä ©«  ¢ ¤¨ «®£ á®åà ­¥­¨ï
  845.         .end0:
  846.  
  847.         mov [run_file_70.Function], SSF_GET_INFO
  848.         mov [run_file_70.Position], 0
  849.         mov [run_file_70.Flags], 0
  850.         mov dword[run_file_70.Count], 0
  851.         mov dword[run_file_70.Buffer], open_b
  852.         mov byte[run_file_70+20], 0
  853.         mov dword[run_file_70.FileName], openfile_path
  854.         mcall SF_FILE,run_file_70
  855.  
  856.         mov ecx,dword[open_b+32] ;+32 qword: à §¬¥à ä ©«  ¢ ¡ ©â å
  857.         mov [open_file_size],ecx
  858.         stdcall mem.ReAlloc,[open_file_img],ecx ;¢ë¤¥«ï¥¬ ¯ ¬ïâì ¤«ï ¨§®¡à ¦¥­¨ï
  859.         mov [open_file_img],eax
  860.  
  861.         mov [run_file_70.Function], SSF_READ_FILE
  862.         mov [run_file_70.Position], 0
  863.         mov [run_file_70.Flags], 0
  864.         m2m [run_file_70.Count], dword[open_file_size]
  865.         m2m [run_file_70.Buffer],dword[open_file_img]
  866.         mov byte[run_file_70+20], 0
  867.         mov [run_file_70.FileName], openfile_path
  868.         mcall SF_FILE,run_file_70
  869.         cmp ebx,0xffffffff
  870.         je .end_0
  871.                 ;®¯à¥¤¥«ï¥¬ ¢¨¤ ¨§®¡à ¦¥­¨ï
  872.                 stdcall [img_decode], [open_file_img],ebx,0
  873.                 or eax,eax
  874.                 jz .end_0 ;¥á«¨ ­ àã襭 ä®à¬ â ä ©« 
  875.                 mov ebx,eax
  876.                
  877.                 mov ecx,[ebx+4] ;+4 = image width
  878.                 mov dword[buf_cop.w],ecx
  879.                 imul ecx,[ebx+8] ;+8 = image height
  880.                 lea ecx,[ecx+ecx*2]
  881.                 mov [open_file_size],ecx
  882.                 stdcall mem.ReAlloc,[open_file_img],ecx
  883.                 mov [open_file_img],eax
  884.                 mov dword[buf_cop],eax
  885.                 mov dword[buf_cop.l],0 ;left = 0, top = 0
  886.                 m2m dword[buf_cop.h],dword[ebx+8]
  887.  
  888.                 ;¯à¥®¡à §ã¥¬ ¨§®¡à ¦¥­¨¥ ª ä®à¬ âã rgb
  889.                 stdcall [img_to_rgb2], ebx,[open_file_img]
  890.                 mov edi,buf_i0
  891.                 cmp buf2d_data,0
  892.                 jne .end3
  893.                         stdcall getNextPowerOfTwo,[ebx+8]
  894.                         mov buf2d_h,eax
  895.                         mov edx,eax
  896.                         stdcall getNextPowerOfTwo,[ebx+4]
  897.                         mov buf2d_w,eax
  898.                         cmp edx,[ebx+8]
  899.                         jne @f
  900.                         cmp eax,[ebx+4]
  901.                         jne @f
  902.                                 ;ᮧ¤ ­¨¥ ­®¢®£® ¨§®¡à ¦¥­¨ï ¯® ¨á室­ë¬ à §¬¥à ¬
  903.                                 stdcall [buf2d_create_f_img], edi,[open_file_img]
  904.                                 jmp .end_1
  905.                         @@:
  906.                                 ;ᮧ¤ ­¨¥ ­®¢®£® ¨§®¡à ¦¥­¨ï ¯® ¯à¥®¡à §®¢ ­­ë¬ à §¬¥à ¬
  907.                                 cmp eax,[ebx+4]
  908.                                 jge @f
  909.                                         mov eax,[ebx+4]
  910.                                         mov buf2d_w,eax
  911.                                 @@:
  912.                                 sub eax,[ebx+4]
  913.                                 shr eax,1
  914.                                 mov esi,eax
  915.                                 cmp edx,[ebx+8]
  916.                                 jge @f
  917.                                         mov edx,[ebx+8]
  918.                                         mov buf2d_h,edx
  919.                                 @@:
  920.                                 sub edx,[ebx+8]
  921.                                 shr edx,1
  922.                                 stdcall [buf2d_create], edi
  923.                                 mov [buf_cop.l],si
  924.                                 mov [buf_cop.t],dx
  925.                                 stdcall [buf2d_bit_blt], edi, esi,edx, buf_cop
  926.                                 jmp .end_1
  927.                 .end3:
  928.                         ;¯à¥®¡à §®¢ ­¨¥ ᮧ¤ ­­®£® ¨§®¡à ¦¥­¨ï
  929.                         stdcall getNextPowerOfTwo,[ebx+4]
  930.                         cmp eax,[ebx+4]
  931.                         jg @f
  932.                                 mov eax,[ebx+4]
  933.                         @@:
  934.                         mov ecx,eax ;à §¬¥à ¯® x
  935.                         stdcall getNextPowerOfTwo,[ebx+8]
  936.                         cmp eax,[ebx+8]
  937.                         jg @f
  938.                                 mov eax,[ebx+8]
  939.                         @@:
  940.                         mov edx,eax ;à §¬¥à ¯® y
  941.                         stdcall [buf2d_resize], edi, ecx,edx,1 ;¨§¬¥­ï¥¬ à §¬¥àë ¡ãä¥à 
  942.                         stdcall [buf2d_clear], edi, buf2d_color
  943.                         sub ecx,[ebx+4]
  944.                         shr ecx,1
  945.                         mov [buf_cop.l],cx
  946.                         sub edx,[ebx+8]
  947.                         shr edx,1
  948.                         mov [buf_cop.t],dx
  949.                         stdcall [buf2d_bit_blt], edi, ecx,edx, buf_cop
  950.                 .end_1:
  951.                
  952.                 ;ᮧ¤ ¥¬ ¡ãä¥à ¤«ï ¯à¥®¡à §®¢ ­­®£® ¨§®¡à ¦¥­¨ï
  953.                 mov edi,buf_ogl
  954.                 mov eax,[buf_i0.w]
  955.                 mov buf2d_w,eax
  956.                 mov eax,[buf_i0.h]
  957.                 mov buf2d_h,eax
  958.                 cmp buf2d_data,0
  959.                 jne @f
  960.                         stdcall [kosglMakeCurrent], 0,35,buf2d_w,buf2d_h,ctx1
  961.                         stdcall [glEnable], GL_DEPTH_TEST
  962.                         stdcall [glEnable], GL_NORMALIZE ;¤¥« ¬ ­®à¬ «¨ ®¤¨­ ª®¢®© ¢¥«¨ç¨­ë ¢® ¨§¡¥¦ ­¨¥  àâ¥ä ªâ®¢
  963.                         stdcall [glShadeModel], GL_SMOOTH
  964.                         stdcall [glScalef], 2.0, -2.0, 1.0
  965.                         stdcall [glTranslatef], -0.5, -0.5, 0.0
  966.                         jmp .end_2
  967.                 @@:
  968.                         stdcall reshape, buf2d_w,buf2d_h ;¨§¬¥­ï¥¬ à §¬¥àë ¡ãä¥à  buf_ogl
  969.                 .end_2:
  970.                 mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
  971.                 mov eax,[eax] ;eax -> ZBuffer
  972.                 mov eax,[eax+ZBuffer.pbuf]
  973.                 mov buf2d_data,eax
  974.  
  975.                 stdcall [buf2d_bit_blt], edi, 0,0, buf_i0 ;ª®¯¨à㥬 ¨§®¡à ¦¥­¨¥ ¤«ï ¢®áâ ­®¢«¥­¨ï
  976.  
  977.                 ;* Setup texturing *
  978.                 stdcall [glTexEnvi], GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL
  979.  
  980.                 ;* generate texture object IDs *
  981.                 stdcall [glGenTextures], 1, TexObj
  982.                 stdcall [glBindTexture], GL_TEXTURE_2D, [TexObj]
  983.                 stdcall [glTexImage2D], GL_TEXTURE_2D, 0, 3, [buf_i0.w], [buf_i0.h],\
  984.                         0, GL_RGB, GL_UNSIGNED_BYTE, [buf_i0] ;¤¥« ¥¬ ⥪áâãàã ­  ®á­®¢¥ ¡ãä¥à , á ¬® ¨§®¡à ¦¥­¨¥ ¢ ¡ãä¥à¥ ¬®¦¥â ¨á¯®àâ¨âáï ¯à¨ ¯®¤£®­ª¥ à §¬¥à®¢ ⥪áâãàë
  985.  
  986.                 stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST
  987.                 stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST
  988.                 stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT
  989.                 stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT
  990.                 stdcall [glBindTexture], GL_TEXTURE_2D, [TexObj]
  991.                 stdcall [glEnable], GL_TEXTURE_2D
  992.  
  993.                 stdcall [buf2d_bit_blt], buf_i0, 0,0, edi ;¢®áâ ­ ¢«¨¢ ¥¬ ¨§®¡à ¦¥­¨¥ ¨á¯®à祭®¥ ¯à¨ ãáâ ­®¢ª¥ ⥪áâãàë
  994.  
  995.                 ;㤠«ï¥¬ ¢à¥¬¥­­ë© ¡ãä¥à ¢ ebx
  996.                 stdcall [img_destroy], ebx
  997.                
  998.                 movzx eax,word[buf_cop.l]
  999.                 movzx ebx,word[buf_cop.t]
  1000.                 stdcall points_init_2,eax,ebx
  1001.  
  1002.                 call calc_nav_params
  1003.                 stdcall nav_to_point, dword[sel_pt+point2d.x],dword[sel_pt+point2d.y]
  1004.                 mov byte[view_b],0
  1005.                 mov dword[sel_act],-1 ;á­¨¬ ¥¬ ¢ë¤¥«¥­¨¥ á â®ç¥ª
  1006.                 mov byte[calc],1
  1007.         .end_0:
  1008.  
  1009.         .end_open_file:
  1010.         popad
  1011.         ret
  1012. endp
  1013.  
  1014. align 4
  1015. proc nav_to_point, coord_x:dword, coord_y:dword
  1016.         ;coord x
  1017.         mov eax,[nav_x_max]
  1018.         cmp eax,0
  1019.         jle @f
  1020.                 ;¥á«¨ ¬ «¥­ìª®¥ ¨§®¡à ¦¥­¨¥ â® áâ ¢¨¬ ¯® 業âàã
  1021.                 shr eax,1
  1022.                 jmp .end0
  1023.         @@:
  1024.         mov eax,[buf_0.w]
  1025.         shr eax,1
  1026.         sub eax,[coord_x]
  1027.         call nav_x_corect
  1028.         .end0:
  1029.         mov [nav_x],eax
  1030.         ;coord y
  1031.         mov eax,[nav_y_max]
  1032.         cmp eax,0
  1033.         jle @f
  1034.                 ;¥á«¨ ¬ «¥­ìª®¥ ¨§®¡à ¦¥­¨¥ â® áâ ¢¨¬ ¯® 業âàã
  1035.                 shr eax,1
  1036.                 jmp .end1
  1037.         @@:
  1038.         mov eax,[buf_0.h]
  1039.         shr eax,1
  1040.         sub eax,[coord_y]
  1041.         call nav_y_corect
  1042.         .end1:
  1043.         mov [nav_y],eax
  1044.         ret
  1045. endp
  1046.  
  1047. ;input:
  1048. ; eax - navigation coord x
  1049. ;output:
  1050. ; eax - valid coord x
  1051. align 4
  1052. nav_x_corect:
  1053.         cmp eax,[nav_x_min]
  1054.         jge @f
  1055.                 mov eax,[nav_x_min]
  1056.         @@:
  1057.         cmp eax,[nav_x_max]
  1058.         jle @f
  1059.                 mov eax,[nav_x_max]
  1060.         @@:
  1061.         ret
  1062.  
  1063. ;input:
  1064. ; eax - navigation coord y
  1065. ;output:
  1066. ; eax - valid coord y
  1067. align 4
  1068. nav_y_corect:
  1069.         cmp eax,[nav_y_min]
  1070.         jge @f
  1071.                 mov eax,[nav_y_min]
  1072.         @@:
  1073.         cmp eax,[nav_y_max]
  1074.         jle @f
  1075.                 mov eax,[nav_y_max]
  1076.         @@:
  1077.         ret
  1078.  
  1079. align 4
  1080. proc getNextPowerOfTwo uses ebx, n:dword
  1081.         mov ebx,[n]
  1082.         mov eax,8 ;min size
  1083.         cmp ebx,eax
  1084.         jle .set
  1085.         @@:
  1086.                 shl eax,1
  1087.                 cmp ebx,eax
  1088.                 jg @b
  1089.         cmp eax,4096 ;max size
  1090.         jle .set
  1091.                 mov eax,4096
  1092.         .set:
  1093.         ret
  1094. endp
  1095.  
  1096. ; new window size or exposure
  1097. align 4
  1098. proc reshape uses ebx ecx, width:dword, height:dword
  1099.         stdcall [glViewport], 0, 0, [width], [height]
  1100.         stdcall [glMatrixMode], GL_MODELVIEW
  1101.         stdcall [glLoadIdentity]
  1102.         stdcall [glScalef], 2.0, -2.0, 1.0
  1103.         stdcall [glTranslatef], -0.5, -0.5, 0.0
  1104.         ret
  1105. endp
  1106.  
  1107. align 4
  1108. proc but_save_file
  1109. locals
  1110.         png_data dd 0
  1111.         png_size dd 0
  1112. endl
  1113.         pushad
  1114.         copy_path open_dialog_name,communication_area_default_path,file_name,0
  1115.         mov [OpenDialog_data.type],1
  1116.         stdcall [OpenDialog_Set_file_ext],OpenDialog_data,Filter.1 ;.png
  1117.         stdcall [OpenDialog_Start],OpenDialog_data
  1118.         cmp [OpenDialog_data.status],1
  1119.         jne .end_save_file
  1120.                 ;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
  1121.                 mov dword[png_data],0
  1122.  
  1123.                 ;create image struct
  1124.                 stdcall [img_create], [buf_ogl.w], [buf_ogl.h], Image.bpp24
  1125.                 mov ebx,eax
  1126.                 test eax,eax
  1127.                 jz @f
  1128.                         ;copy foto to image buffer
  1129.                         mov edi,[eax+Image.Data]
  1130.                         mov esi,[buf_ogl]
  1131.                         mov ecx,[buf_ogl.w]
  1132.                         mov edx,[buf_ogl.h]
  1133.                         imul ecx,edx
  1134.                         imul ecx,3
  1135.                         shr ecx,2 ;OpenGL buffer align to 4
  1136.                         rep movsd
  1137.  
  1138.                         ;encode image
  1139.                         stdcall [img_encode], eax, LIBIMG_FORMAT_PNG, 0
  1140.                         test eax,eax
  1141.                         jz @f
  1142.                                 mov [png_data],eax
  1143.                                 mov [png_size],ecx
  1144.                 @@:
  1145.                 stdcall [img_destroy],ebx
  1146.  
  1147.         ; § ¯®«­ï¥¬ áâàãªâãàã ¤«ï á®åà ­¥­¨ï ä ©« 
  1148.         mov ebx,run_file_70
  1149.         mov dword[ebx],SSF_CREATE_FILE
  1150.         mov eax,[png_size]
  1151.         mov [ebx+12],eax ;file size
  1152.         mov eax,[png_data]
  1153.         mov [ebx+16],eax
  1154.         mov dword[ebx+FileInfoBlock.FileName], openfile_path
  1155.  
  1156.         mcall SF_FILE,run_file_70
  1157.         test eax,eax
  1158.         jnz .save_error
  1159.                         ;notify_window_run openfile_path
  1160.                         jmp @f
  1161.                 .save_error:
  1162.                         ;á®®¡é¥­¨¥ ® ­¥ã¤ ç­®¬ á®åà ­¥­¨¨
  1163.                         notify_window_run txt_err_save_img_file
  1164.                 @@:
  1165.                 mcall SF_SYS_MISC, SSF_MEM_FREE, [png_data]
  1166.         .end_save_file:
  1167.         popad
  1168.         ret
  1169. endp
  1170.  
  1171. align 4
  1172. but_2:
  1173.         xor byte[view_b],1
  1174.         mov byte[calc],1
  1175.         ret
  1176.  
  1177. align 4
  1178. but_3:
  1179.         xor byte[trans_a],1
  1180.         call points_update_prop
  1181.         mov byte[calc],1
  1182.         ret
  1183.  
  1184. align 4
  1185. but_about:
  1186.         notify_window_run txt_about
  1187.         ret
  1188.  
  1189. align 4
  1190. calc db 0 ;0 - ­¥ ¯¥à¥áç¨â뢠âì ¡ãä¥à, 1 - ¯¥à¥áç¨â âì ¨ ®¡­®¢¨âì ¡ãä¥à
  1191. view_b db 0 ;0 - ¨á室­ë© ¡ãä¥à, 1 - ¯à®á¬®âà १ã«ìâ â 
  1192. trans_a db 0 ;0 - ¯à¥®¡à §®¢ âì ¯® § ¤ ­­®¬ã à §¬¥àã, 1 - ¯à¥®¡à §®¢ âì ­  ¢¥áì ¡ãä¥à
  1193.  
  1194. align 4
  1195. proc but_img_move_up uses eax
  1196.         cmp dword[sel_act],-1
  1197.         je .end0
  1198.                 mov eax,[sel_act]
  1199.                 imul eax,sizeof.point2d
  1200.                 add eax,sel_pt
  1201.                 cmp dword[eax+point2d.y],0
  1202.                 je .end2
  1203.                 dec dword[eax+point2d.y]
  1204.                 call points_update_prop
  1205.                 jmp .end1
  1206.         .end0:
  1207.         mov eax,[nav_y]
  1208.         sub eax,[nav_sy]
  1209.         cmp eax,[nav_y_min]
  1210.         jge @f
  1211.                 mov eax,[nav_y_min]
  1212.         @@:
  1213.         mov [nav_y],eax
  1214.         .end1:
  1215.         mov byte[calc],1
  1216.         .end2:
  1217.         ret
  1218. endp
  1219.  
  1220. align 4
  1221. proc but_img_move_down uses eax edi
  1222.         cmp dword[sel_act],-1
  1223.         je .end0
  1224.                 mov eax,[sel_act]
  1225.                 imul eax,sizeof.point2d
  1226.                 add eax,sel_pt
  1227.                 mov edi,buf_ogl
  1228.                 mov edi,buf2d_h
  1229.                 cmp dword[eax+point2d.y],edi
  1230.                 jge .end2
  1231.                 inc dword[eax+point2d.y]
  1232.                 call points_update_prop
  1233.                 jmp .end1
  1234.         .end0:
  1235.         mov eax,[nav_y]
  1236.         add eax,[nav_sy]
  1237.         cmp eax,[nav_y_max]
  1238.         jle @f
  1239.                 mov eax,[nav_y_max]
  1240.         @@:
  1241.         mov [nav_y],eax
  1242.         .end1:
  1243.         mov byte[calc],1
  1244.         .end2:
  1245.         ret
  1246. endp
  1247.  
  1248. align 4
  1249. proc but_img_move_left uses eax
  1250.         cmp dword[sel_act],-1
  1251.         je .end0
  1252.                 mov eax,[sel_act]
  1253.                 imul eax,sizeof.point2d
  1254.                 add eax,sel_pt
  1255.                 cmp dword[eax+point2d.x],0
  1256.                 je .end2
  1257.                 dec dword[eax+point2d.x]
  1258.                 call points_update_prop
  1259.                 jmp .end1
  1260.         .end0:
  1261.         mov eax,[nav_x]
  1262.         sub eax,[nav_sx]
  1263.         cmp eax,[nav_x_min]
  1264.         jge @f
  1265.                 mov eax,[nav_x_min]
  1266.         @@:
  1267.         mov [nav_x],eax
  1268.         .end1:
  1269.         mov byte[calc],1
  1270.         .end2:
  1271.         ret
  1272. endp
  1273.  
  1274. align 4
  1275. proc but_img_move_right uses eax edi
  1276.         cmp dword[sel_act],-1
  1277.         je .end0
  1278.                 mov eax,[sel_act]
  1279.                 imul eax,sizeof.point2d
  1280.                 add eax,sel_pt
  1281.                 mov edi,buf_ogl
  1282.                 mov edi,buf2d_w
  1283.                 cmp dword[eax+point2d.x],edi
  1284.                 jge .end2
  1285.                 inc dword[eax+point2d.x]
  1286.                 call points_update_prop
  1287.                 jmp .end1
  1288.         .end0:
  1289.         mov eax,[nav_x]
  1290.         add eax,[nav_sx]
  1291.         cmp eax,[nav_x_max]
  1292.         jle @f
  1293.                 mov eax,[nav_x_max]
  1294.         @@:
  1295.         mov [nav_x],eax
  1296.         .end1:
  1297.         mov byte[calc],1
  1298.         .end2:
  1299.         ret
  1300. endp
  1301.  
  1302. ;input:
  1303. ; eax - ç¨á«®
  1304. ; edi - ¡ãä¥à ¤«ï áâப¨
  1305. ; len - ¤«¨­­  ¡ãä¥à 
  1306. ;output:
  1307. align 4
  1308. proc convert_int_to_str, len:dword
  1309. pushad
  1310.         mov esi,[len]
  1311.         add esi,edi
  1312.         dec esi
  1313.         bt eax,31
  1314.         jae @f
  1315.                 ;¥á«¨ ç¨á«® ®âà¨æ â¥«ì­®¥
  1316.                 neg eax
  1317.                 mov byte[edi],'-'
  1318.                 inc edi
  1319.         @@:
  1320.         call .str
  1321. popad
  1322.         ret
  1323. endp
  1324.  
  1325. align 4
  1326. .str:
  1327.         mov ecx,10
  1328.         cmp eax,ecx
  1329.         jb @f
  1330.                 xor edx,edx
  1331.                 div ecx
  1332.                 push edx
  1333.                 ;dec edi  ;ᬥ饭¨¥ ­¥®¡å®¤¨¬®¥ ¤«ï § ¯¨á¨ á ª®­æ  áâப¨
  1334.                 call .str
  1335.                 pop eax
  1336.         @@:
  1337.         cmp edi,esi
  1338.         jge @f
  1339.                 or al,0x30
  1340.                 stosb
  1341.                 mov byte[edi],0 ;¢ ª®­¥æ áâப¨ áâ ¢¨¬ 0, çâ®-¡ë ­¥ ¢ë« §¨« ¬ãá®à
  1342.         @@:
  1343.         ret
  1344.  
  1345. ;¤ ­­ë¥ ¤«ï ¤¨ «®£  ®âªàëâ¨ï ä ©«®¢
  1346. align 4
  1347. OpenDialog_data:
  1348. .type                   dd 0 ;0 - ®âªàëâì, 1 - á®åà ­¨âì, 2 - ¢ë¡à âì ¤â४â®à¨î
  1349. .procinfo               dd procinfo     ;+4
  1350. .com_area_name          dd communication_area_name      ;+8
  1351. .com_area               dd 0    ;+12
  1352. .opendir_path           dd plugin_path  ;+16
  1353. .dir_default_path       dd default_dir ;+20
  1354. .start_path             dd file_name ;+24 ¯ãâì ª ¤¨ «®£ã ®âªàëâ¨ï ä ©«®¢
  1355. .draw_window            dd draw_window  ;+28
  1356. .status                 dd 0    ;+32
  1357. .openfile_path          dd openfile_path        ;+36 ¯ãâì ª ®âªà뢠¥¬®¬ã ä ©«ã
  1358. .filename_area          dd filename_area        ;+40
  1359. .filter_area            dd Filter
  1360. .x:
  1361. .x_size                 dw 420 ;+48 ; Window X size
  1362. .x_start                dw 10 ;+50 ; Window X position
  1363. .y:
  1364. .y_size                 dw 320 ;+52 ; Window y size
  1365. .y_start                dw 10 ;+54 ; Window Y position
  1366.  
  1367. default_dir db '/rd/1',0
  1368.  
  1369. communication_area_name:
  1370.         db 'FFFFFFFF_open_dialog',0
  1371. open_dialog_name:
  1372.         db 'opendial',0
  1373. communication_area_default_path:
  1374.         db '/rd/1/File managers/',0
  1375.  
  1376. Filter:
  1377. dd Filter.end - Filter ;.1
  1378. .1:
  1379. db 'PNG',0
  1380. db 'JPG',0
  1381. db 'JPEG',0
  1382. db 'BMP',0
  1383. db 'GIF',0
  1384. .end:
  1385. db 0
  1386.  
  1387. txt_space db ' ',0
  1388.  
  1389. if lang eq ru
  1390.         txt_err_save_img_file db '¥ ¬®£ã á®åà ­¨âì *.png ä ©«.',0
  1391.         txt_about db '"Ž ¯à®£à ¬¬¥',13,10,\
  1392.         '„ ­­ ï ¯à®£à ¬¬  ᤥ« ­  ¤«ï ¯à¥®¡à §®¢ ­¨ï ¨§®¡à ¦¥­¨©.',13,10,\
  1393.         '®á«¥ ®âªàëâ¨ï ä ©«  ¨§®¡à ¦¥­¨ï ­ã¦­® 㪠§ âì 4 â®çª¨,',13,10,\
  1394.         'ª®â®àë¥ áâ ­ãâ 㣫 ¬¨ ¯à¥®¡à §®¢ ­®£® ¨§®¡à ¦¥­¨ï." -tI',0
  1395.         txt_pref db ' ¡ ',0,' Š¡',0,' Œ¡',0,' ƒ¡',0 ;¯à¨áâ ¢ª¨: ª¨«®, ¬¥£ , £¨£ 
  1396.         txt_f_size db ' §¬¥à: '
  1397. .size: rb 16
  1398.         txt_img_w db '˜¨à¨­ : '
  1399. .size: rb 16
  1400.         txt_img_h db '‚ëá®â : '
  1401. else
  1402.         txt_err_save_img_file db 'Can',39,'t save *.png file.',0
  1403.         txt_about db '"About',13,10,\
  1404.         'This program is designed to convert images.',13,10,\
  1405.         'After opening the image file, you need to specify 4 points',13,10,\
  1406.         'that will become the corners of the converted image." -tI',0
  1407.         txt_pref db ' b ',0,' Kb',0,' Mb',0,' Gb',0 ;¯à¨áâ ¢ª¨: ª¨«®, ¬¥£ , £¨£ 
  1408.         txt_f_size db 'Size: '
  1409. .size: rb 16
  1410.         txt_img_w db 'Width: '
  1411. .size: rb 16
  1412.         txt_img_h db 'Height: '
  1413. end if
  1414. .size: rb 16
  1415.  
  1416.  
  1417. system_dir_0 db '/sys/lib/'
  1418. lib_name_0 db 'proc_lib.obj',0
  1419. system_dir_1 db '/sys/lib/'
  1420. lib_name_1 db 'libimg.obj',0
  1421. system_dir_2 db '/sys/lib/'
  1422. lib_name_2 db 'buf2d.obj',0
  1423. system_dir_3 db '/sys/lib/'
  1424. lib_name_3 db 'tinygl.obj',0
  1425.  
  1426. align 4
  1427. l_libs_start:
  1428.         lib_0 l_libs lib_name_0, file_name, system_dir_0, import_proclib
  1429.         lib_1 l_libs lib_name_1, file_name, system_dir_1, import_libimg
  1430.         lib_2 l_libs lib_name_2, library_path, system_dir_2, import_buf2d
  1431.         lib_3 l_libs lib_name_3, library_path, system_dir_3, import_lib_tinygl
  1432. l_libs_end:
  1433.  
  1434. align 4
  1435. import_libimg:
  1436.         dd alib_init1
  1437.         img_is_img  dd aimg_is_img
  1438.         img_info    dd aimg_info
  1439.         img_from_file dd aimg_from_file
  1440.         img_to_file dd aimg_to_file
  1441.         img_from_rgb dd aimg_from_rgb
  1442.         img_to_rgb  dd aimg_to_rgb
  1443.         img_to_rgb2 dd aimg_to_rgb2
  1444.         img_decode  dd aimg_decode
  1445.         img_encode  dd aimg_encode
  1446.         img_create  dd aimg_create
  1447.         img_destroy dd aimg_destroy
  1448.         img_destroy_layer dd aimg_destroy_layer
  1449.         img_count   dd aimg_count
  1450.         img_lock_bits dd aimg_lock_bits
  1451.         img_unlock_bits dd aimg_unlock_bits
  1452.         img_flip    dd aimg_flip
  1453.         img_flip_layer dd aimg_flip_layer
  1454.         img_rotate  dd aimg_rotate
  1455.         img_rotate_layer dd aimg_rotate_layer
  1456.         img_draw    dd aimg_draw
  1457.  
  1458.         dd 0,0
  1459.         alib_init1   db 'lib_init',0
  1460.         aimg_is_img  db 'img_is_img',0 ;®¯à¥¤¥«ï¥â ¯® ¤ ­­ë¬, ¬®¦¥â «¨ ¡¨¡«¨®â¥ª  ᤥ« âì ¨§ ­¨å ¨§®¡à ¦¥­¨¥
  1461.         aimg_info    db 'img_info',0
  1462.         aimg_from_file db 'img_from_file',0
  1463.         aimg_to_file db 'img_to_file',0
  1464.         aimg_from_rgb db 'img_from_rgb',0
  1465.         aimg_to_rgb  db 'img_to_rgb',0 ;¯à¥®¡à §®¢ ­¨¥ ¨§®¡à ¦¥­¨ï ¢ ¤ ­­ë¥ RGB
  1466.         aimg_to_rgb2 db 'img_to_rgb2',0
  1467.         aimg_decode  db 'img_decode',0 ; ¢â®¬ â¨ç¥áª¨ ®¯à¥¤¥«ï¥â ä®à¬ â £à ä¨ç¥áª¨å ¤ ­­ëå
  1468.         aimg_encode  db 'img_encode',0
  1469.         aimg_create  db 'img_create',0
  1470.         aimg_destroy db 'img_destroy',0
  1471.         aimg_destroy_layer db 'img_destroy_layer',0
  1472.         aimg_count   db 'img_count',0
  1473.         aimg_lock_bits db 'img_lock_bits',0
  1474.         aimg_unlock_bits db 'img_unlock_bits',0
  1475.         aimg_flip    db 'img_flip',0
  1476.         aimg_flip_layer db 'img_flip_layer',0
  1477.         aimg_rotate  db 'img_rotate',0
  1478.         aimg_rotate_layer db 'img_rotate_layer',0
  1479.         aimg_draw    db 'img_draw',0
  1480.  
  1481. align 4
  1482. import_proclib:
  1483.         OpenDialog_Init dd aOpenDialog_Init
  1484.         OpenDialog_Start dd aOpenDialog_Start
  1485.         OpenDialog_Set_file_name dd aOpenDialog_Set_file_name
  1486.         OpenDialog_Set_file_ext dd aOpenDialog_Set_file_ext
  1487. dd 0,0
  1488.         aOpenDialog_Init db 'OpenDialog_init',0
  1489.         aOpenDialog_Start db 'OpenDialog_start',0
  1490.         aOpenDialog_Set_file_name db 'OpenDialog_set_file_name',0
  1491.         aOpenDialog_Set_file_ext db 'OpenDialog_set_file_ext',0
  1492.  
  1493. align 4
  1494. import_buf2d:
  1495.         init dd sz_init
  1496.         buf2d_create dd sz_buf2d_create
  1497.         buf2d_create_f_img dd sz_buf2d_create_f_img
  1498.         buf2d_clear dd sz_buf2d_clear
  1499.         buf2d_draw dd sz_buf2d_draw
  1500.         buf2d_delete dd sz_buf2d_delete
  1501.         buf2d_resize dd sz_buf2d_resize
  1502.         buf2d_line dd sz_buf2d_line
  1503.         buf2d_rect_by_size dd sz_buf2d_rect_by_size
  1504.         buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size
  1505.         buf2d_circle dd sz_buf2d_circle
  1506.         buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
  1507.         buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
  1508.         buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
  1509.         buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
  1510.         buf2d_bit_blt dd sz_buf2d_bit_blt
  1511.         buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
  1512.         buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
  1513.         buf2d_curve_bezier dd sz_buf2d_curve_bezier
  1514.         buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
  1515.         buf2d_draw_text dd sz_buf2d_draw_text
  1516.         buf2d_crop_color dd sz_buf2d_crop_color
  1517.         buf2d_offset_h dd sz_buf2d_offset_h
  1518.         buf2d_flood_fill dd sz_buf2d_flood_fill
  1519.         buf2d_set_pixel dd sz_buf2d_set_pixel
  1520.         buf2d_get_pixel dd sz_buf2d_get_pixel
  1521.         dd 0,0
  1522.         sz_init db 'lib_init',0
  1523.         sz_buf2d_create db 'buf2d_create',0
  1524.         sz_buf2d_create_f_img db 'buf2d_create_f_img',0
  1525.         sz_buf2d_clear db 'buf2d_clear',0
  1526.         sz_buf2d_draw db 'buf2d_draw',0
  1527.         sz_buf2d_delete db 'buf2d_delete',0
  1528.         sz_buf2d_resize db 'buf2d_resize',0
  1529.         sz_buf2d_line db 'buf2d_line',0
  1530.         sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0
  1531.         sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0
  1532.         sz_buf2d_circle db 'buf2d_circle',0
  1533.         sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
  1534.         sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
  1535.         sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
  1536.         sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
  1537.         sz_buf2d_bit_blt db 'buf2d_bit_blt',0
  1538.         sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
  1539.         sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
  1540.         sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
  1541.         sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
  1542.         sz_buf2d_draw_text db 'buf2d_draw_text',0
  1543.         sz_buf2d_crop_color db 'buf2d_crop_color',0
  1544.         sz_buf2d_offset_h db 'buf2d_offset_h',0
  1545.         sz_buf2d_flood_fill db 'buf2d_flood_fill',0
  1546.         sz_buf2d_set_pixel db 'buf2d_set_pixel',0
  1547.         sz_buf2d_get_pixel db 'buf2d_get_pixel',0
  1548.  
  1549. align 4
  1550. import_lib_tinygl:
  1551.  
  1552. macro E_LIB n
  1553. {
  1554.         n dd sz_#n
  1555. }
  1556. include '../../../programs/develop/libraries/TinyGL/asm_fork/export.inc'
  1557.         dd 0,0
  1558. macro E_LIB n
  1559. {
  1560.         sz_#n db `n,0
  1561. }
  1562. include '../../../programs/develop/libraries/TinyGL/asm_fork/export.inc'
  1563.  
  1564. align 4
  1565. buf_0: dd 0
  1566. .l: dw 5 ;+4 left
  1567. .t: dw 35 ;+6 top
  1568. .w: dd 6*64 ;+8 w
  1569. .h: dd 7*64 ;+12 h
  1570. .color: dd 0x808080 ;+16 color
  1571.         db 24 ;+20 bit in pixel
  1572.  
  1573. align 4
  1574. buf_font:
  1575.         dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
  1576.         dd 0 ;+4 left,top
  1577. .w: dd 0
  1578. .h: dd 0,0,24
  1579.  
  1580. align 4
  1581. buf_cop: ;¡ãä¥à ¤«ï ª®¯¨à®¢ ­¨ï ⥪áâãàë
  1582.         dd 0
  1583. .l: dw 0 ;+4 left
  1584. .t: dw 0 ;+6 top
  1585. .w: dd 0
  1586. .h: dd 0,0,24
  1587.  
  1588. ;¨á室­®¥ ¨§®¡à ¦¥­¨¥
  1589. align 4
  1590. buf_i0: dd 0,0
  1591. .w: dd 0
  1592. .h: dd 0
  1593. .color: dd 0,24
  1594.  
  1595. ;¯à¥®¡à §®¢ ­®¥ ¨§®¡à ¦¥­¨¥
  1596. align 4
  1597. buf_ogl: dd 0,0
  1598. .w: dd 0
  1599. .h: dd 0
  1600. .color: dd 0,24
  1601.  
  1602. align 16
  1603. i_end:
  1604. ctx1 rb 28 ;sizeof.TinyGLContext = 28
  1605. TexObj dd 0 ;¬ áᨢ 㪠§ â¥«¥© ­  ⥪áâãàë (¢ ¤ ­­®¬ á«ãç ¥ 1 èâ.)
  1606. nav_x_min dd 0 ;¬¨­. ª®®à¤. x ¤«ï ­ ¢¨£ æ¨¨
  1607. nav_y_min dd 0 ;¬¨­. ª®®à¤. y ¤«ï ­ ¢¨£ æ¨¨
  1608. nav_x_max dd 0 ;¬ ªá. ª®®à¤. x
  1609. nav_y_max dd 0 ;¬ ªá. ª®®à¤. y
  1610. nav_x dd 0 ;⥪ãé. ª®®à¤. x ¤«ï ­ ¢¨£ æ¨¨
  1611. nav_y dd 0 ;⥪ãé. ª®®à¤. y ¤«ï ­ ¢¨£ æ¨¨
  1612. nav_sx dd 0 ;áªà®« ¯® x
  1613. nav_sy dd 0 ;áªà®« ¯® y
  1614. nav_wnd_w dd 0 ;è¨à¨­  ®ª­  ­ ¢¨£ æ¨¨
  1615. nav_wnd_h dd 0 ;¢ëá® â  ®ª­  ­ ¢¨£ æ¨¨
  1616. nav_wnd_zoom dd 0
  1617. mouse_down_x dd ?
  1618. mouse_down_y dd ?
  1619. sel_act dd ? ;â®çª  ¢ë¡à ­­ ï ¤«ï । ªâ¨à®¢ ­¨ï á ª« ¢¨ âãàë
  1620. sel_pt rb 8*sizeof.point2d ;â®çª¨ ¤«ï ¢ë¡®à  4-å 㣫®¢
  1621. last_time dd 0
  1622. u_line_v dd 0 ;¢¥à⨪ «ì­ ï «¨­¨ï
  1623. u_line_h dd 0 ;£®à¨§®­â «ì­ ï «¨­¨ï
  1624. txt_buf rb 8
  1625. procinfo process_information
  1626. sc system_colors
  1627. run_file_70 FileInfoBlock
  1628.                 rb 4096
  1629. align 16
  1630. stacktop:
  1631.         sys_path rb 1024
  1632.         file_name rb 1024 ;4096
  1633.         library_path rb 1024
  1634.         plugin_path rb 4096
  1635.         openfile_path rb 4096
  1636.         filename_area rb 256
  1637. mem:
  1638.