Subversion Repositories Kolibri OS

Rev

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

  1. use32
  2.         org 0x0
  3.  
  4. db 'MENUET01'
  5. dd 1,START,I_END,MEM,STACKTOP,0,cur_dir_path
  6.  
  7.  
  8. include '../../../../../proc32.inc'
  9. include '../../../../../macros.inc'
  10. include '../../../../../KOSfuncs.inc'
  11. include '../../../box_lib/load_lib.mac'
  12. include '../../../../../dll.inc'
  13. include '../../libimg/libimg.inc'
  14.  
  15. macro cStr dest,txt
  16. {
  17. local .end_t
  18. local .m_txt
  19. jmp .end_t
  20. align 4
  21.         .m_txt db txt,0
  22. align 4
  23. .end_t:
  24. if dest eq
  25.         mov eax,.m_txt
  26. else
  27.         mov dest,.m_txt
  28. end if
  29. }
  30.  
  31. @use_library_mem mem.Alloc,mem.Free,mem.ReAlloc, dll.Load
  32.  
  33. align 4
  34. m1size dd 16*1024
  35. m1 rb 16*1024
  36.  
  37. align 4
  38. START:
  39. load_libraries l_libs_start,load_lib_end
  40. mov     ebp,lib0
  41. .test_lib_open:
  42.         cmp     dword [ebp+ll_struc_size-4],0
  43.         jz      @f
  44.         mcall SF_TERMINATE_PROCESS ;exit not correct
  45. @@:
  46.         add ebp,ll_struc_size
  47.         cmp ebp,load_lib_end
  48.         jl .test_lib_open
  49.  
  50.         ;create image data
  51.         stdcall [buf2d_create], buf_0
  52.         stdcall [buf2d_line], buf_0, 110, 20, 125, 90, 0xffff00
  53.         stdcall [buf2d_line], buf_0, 60, 120, 110, 20, 0xd000
  54.         stdcall [buf2d_curve_bezier], buf_0, (10 shl 16)+20,(110 shl 16)+10,(50 shl 16)+90, dword 0xff
  55.         stdcall [buf2d_circle], buf_0, 125, 90, 30, 0xffffff
  56.         stdcall [buf2d_circle], buf_0, 25, 70, 15, 0xff0000
  57.  
  58.         ;create image struct
  59.         stdcall [img.create], [buf_0.w], [buf_0.h], Image.bpp24
  60.         test eax,eax
  61.         jz @f
  62.                 ;copy image
  63.                 mov edi,[eax+Image.Data]
  64.                 mov esi,[buf_0]
  65.                 mov ecx,[buf_0.w]
  66.                 imul ecx,[buf_0.h]
  67.                 imul ecx,3
  68.                 rep movsb
  69.  
  70.                 ;encode image
  71.                 stdcall [img.encode], eax, LIBIMG_FORMAT_PNG, 0
  72.                 test eax,eax
  73.                 jz @f
  74.  
  75.                 ;copy output image
  76.                 mov edi,m1
  77.                 mov esi,eax
  78.                 mov [m1size],ecx
  79.                 rep movsb
  80.         @@:
  81.  
  82. align 4
  83. red:
  84.     call draw_window
  85.  
  86. align 4
  87. still:
  88.     mcall SF_WAIT_EVENT ; äã­ªæ¨ï 10 - ¦¤ âì ᮡëâ¨ï
  89.  
  90.     cmp  eax,1          ; ¯¥à¥à¨á®¢ âì ®ª­® ?
  91.     je   red            ; ¥á«¨ ¤  - ­  ¬¥âªã red
  92.     cmp  eax,2          ; ­ ¦ â  ª« ¢¨è  ?
  93.     je   key            ; ¥á«¨ ¤  - ­  key
  94.     cmp  eax,3          ; ­ ¦ â  ª­®¯ª  ?
  95.     je   button         ; ¥á«¨ ¤  - ­  button
  96.  
  97.     jmp  still          ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横« 
  98.  
  99. align 4
  100. key:                  ; ­ ¦ â  ª« ¢¨è  ­  ª« ¢¨ âãà¥
  101.     mcall SF_GET_KEY  ; äã­ªæ¨ï 2 - áç¨â âì ª®¤ ᨬ¢®«  (¢ ah)
  102.  
  103.         cmp ah,178 ;Up
  104.         jne @f
  105.                 call but_save_file
  106.         @@:
  107.     jmp  still          ; ¢¥à­ãâìáï ª ­ ç «ã 横« 
  108.  
  109. ;---------------------------------------------------------------------
  110. align 4
  111. button:
  112.     mcall SF_GET_BUTTON
  113.     cmp   ah, 1
  114.     jne   still
  115. .exit:
  116.         stdcall [buf2d_delete],buf_0
  117.     mcall SF_TERMINATE_PROCESS
  118.  
  119. align 4
  120. draw_window:
  121.     mcall SF_REDRAW, SSF_BEGIN_DRAW
  122.     mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc,sizeof.system_colors
  123.     mov   edx, [sc.work]         ; 梥â ä®­ 
  124.     or    edx, 0x33000000        ; ¨ ⨯ ®ª­  3
  125.     mcall SF_CREATE_WINDOW, <50,400>, <50,230>, , ,title
  126.  
  127.         stdcall [buf2d_draw], buf_0
  128.  
  129.         cStr edx,'Img. size:'
  130.         mcall SF_DRAW_TEXT, <10,130>,0x40f0,,10
  131.         mcall SF_DRAW_NUMBER, (5 shl 16)+1, m1size, <80,130>, 0
  132.  
  133.     mcall SF_REDRAW, SSF_END_DRAW
  134.     ret
  135.  
  136. align 4
  137. title db 'Press button [Up] and see '
  138. openfile_path db '/rd/1/t1.png',0
  139.  
  140. struct FileInfoBlock
  141.         Function dd ?
  142.         Position dd ?
  143.         Flags    dd ?
  144.         Count    dd ?
  145.         Buffer   dd ?
  146.                 db ?
  147.         FileName dd ?
  148. ends
  149.  
  150. align 4
  151. run_file_70 FileInfoBlock
  152.  
  153. align 4
  154. but_save_file:
  155.         pushad
  156.         mov eax,SF_FILE
  157.         mov [run_file_70.Function], SSF_CREATE_FILE
  158.         mov [run_file_70.Position], 0
  159.         mov [run_file_70.Flags], 0
  160.         mov [run_file_70.Buffer], m1
  161.         mov ebx,[m1size]
  162.         mov dword[run_file_70.Count], ebx
  163.         mov byte[run_file_70+20], 0
  164.         mov dword[run_file_70.FileName], openfile_path
  165.         mov ebx,run_file_70
  166.         int 0x40
  167.         ;cmp ebx,0xffffffff
  168.         ;je .end_save_file
  169.         ;... if error ...
  170.         ;.end_save_file:
  171.         popad
  172.         ret
  173.  
  174. align 4
  175. buf_0:
  176.         dd 0
  177.         dw 10 ;+4 left
  178.         dw 4 ;+6 top
  179. .w:     dd 360 ;+8 w
  180. .h:     dd 120 ;+12 h
  181.         dd 0x80 ;+16 color
  182.         db 24 ;+20 bit in pixel
  183.  
  184. align 4
  185. sc system_colors
  186.  
  187. align 4
  188. import_buf2d_lib:
  189.         dd sz_lib_init
  190.         buf2d_create dd sz_buf2d_create
  191.         buf2d_create_f_img dd sz_buf2d_create_f_img
  192.         buf2d_clear dd sz_buf2d_clear
  193.         buf2d_draw dd sz_buf2d_draw
  194.         buf2d_delete dd sz_buf2d_delete
  195.         buf2d_line dd sz_buf2d_line
  196.         buf2d_circle dd sz_buf2d_circle
  197.         buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
  198.         buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
  199.         buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
  200.         buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
  201.         buf2d_bit_blt dd sz_buf2d_bit_blt
  202.         buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
  203.         buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
  204.         buf2d_curve_bezier dd sz_buf2d_curve_bezier
  205.         buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
  206.         buf2d_draw_text dd sz_buf2d_draw_text
  207.         dd 0,0
  208.         sz_lib_init db 'lib_init',0
  209.         sz_buf2d_create db 'buf2d_create',0
  210.         sz_buf2d_create_f_img db 'buf2d_create_f_img',0
  211.         sz_buf2d_clear db 'buf2d_clear',0
  212.         sz_buf2d_draw db 'buf2d_draw',0
  213.         sz_buf2d_delete db 'buf2d_delete',0
  214.         sz_buf2d_line db 'buf2d_line',0
  215.         sz_buf2d_circle db 'buf2d_circle',0
  216.         sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
  217.         sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
  218.         sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
  219.         sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
  220.         sz_buf2d_bit_blt db 'buf2d_bit_blt',0
  221.         sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
  222.         sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
  223.         sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
  224.         sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
  225.         sz_buf2d_draw_text db 'buf2d_draw_text',0
  226.  
  227. align 4
  228. import_libimg:
  229.         libimg.init dd sz_lib_init1
  230.         img.draw    dd sz_img_draw
  231.         img.decode  dd sz_img_decode
  232.         img.encode  dd sz_img_encode
  233.         img.create  dd sz_img_create
  234.         img.destroy dd sz_img_destroy
  235.         img.to_rgb2 dd sz_img_to_rgb2
  236.         img.formats_table dd sz_img_formats_table
  237. dd 0,0
  238.         sz_lib_init1   db 'lib_init',0
  239.         sz_img_draw    db 'img_draw',0
  240.         sz_img_decode  db 'img_decode',0
  241.         sz_img_encode  db 'img_encode',0
  242.         sz_img_create  db 'img_create',0
  243.         sz_img_destroy db 'img_destroy',0
  244.         sz_img_to_rgb2 db 'img_to_rgb2',0
  245.         sz_img_formats_table db 'img_formats_table',0
  246.  
  247. ;--------------------------------------------------
  248. system_dir_0 db '/sys/lib/'
  249. lib_name_0 db 'buf2d.obj',0
  250.  
  251. system_dir_1 db '/sys/lib/'
  252. lib_name_1 db 'libimg.obj',0
  253.  
  254. err_message_found_lib0 db 'Sorry I cannot load library buf2d.obj',0
  255. err_message_found_lib1 db 'Sorry I cannot load library libimg.obj',0
  256. head_f_i:
  257. head_f_l db 'System error',0
  258. err_message_import0 db 'Error on load import library buf2d.obj',0
  259. err_message_import1 db 'Error on load import library libimg.obj',0
  260.  
  261. l_libs_start:
  262.         lib0 l_libs lib_name_0, cur_dir_path, library_path, system_dir_0,\
  263.                 err_message_found_lib0, head_f_l, import_buf2d_lib,err_message_import0, head_f_i
  264.         lib1 l_libs lib_name_1, cur_dir_path, library_path, system_dir_1,\
  265.                 err_message_found_lib1, head_f_l, import_libimg, err_message_import1, head_f_i
  266. load_lib_end:
  267. ;---------------------------------------------------------------------
  268.  
  269. align 16
  270. I_END:
  271.         rd 4096
  272. STACKTOP:
  273. cur_dir_path:
  274.         rb 4096
  275. library_path:
  276.         rb 4096
  277. MEM:
  278.