Subversion Repositories Kolibri OS

Rev

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

  1. ;*****************************************************************************
  2. ; zSea - advanced image viewer for KolibriOS
  3. ; Copyright (c) 2008-2011, Marat Zakiyanov aka Mario79, aka Mario
  4. ; All rights reserved.
  5. ;
  6. ; Redistribution and use in source and binary forms, with or without
  7. ; modification, are permitted provided that the following conditions are met:
  8. ;        * Redistributions of source code must retain the above copyright
  9. ;          notice, this list of conditions and the following disclaimer.
  10. ;        * Redistributions in binary form must reproduce the above copyright
  11. ;          notice, this list of conditions and the following disclaimer in the
  12. ;          documentation and/or other materials provided with the distribution.
  13. ;        * Neither the name of the <organization> nor the
  14. ;          names of its contributors may be used to endorse or promote products
  15. ;          derived from this software without specific prior written permission.
  16. ;
  17. ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
  18. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  21. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. ;*****************************************************************************
  28. ;       v.1.0 rñ3 13.06.2011
  29. ;******************************************************************************
  30.         use32
  31.         org 0x0
  32.         db 'MENUET01'   ; 8 byte id
  33.         dd 0x01         ; header version
  34.         dd START        ; start of code
  35.         dd IM_END       ; size of image
  36.         dd I_END        ; memory for app
  37.         dd stacktop     ; esp
  38.         dd temp_area    ; I_Param
  39.         dd path         ; APPLICATION PACH
  40.  
  41. include 'lang.inc'
  42. ;include 'macros.inc'
  43. ;include 'editbox_ex.mac'
  44. ;include 'proc32.inc'
  45.  
  46. include '../../macros.inc'
  47. include '../../develop/libraries/box_lib/trunk/box_lib.mac'
  48. include '../../proc32.inc'
  49.  
  50. ;include 'load_lib.mac'
  51. include '../../develop/libraries/box_lib/load_lib.mac'
  52.         @use_library    ;use load lib macros
  53. ;******************************************************************************
  54.  
  55. START:                          ; start of execution
  56.         mcall   68, 11
  57.         mcall   66, 1,1
  58.         mcall 40, 0x27
  59.  
  60.         mcall 9, procinfo, -1
  61.         mov     eax,[ebx+30]
  62.         mov     [PID],eax
  63.         xor     ecx,ecx
  64. @@:
  65.         inc     ecx
  66.         mcall 9, procinfo
  67.         mov     eax,[PID]
  68.         cmp     eax,[ebx+30]
  69.         jne     @r
  70.         mov     [active_process],ecx
  71.  
  72.         mcall   68,12,1024
  73.         mov     [menu_data_1.procinfo],eax
  74.         mov     [menu_data_2.procinfo],eax
  75.         mov     [menu_data_3.procinfo],eax
  76.         mov     [menu_data_4.procinfo],eax
  77.         mov     [menu_data_5.procinfo],eax
  78.         mov     [menu_data_6.procinfo],eax
  79.  
  80.         mov     [load_directory_pointer],dir_header
  81.  
  82.  
  83.         call    load_plugins
  84.  
  85.  
  86.         call    load_buttons
  87.  
  88. ;       call    init_data_OpenDialog
  89.  
  90. ;init_OpenDialog        OpenDialog_data
  91.         push    dword OpenDialog_data
  92.         call    [OpenDialog_Init]
  93.  
  94.         call    get_filter_data
  95.  
  96. ;-----------------------------------------------------
  97. ; check for parameters
  98.         cmp     dword [temp_area],'BOOT'
  99.         jne     .no_boot
  100. .background:
  101.         call    load_image
  102.         cmp     [error_fs],0
  103.         jnz     .exit
  104.         call    convert
  105.  
  106.         call    background
  107.  
  108. .exit:
  109.         call Set_ini
  110. .exit_1:
  111.         mov     ebx,18
  112.         mov     edx,PID1
  113.         mov     esi,7
  114. .kill_successors:
  115.         mov     ecx,[edx]
  116.         add     edx,4
  117.         test    ecx,ecx
  118.         jz      @f
  119.         mcall 18
  120. @@:
  121.         dec     esi
  122.         jnz     .kill_successors
  123.        
  124.         mcall -1
  125. ;-----------------------------------------------------
  126.  .no_boot:
  127.         xor     eax,eax
  128.         cmp     byte [temp_area],al
  129.         jnz     @f
  130.         mov     [file_name],eax
  131.         jmp .no_param
  132. @@:
  133.  
  134.  
  135.         mov     edi,string      ; clear string
  136.         mov     ecx,256/4       ;       length of a string
  137.         xor     eax,eax ;       symbol <0>
  138.         rep     stosd
  139.  
  140.  
  141.         mov     edi,temp_area   ; look for <0> in temp_area
  142.  
  143.         cmp     [edi],byte "\"
  144.         jne     .continue
  145.         cmp     [edi+1],byte "T"
  146.         jne     @f
  147.         mov     [bgrmode],dword 1
  148.         jmp     .continue_1
  149. @@:
  150.         cmp     [edi+1],byte "S"
  151.         jne     START.exit
  152.         mov     [bgrmode],dword 2
  153. .continue_1:
  154.         add     edi,4
  155. .continue:
  156.         mov     esi,edi
  157.         mov     ecx,257 ;       strlen
  158.         repne scasb
  159.         lea             ecx, [edi-temp_area]
  160.  
  161.         mov     edi,string
  162.         rep     movsb           ; copy string from temp_area to "string" (filename)
  163.         cmp     [temp_area],byte "\"
  164.         je      START.background
  165.         call    load_directory
  166.         test    eax,eax
  167.         jnz     @f
  168.         call    load_image
  169.         test    eax,eax
  170.         jnz     @f
  171.         call    convert
  172.         jmp     .no_param
  173. @@:
  174.         mov     [load_directory_pointer],dir_header
  175.         mov     [error_fs],eax
  176.         call    convert.error
  177. ;-----------------------------------------------------
  178.  .no_param:
  179. ;       or      ecx,-1          ; get information about me
  180. ;       call getappinfo
  181.  
  182. ;       mov edx,[process_info+30] ; òåïåðü â edx íàø èäåíòèôèêàòîð
  183. ;       mov ecx,eax
  184.  
  185. ;       @@:
  186. ;       call getappinfo
  187. ;       cmp edx,[process_info+30]
  188. ;       je      @f      ; åñëè íàø PID ñîâïàë ñ PID ðàññìàòðèâàåìîãî ïðîöåññà, ìû íàøëè ñåáÿ
  189. ;       dec ecx ; èíà÷å ñìîòðèì ñëåäóþùèé ïðîöåññ
  190. ;       jne @b  ; âîçâðàùàåìñÿ, åñëè íå âñå ïðîöåññû ðàññìîòðåíû
  191. ;       @@:
  192.  
  193. ; òåïåðü â ecx íîìåð ïðîöåññà
  194. ;       mov     [process],ecx
  195. ;---------------------------------------------------------------------
  196.         cmp     [wnd_width],635
  197.         jae     @f
  198.         mov     [wnd_width],635
  199. @@:
  200.         cmp     [wnd_height],150
  201.         jae     @f
  202.         mov     [wnd_height],150
  203. @@:
  204. ;       call draw_window
  205. red:
  206. ;draw_still:
  207. ;       pusha
  208.         call    get_window_param
  209.         test    [window_status],10b
  210.         jnz     red_1   ;still
  211.         test    [window_status],100b
  212.         jnz     red_1
  213.         test    [window_status],1b
  214.         jnz     red_1
  215.         mov esi,-1
  216.         mov eax,procinfo
  217.         mov eax,[eax+66]
  218.         cmp     eax,150
  219. ;       cmp     [window_high],150
  220.         jae     @f
  221.         mov     esi,150
  222.         mcall 67,-1,ebx,ebx
  223. @@:
  224.         mov edx,-1
  225.         mov eax,procinfo
  226.         mov eax,[eax+62]
  227.         cmp     eax,635
  228. ;       cmp     [window_width],635
  229.         jae     @f      ;red_1
  230.         mov     edx,635
  231.         mcall 67,-1,ebx, ,ebx
  232. @@:
  233. ;       mcall 67,-1,ebx
  234. ;       popa
  235. ;       xor esi,esi
  236. red_1:
  237. ;       xor     eax,eax
  238. ;       mov     [scroll_bar_data_vertical.position],eax
  239. ;       mov     [scroll_bar_data_horizontal.position],eax
  240.  
  241.         call draw_window
  242.        
  243.         cmp     [redraw_wallpaper_flag],0
  244.         je      still
  245.         mov     [redraw_wallpaper_flag],0
  246.         call    clear_thread
  247. ;       mcall 15,3
  248. ;       jmp  red_1
  249. still:
  250.         cmp     [RAW1_flag],1
  251.         je      animation_handler
  252.         mcall   10
  253. .1:
  254.         cmp     [open_file_flag],1
  255.         je      kopen_1
  256.         cmp     [sort_directory_flag],byte 1
  257.         je      red_sort_directory
  258.         cmp     [redraw_flag],byte 1
  259.         je      redraw_window
  260.         cmp     eax,1   ; ïåðåðèñîâàòü îêíî ?
  261.         je              red     ; åñëè äà - íà ìåòêó red
  262.         cmp     eax,2   ; íàæàòà êëàâèøà ?
  263.         je              key     ; åñëè äà - íà key
  264.         cmp     eax,3   ; íàæàòà êíîïêà ?
  265.         je              button          ; åñëè äà - íà button
  266.         cmp     eax,6
  267.         je      mouse
  268. ;       cmp [redraw_wallpaper_flag],1
  269. ;       jne still
  270. ;       mov     [redraw_wallpaper_flag],0
  271. ;       mcall   15,3
  272.         jmp     still   ; åñëè äðóãîå ñîáûòèå - â íà÷àëî öèêëà
  273.  
  274. red_sort_directory:
  275.         mov     [sort_directory_flag],byte 0
  276.         jmp     red_1
  277.  
  278. redraw_window:
  279.         mov     [redraw_flag],byte 0
  280.         jmp     red_1
  281. ;---------------------------------------------------------------------
  282. ;       red:
  283. ;       test    dword [status], 4
  284. ;       jz      draw_still
  285. ;       mov     al,18
  286. ;       mov     ebx,3
  287. ;       mov     ecx,[process]
  288. ;       mcall   18,3,[active_process]
  289. ;       and     byte [status], not 4
  290. ;       jmp     still
  291. ;---------------------------------------------------------------------
  292. button:                 ; button
  293.         mov     eax,17          ; get id
  294.         mcall
  295.         cmp     ah,1                    ; button id=1 ?
  296.         je      START.exit
  297. ;       jne     .noclose
  298. ;
  299. ;       mov     eax,-1          ; close this program
  300. ;       mcall
  301. .noclose:
  302.         cmp     ah,2
  303.         je      slide_show.3    ;still
  304.         jmp     slide_show
  305. ;---------------------------------------------------------------------
  306. kopen_1:
  307.  
  308.         mov     [open_file_flag],0
  309.         call    load_directory
  310.         test    eax,eax
  311.         jz      kopen
  312. .err:
  313.         mov     [load_directory_pointer],dir_header
  314.         mov     [error_fs],eax
  315.         call    convert.error
  316.         jmp     still   ;red_1
  317.  
  318. kopen:
  319.         cmp     [string],byte 0
  320.         je      still
  321.  
  322.         mov     ecx,-1
  323.         call    getappinfo
  324.  
  325.         call    load_image
  326.  
  327.         test    eax,eax
  328.         jnz     kopen_1.err
  329.         call    convert
  330.  
  331. .1:
  332.         call    get_window_param
  333.         test    [window_status],1b
  334.         jz      red     ;draw_still
  335.         mov     [no_draw_window],1
  336.  
  337. ;       push    edx
  338. ;       mov     edx,size_after_convert_2
  339. ;       call    write_memory_size
  340. ;       pop     edx
  341.  
  342.         call    draw_other
  343.  
  344.         mov     [no_draw_window],0
  345. ;       jmp     draw_still
  346.         jmp     still
  347. ;---------------------------------------------------------------------
  348. getappinfo:
  349.         mov     eax,9
  350.         mov     ebx,process_info
  351.         mcall
  352.         ret
  353. ;---------------------------------------------------------------------
  354. ; ÓÑÒÀÍÎÂÈÒÜ ÔÎÍ
  355. background:
  356.         cmp     [soi],0
  357.         je      .end
  358.         mov     ecx,[img_width] ;       øèðèíà
  359.         test    ecx,ecx
  360.         jz      .end
  361.         mov     edx,[img_high]  ; âûñîòà 
  362.         test    edx,edx
  363.         jz      .end
  364.         mcall   15,1    ; set size
  365.  
  366.         mov     esi,ecx
  367.         imul    esi,edx
  368.         lea     esi,[esi*3]
  369. ;       mov     ebx,5
  370.         mov     ecx,[soi]
  371.  
  372.         xor     edx,edx
  373.  
  374.         cmp     [img_resolution],24
  375.         je      @f
  376. ;       mov     eax,image_file
  377.         push    dword image_file
  378. ;       call    [plugin_convert_background]
  379.         call    [convert_Conv_24b]
  380.         mov     ecx,[raw_pointer_2]
  381.         mcall   15,5    ;15,5 set data
  382.         mov     ecx,[raw_pointer_2]
  383.         mcall   68,13
  384.         jmp     .set_mode
  385. @@:
  386.  
  387.         mcall   15,5    ; 15,5 set data
  388. .set_mode:
  389. ;       dec     ebx     ;tile/stretch
  390.         mov     ecx,[bgrmode]
  391.         mcall   15,4 ; 15,4 set mode
  392.  
  393.         dec     ebx ; 15,3 redraw background
  394.         mcall
  395.  
  396. .end:
  397.         ret
  398. ;---------------------------------------------------------------------
  399. get_window_param:
  400.         mcall   9, procinfo, -1
  401.         mov     eax,[ebx+34]
  402.         mov     [window_start_x],eax
  403.         mov     eax,[ebx+38]
  404.         mov     [window_start_y],eax
  405.         mov     eax,[ebx+66]   ;46]
  406.         inc     eax
  407.         mov     [window_high],eax
  408.         mov     eax,[ebx+62]   ;42]
  409.         inc     eax
  410.         mov     [window_width],eax
  411.         mov     eax,[ebx+70]
  412.         mov     [window_status],eax
  413. ;       mcall   48,4
  414. ;       mov     [skin_high],eax
  415.         ret
  416. ;---------------------------------------------------------------------
  417. ;write_memory_size:
  418. ;       pusha
  419. ;       mcall   9, procinfo, -1
  420. ;       mov     eax,[ebx+26]
  421. ;       mov     [edx],eax
  422. ;       popa
  423. ;       ret
  424. ;---------------------------------------------------------------------
  425. include 'draw_win.inc'
  426. include 'full_win.inc'
  427. include 'mouse.inc'
  428. include 'key.inc'
  429. include 'menu_key.inc'
  430. include 'clr_bcgr.inc'
  431. include 'w_error.inc'
  432. include 'load.inc'
  433. include 'animat.inc'
  434. include 'draw_img.inc'
  435. include 'convert.inc'
  436. include 'zoom.inc'
  437. include 'w_about.inc'
  438. include 'win_file.inc'
  439. include 'win_info.inc'
  440. include 'win_bcgr.inc'
  441. include 'win_sort.inc'
  442. include 'win_opti.inc'
  443. include 'libini.inc'
  444. include 'dll.inc'
  445. include 'data.inc'
  446. ;---------------------------------------------------------------------
  447. IM_END:
  448. include 'dat_area.inc'
  449. I_END:
  450.