[docs] Replace cyrillic 'с' with latin 'c' in register names
[kolibrios.git] / programs / media / zsea / zSea.asm
blobbb9169f9a393b22c33b469580d5724c78013c9f5
1 ;*****************************************************************************
2 ;*****************************************************************************
3 ; zSea - advanced image viewer for KolibriOS
4 ; Copyright (c) 2008-2014, Marat Zakiyanov aka Mario79, aka Mario
5 ; All rights reserved.
7 ; Redistribution and use in source and binary forms, with or without
8 ; modification, are permitted provided that the following conditions are met:
9 ; * Redistributions of source code must retain the above copyright
10 ; notice, this list of conditions and the following disclaimer.
11 ; * Redistributions in binary form must reproduce the above copyright
12 ; notice, this list of conditions and the following disclaimer in the
13 ; documentation and/or other materials provided with the distribution.
14 ; * Neither the name of the <organization> nor the
15 ; names of its contributors may be used to endorse or promote products
16 ; derived from this software without specific prior written permission.
18 ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
19 ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22 ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ;*****************************************************************************
29 ; v.1.0 rñ5 22.04.2014
30 ;******************************************************************************
31 use32
32 org 0x0
33 db 'MENUET01' ; 8 byte id
34 dd 0x01 ; header version
35 dd START ; start of code
36 dd IM_END ; size of image
37 dd I_END ; memory for app
38 dd stacktop ; esp
39 dd dest_cmdline ; I_Param
40 dd path ; APPLICATION PACH
42 include 'lang.inc'
43 ;include 'macros.inc'
44 ;include 'editbox_ex.mac'
45 ;include 'proc32.inc'
46 include '../../macros.inc'
47 include '../../develop/libraries/box_lib/trunk/box_lib.mac'
48 include '../../proc32.inc'
49 ;include 'debug.inc'
50 include '../../KOSfuncs.inc'
51 include '../../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
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
72 mcall 48,4
73 mov [skin_height],eax
75 mcall 68,12,1024
76 mov [menu_data_1.procinfo],eax
77 mov [menu_data_2.procinfo],eax
78 mov [menu_data_3.procinfo],eax
79 mov [menu_data_4.procinfo],eax
80 mov [menu_data_5.procinfo],eax
81 mov [menu_data_6.procinfo],eax
83 mov [load_directory_pointer],dir_header
86 call load_plugins
88 ;init_checkboxes2 check1,...
89 push check1
90 call [init_checkbox]
91 push check2
92 call [init_checkbox]
94 call load_buttons
96 ; call init_data_OpenDialog
98 ;init_OpenDialog OpenDialog_data
99 push dword OpenDialog_data
100 call [OpenDialog_Init]
102 ;init_ColorDialog ColorDialog_data
103 push dword ColorDialog_data
104 call [ColorDialog_Init]
106 call get_filter_data
108 ;-----------------------------------------------------
109 ; check for parameters
110 mov esi, [28]
111 cmp dword [esi],'BOOT'
112 jne .no_boot
113 .background:
114 call load_image
115 cmp [error_fs],0
116 jnz .exit
117 call convert
119 call background
121 .exit:
122 call Set_ini
123 .exit_1:
124 mov ebx,18
125 mov edx,PID1
126 mov esi,7
127 .kill_successors:
128 mov ecx,[edx]
129 add edx,4
130 test ecx,ecx
131 jz @f
132 mcall 18
134 dec esi
135 jnz .kill_successors
137 mcall -1
138 ;-----------------------------------------------------
139 .no_boot:
140 xor eax,eax
141 cmp [esi],al
142 jnz @f
143 mov [file_name],eax
144 jmp .no_param
148 mov edi,string ; clear string
149 mov ecx,4096/4 ;256/4 ; length of a string
150 xor eax,eax ; symbol <0>
151 rep stosd
154 mov edi, [28] ; look for <0> in temp_area
156 cmp [edi],byte "\"
157 jne .continue
158 cmp [edi+1],byte "T"
159 jne @f
160 mov [bgrmode],dword 1
161 jmp .continue_1
163 cmp [edi+1],byte "S"
164 jne START.exit
165 mov [bgrmode],dword 2
166 .continue_1:
167 add edi,4
168 .continue:
169 mov esi,edi
170 mov ecx,4095 ;257 ; strlen
171 repne scasb
172 mov ecx, edi
173 sub ecx, [28]
175 mov edi,string
176 rep movsb ; copy string from temp_area to "string" (filename)
177 mov ecx, [28]
178 cmp [ecx],byte "\"
179 je START.background
180 call load_directory
181 test eax,eax
182 jnz @f
183 call load_image
184 test eax,eax
185 jnz @f
186 call convert
187 jmp .no_param
189 mov [load_directory_pointer],dir_header
190 mov [error_fs],eax
191 call convert.error
192 ;-----------------------------------------------------
193 .no_param:
194 ; or ecx,-1 ; get information about me
195 ; call getappinfo
197 ; mov edx,[process_info+30] ; òåïåðü â edx íàø èäåíòèôèêàòîð
198 ; mov ecx,eax
200 ; @@:
201 ; call getappinfo
202 ; cmp edx,[process_info+30]
203 ; je @f ; åñëè íàø PID ñîâïàë ñ PID ðàññìàòðèâàåìîãî ïðîöåññà, ìû íàøëè ñåáÿ
204 ; dec ecx ; èíà÷å ñìîòðèì ñëåäóþùèé ïðîöåññ
205 ; jne @b ; âîçâðàùàåìñÿ, åñëè íå âñå ïðîöåññû ðàññìîòðåíû
206 ; @@:
208 ; òåïåðü â ecx íîìåð ïðîöåññà
209 ; mov [process],ecx
210 ;---------------------------------------------------------------------
211 cmp [wnd_width],778
212 jae @f
213 mov [wnd_width],778
215 mcall 48, 5 ; GetClientTop, fix for case when @patel in the top
216 shr ebx, 16
217 mov ecx,ebx
218 shl ecx,16
219 add ecx,523 ; [y start] *65536 + [y size]
220 cmp [wnd_height],ecx
221 jae @f
222 mov [wnd_height],ecx
224 ; call draw_window
225 red:
226 ;draw_still:
227 ; pusha
228 call get_window_param
229 test [window_status],10b
230 jnz red_1 ;still
231 test [window_status],100b
232 jnz red_1
233 test [window_status],1b
234 jnz red_1
235 mov esi,-1
236 mov eax,procinfo
237 mov eax,[eax+66]
238 cmp eax,150
239 ; cmp [window_high],150
240 jae @f
241 mov esi,150
242 mcall 67,-1,ebx,ebx
244 mov edx,-1
245 mov eax,procinfo
246 mov eax,[eax+62]
247 cmp eax,635
248 ; cmp [window_width],635
249 jae @f ;red_1
250 mov edx,635
251 mcall 67,-1,ebx, ,ebx
253 ; mcall 67,-1,ebx
254 ; popa
255 ; xor esi,esi
256 red_1:
257 ; xor eax,eax
258 ; mov [scroll_bar_data_vertical.position],eax
259 ; mov [scroll_bar_data_horizontal.position],eax
261 call draw_window
263 cmp [redraw_wallpaper_flag],0
264 je still
265 mov [redraw_wallpaper_flag],0
266 call clear_thread
267 ; mcall 15,3
268 ; jmp red_1
269 still:
270 call pause_cicle
272 cmp [RAW1_flag],1
273 je animation_handler
275 mcall 48,4
276 cmp [skin_height],eax
277 je @f
278 mov [skin_height],eax
279 call convert.img_resolution_ok
280 jmp red_1
282 mcall 10
284 cmp [open_file_flag],1
285 je kopen_1
286 cmp [sort_directory_flag],byte 1
287 je red_sort_directory
288 cmp [redraw_flag],byte 1
289 je redraw_window
290 cmp eax,1 ; ïåðåðèñîâàòü îêíî ?
291 je red ; åñëè äà - íà ìåòêó red
292 cmp eax,2 ; íàæàòà êëàâèøà ?
293 je key ; åñëè äà - íà key
294 cmp eax,3 ; íàæàòà êíîïêà ?
295 je button ; åñëè äà - íà button
296 cmp eax,6
297 je mouse
298 ; cmp [redraw_wallpaper_flag],1
299 ; jne still
300 ; mov [redraw_wallpaper_flag],0
301 ; mcall 15,3
302 jmp still ; åñëè äðóãîå ñîáûòèå - â íà÷àëî öèêëà
304 red_sort_directory:
305 mov [sort_directory_flag],byte 0
306 jmp red_1
308 redraw_window:
309 mov [redraw_flag],byte 0
310 jmp red_1
312 ;---------------------------------------------------------------------
313 ; red:
314 ; test dword [status], 4
315 ; jz draw_still
316 ; mov al,18
317 ; mov ebx,3
318 ; mov ecx,[process]
319 ; mcall 18,3,[active_process]
320 ; and byte [status], not 4
321 ; jmp still
322 ;---------------------------------------------------------------------
323 button: ; button
324 mov eax,17 ; get id
325 mcall
326 cmp ah,1 ; button id=1 ?
327 je START.exit
328 ; jne .noclose
330 ; mov eax,-1 ; close this program
331 ; mcall
332 .noclose:
333 cmp ah,2
334 je slide_show.3 ;still
335 jmp slide_show
336 ;---------------------------------------------------------------------
337 pause_cicle:
338 pusha
339 .start:
340 mcall 9,procinfo,-1
341 mov eax,[procinfo+70] ;status of window
342 test eax,100b
343 jne @f
344 popa
347 mcall 10
348 dec eax
349 jz .redraw
350 dec eax
351 jz .key
352 dec eax
353 jnz .start
354 .button:
355 mcall -1
356 .key:
357 mcall 2
358 jmp .start
359 .redraw:
360 call draw_window
361 jmp .start
362 ;---------------------------------------------------------------------
363 get_filter_data:
364 mov edi,Filter+4
365 xor eax,eax
366 mov ecx,10
369 mov esi,10
370 sub esi,ecx
371 lea esi,[esi+esi*2] ; x 3
372 shl esi,3 ; x 8
373 add esi,dword Convert_plugin_0.Assoc
374 mov esi,[esi]
375 add esi,4
377 test esi,esi
378 jz @f
379 call .start
380 dec ecx
381 jnz @r
383 mov [edi],byte 0
384 mov eax,Filter
385 sub edi,eax
386 mov [eax],edi
389 .start:
391 lodsb
392 stosb
393 test eax,eax
394 jnz @r
395 cmp [esi],ah
396 jne @r
398 ;---------------------------------------------------------------------
399 kopen_1:
401 mov [open_file_flag],0
402 call load_directory
403 test eax,eax
404 jz kopen
405 .err:
406 mov [load_directory_pointer],dir_header
407 mov [error_fs],eax
408 call convert.error
409 jmp still ;red_1
411 kopen:
412 cmp [string],byte 0
413 je still
415 mov ecx,-1
416 call getappinfo
418 call load_image
420 test eax,eax
421 jnz kopen_1.err
422 call convert
425 call get_window_param
426 test [window_status],1b
427 jz red ;draw_still
428 mov [no_draw_window],1
430 ; push edx
431 ; mov edx,size_after_convert_2
432 ; call write_memory_size
433 ; pop edx
435 call draw_other
437 mov [no_draw_window],0
438 ; jmp draw_still
439 jmp still
440 ;---------------------------------------------------------------------
441 getappinfo:
442 mov eax,9
443 mov ebx,process_info
444 mcall
446 ;---------------------------------------------------------------------
447 get_window_param:
448 mcall 9, procinfo, -1
449 mov eax,[ebx+34]
450 mov [window_start_x],eax
451 mov eax,[ebx+38]
452 mov [window_start_y],eax
453 mov eax,[ebx+66] ;46]
454 inc eax
455 mov [window_high],eax
456 mov eax,[ebx+62] ;42]
457 inc eax
458 mov [window_width],eax
459 mov eax,[ebx+70]
460 mov [window_status],eax
461 ; mcall 48,4
462 ; mov [skin_high],eax
464 ;---------------------------------------------------------------------
465 ;write_memory_size:
466 ; pusha
467 ; mcall 9, procinfo, -1
468 ; mov eax,[ebx+26]
469 ; mov [edx],eax
470 ; popa
471 ; ret
472 ;---------------------------------------------------------------------
473 include 'backgrnd.inc'
474 include 'draw_win.inc'
475 include 'full_win.inc'
476 include 'mouse.inc'
477 include 'key.inc'
478 include 'menu_key.inc'
479 include 'clr_bcgr.inc'
480 include 'w_error.inc'
481 include 'load.inc'
482 include 'animat.inc'
483 include 'draw_img.inc'
484 include 'convert.inc'
485 include 'zoom.inc'
486 include 'w_about.inc'
487 include 'win_file.inc'
488 include 'win_info.inc'
489 include 'win_bcgr.inc'
490 include 'win_sort.inc'
491 include 'win_opti.inc'
492 include 'libini.inc'
493 include '../../dll.inc'
494 include 'data.inc'
495 ;---------------------------------------------------------------------
496 IM_END:
497 include 'dat_area.inc'
498 I_END: