diff --git a/programs/media/zsea/Docs/RAW/RAW.png b/programs/media/zsea/Docs/RAW/RAW.png
new file mode 100644
index 0000000000..699a44bea3
Binary files /dev/null and b/programs/media/zsea/Docs/RAW/RAW.png differ
diff --git a/programs/media/zsea/Docs/RAW/RAW_format.doc b/programs/media/zsea/Docs/RAW/RAW_format.doc
new file mode 100644
index 0000000000..4c54d18cad
Binary files /dev/null and b/programs/media/zsea/Docs/RAW/RAW_format.doc differ
diff --git a/programs/media/zsea/Docs/RAW/RAW_format.html b/programs/media/zsea/Docs/RAW/RAW_format.html
new file mode 100644
index 0000000000..32c821e35b
--- /dev/null
+++ b/programs/media/zsea/Docs/RAW/RAW_format.html
@@ -0,0 +1,163 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ RAW ( ).
+
+
+:
+
+
+
+
+
+
+ , |
+
+ , |
+
+ |
+
+
+
+ 0 |
+
+ 4 |
+
+ 'RAW' |
+
+
+
+ 4 |
+
+ 4 |
+
+ X ( ), |
+
+
+
+ 8 |
+
+ 4 |
+
+ Y ( ), |
+
+
+
+ 12 |
+
+ 4 |
+
+
+ - = *
-
+ : 1, 4, 8, 16, 24, 32, 48, 64
+ |
+
+
+
+ 16 |
+
+ 2 |
+
+
+ -
-
+ Grayscale: 1, 4, 8, 16
-
+ R, G, B T (Transparency
+ — ):
+ 5, 8, 16
+ |
+
+
+
+ 18 |
+
+ 2 |
+
+
+ - :
-
+ Grayscale: 1, 2 ( 2 T
+ 8)
-
+ R, G, B: 1, ( 16 ), 3
-
+ R, G, B T (Transparency
+ — ): 4
+ |
+
+
+
+ 20 |
+
+ 4 |
+
+ ( ),
+ 0 |
+
+
+
+ 24 |
+
+ 4 |
+
+ , 256*4=1024
+ . |
+
+
+
+ 28 |
+
+ 4 |
+
+ R, G, B. 0,
+ . |
+
+
+
+ 32 |
+
+ 4 |
+
+ . |
+
+
+
+ 36 |
+
+ 4 |
+
+ T (Transparency
+ — ) |
+
+
+
+ 40 |
+
+ 4 |
+
+ T. |
+
+
+
+ |
+
+
+
+ R, G, B. |
+
+
+
+ T (Transparency
+ — ) |
+
+
+
+
+
\ No newline at end of file
diff --git a/programs/media/zsea/Docs/RAW/RAW_format.odt b/programs/media/zsea/Docs/RAW/RAW_format.odt
new file mode 100644
index 0000000000..134a7227b5
Binary files /dev/null and b/programs/media/zsea/Docs/RAW/RAW_format.odt differ
diff --git a/programs/media/zsea/Docs/RAW/RAW_format.pdf b/programs/media/zsea/Docs/RAW/RAW_format.pdf
new file mode 100644
index 0000000000..0a2cc383b7
Binary files /dev/null and b/programs/media/zsea/Docs/RAW/RAW_format.pdf differ
diff --git a/programs/media/zsea/Docs/RAW1/RAW1.png b/programs/media/zsea/Docs/RAW1/RAW1.png
new file mode 100644
index 0000000000..04303ec464
Binary files /dev/null and b/programs/media/zsea/Docs/RAW1/RAW1.png differ
diff --git a/programs/media/zsea/Docs/RAW1/raw1.doc b/programs/media/zsea/Docs/RAW1/raw1.doc
new file mode 100644
index 0000000000..35dbcbf492
Binary files /dev/null and b/programs/media/zsea/Docs/RAW1/raw1.doc differ
diff --git a/programs/media/zsea/Docs/RAW1/raw1.html b/programs/media/zsea/Docs/RAW1/raw1.html
new file mode 100644
index 0000000000..ca15b2c3dc
--- /dev/null
+++ b/programs/media/zsea/Docs/RAW1/raw1.html
@@ -0,0 +1,209 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - RAW
-
+
+ - gif- START
+ :
-
+
+
+
+
+
+
+
+
+ ,
+ |
+
+ , |
+
+ |
+
+
+
+ 0 |
+
+ 4 |
+
+ 'RAW1' |
+
+
+
+ 4 |
+
+ 4 |
+
+ n = |
+
+
+
+ 8 |
+
+ 4 |
+
+ (
+ ), |
+
+
+
+ 12 |
+
+ 4 |
+
+ (
+ ), |
+
+
+
+ Repeat 0 ; repeat n —
+ , 1 GIF, N
+ 0 |
+
+
+
+ 16+N*16 |
+
+ 4 |
+
+ - 'RAW
+ '**3 |
+
+
+
+ 20+N*16 |
+
+ 4 |
+
+ x- , |
+
+
+
+ 24+N*16 |
+
+ 4 |
+
+ y- , |
+
+
+
+ 28+N*16 |
+
+ 2 |
+
+ , 0.01 **2 |
+
+
+
+ 30+N*16 |
+
+ 1 |
+
+
+ - <Packed Fields>
-
+
+ - 0 bit
+ -
-
+ 0 -
+ , 1 -
-
+
+ - 1 bit
+ —
-
+ :
+
+
+ 0 -
+ .
+
+ - 1
+ - .
-
+
+ - 2,3,4 bit
+ —
-
+ :
-
+ 0 -
+ . .
-
+ 1 - .
+
-
+ 2 - .
+ , ,
+ .
-
+ 3 - .
+ ,
+ ,
+ .
-
+ 4-7 -.
-
+
+ - 5,6,7
+ bit
+ -
-
+
+
+ |
+
+
+
+ 31+N*16 |
+
+ 1 |
+
+ **1
+ (, ) |
+
+
+
+ end repeat 0 |
+
+
+
+ Repeat 1 |
+
+
+
+ Repeat 2 |
+
+
+
+ Repeat 3 |
+
+
+
+ ... |
+
+
+
+ Repeat Nmax |
+
+
+
+
+ - :
+
+ -
+ **1 -
+ , .
+ 0, ,
+ .
-
+ **2 -
-
+ **3 RAW — , RAW
+ ,
+ .
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/programs/media/zsea/Docs/RAW1/raw1.odt b/programs/media/zsea/Docs/RAW1/raw1.odt
new file mode 100644
index 0000000000..67d2ce3f19
Binary files /dev/null and b/programs/media/zsea/Docs/RAW1/raw1.odt differ
diff --git a/programs/media/zsea/Docs/RAW1/raw1.pdf b/programs/media/zsea/Docs/RAW1/raw1.pdf
new file mode 100644
index 0000000000..bea4498a00
Binary files /dev/null and b/programs/media/zsea/Docs/RAW1/raw1.pdf differ
diff --git a/programs/media/zsea/Docs/call_new.txt b/programs/media/zsea/Docs/call_new.txt
new file mode 100644
index 0000000000..76212bb00c
--- /dev/null
+++ b/programs/media/zsea/Docs/call_new.txt
@@ -0,0 +1,68 @@
+
+The block is passed to the plugin:
+;---------------------------------------------------------------------
+; not change this section!!!
+; start section
+;---------------------------------------------------------------------
+align 4
+image_file dd 0 ;+0
+raw_pointer dd 0 ;+4
+return_code dd 0 ;+8
+img_size dd 0 ;+12
+deflate_unpack dd 0 ;+16
+raw_pointer_2 dd 0 ;+20
+;---------------------------------------------------------------------
+; end section
+;---------------------------------------------------------------------
+
+
+Calling plugins:
+
+;---------------------------------------------------------------------
+convert:
+ xor eax,eax
+ cmp [error_fs],eax
+ jnz .error
+ mov [return_code],eax
+; mov eax,image_file
+ push image_file
+ call [plugin]
+ cmp [return_code],dword 0
+ je @f
+ cmp [return_code],dword 2
+ je @f
+;-------------------------------
+ xor eax,eax
+ mov [return_code],eax
+; mov eax,image_file
+ push image_file
+ call [plugin_1]
+ cmp [return_code],dword 0
+ je @f
+ cmp [return_code],dword 2
+ je @f
+;-------------------------------
+ xor eax,eax
+ mov [return_code],eax
+; mov eax,image_file
+ push image_file
+ call [plugin_2]
+ cmp [return_code],dword 0
+ je @f
+ cmp [return_code],dword 2
+ je @f
+;-------------------------------
+ xor eax,eax
+ mov [return_code],eax
+; mov eax,image_file
+ push image_file
+ call [plugin_3]
+;-------------------------------
+@@:
+ mov ecx,[image_file]
+ mcall 68,13
+
+ cmp [return_code],dword 0
+ je .all_ok
+ xor eax,eax
+;-------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/Docs/call_old.txt b/programs/media/zsea/Docs/call_old.txt
new file mode 100644
index 0000000000..082d6813e9
--- /dev/null
+++ b/programs/media/zsea/Docs/call_old.txt
@@ -0,0 +1,66 @@
+
+The block is passed to the plugin:
+;---------------------------------------------------------------------
+; not change this section!!!
+; start section
+;---------------------------------------------------------------------
+align 4
+image_file dd 0 ;+0
+raw_pointer dd 0 ;+4
+return_code dd 0 ;+8
+img_size dd 0 ;+12
+deflate_unpack dd 0 ;+16
+raw_pointer_2 dd 0 ;+20
+;---------------------------------------------------------------------
+; end section
+;---------------------------------------------------------------------
+
+
+Calling plugins:
+
+
+
+;---------------------------------------------------------------------
+convert:
+ xor eax,eax
+ cmp [error_fs],eax
+ jnz .error
+ mov [return_code],eax
+ mov eax,image_file
+ call [plugin]
+ cmp [return_code],dword 0
+ je @f
+ cmp [return_code],dword 2
+ je @f
+;-------------------------------
+ xor eax,eax
+ mov [return_code],eax
+ mov eax,image_file
+ call [plugin_1]
+ cmp [return_code],dword 0
+ je @f
+ cmp [return_code],dword 2
+ je @f
+;-------------------------------
+ xor eax,eax
+ mov [return_code],eax
+ mov eax,image_file
+ call [plugin_2]
+ cmp [return_code],dword 0
+ je @f
+ cmp [return_code],dword 2
+ je @f
+;-------------------------------
+ xor eax,eax
+ mov [return_code],eax
+ mov eax,image_file
+ call [plugin_3]
+;-------------------------------
+@@:
+ mov ecx,[image_file]
+ mcall 68, 13,
+
+ cmp [return_code],dword 0
+ je .all_ok
+ xor eax,eax
+;-------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/Docs/resouce.txt b/programs/media/zsea/Docs/resouce.txt
new file mode 100644
index 0000000000..bc7812ac61
--- /dev/null
+++ b/programs/media/zsea/Docs/resouce.txt
@@ -0,0 +1,10 @@
+Use variable "status":
+
+1 1h 1 open file
+2 2h 10 file info
+4 4h 100 window about
+8 8h 1000 window background
+16 10h 10000 window set sort mode
+32 20h 100000 window error
+64 40h 1000000 window option
+128 80h 10000000
\ No newline at end of file
diff --git a/programs/media/zsea/Docs/zSea_keys.txt b/programs/media/zsea/Docs/zSea_keys.txt
new file mode 100644
index 0000000000..f039ec10b5
--- /dev/null
+++ b/programs/media/zsea/Docs/zSea_keys.txt
@@ -0,0 +1,63 @@
+ࠢ騥 ⠭ zSea v1.00 Beta ( ⥪ ).
+
+ :
+PageUp - ⠭ 㪠⥫ 䠩 砫 ᯨ᪠.
+PageDown - ⠭ 㪠⥫ 䠩 ᯨ᪠.
+Home - ६饭 㪠⥫ 䠩 砫 ᯨ᪠.
+End - ६饭 㪠⥫ 䠩 ᯨ᪠.
+"0" ( . .) "*" ( . .) - ⮬⠡ ࠧ ࠭.
+"+" - 㢥 ⠡
+"-" - 㬥 ⠡
+"|" ( . .) "/" ( . .) - ⠡ 100%
+W - 筮 "⠭ ⨭ ࠡ祣 ⮫"
+I - 筮 " ᬠਢ 䠩"
+S - 筮 "롮 ० "
+O - 筮 "樨 ਫ"
+५ ( . .) - ᤢ ⨭, ⮡ࠦ.
+Enter ( . .) - ⮡ࠦ ࠭ ०.
+PrintScreen - SlideShow, ⠭ Esc Space ().
+Alt+F1 - ⨢ .
+
+ :
+५ ६饭 㭪⠬.
+Esc - .
+Enter - ⢥ত 㭪.
+५ ࠢ ६饭 ᥤ .
+
+
+ :
+Esc - .
+Enter - ⢥ত.
+५ ६饭 㭪⠬.
+"+" "-" .
+Space () - ⨢ ⪫ 㭪, checkbox.
+
+ ᯮ - ਢ .
+
+
+OpenDialog - 䠩 (⤥쭠 ணࠬ):
+1) ६饭 :
+ ) ५ ( ⮬ ᯮ ⥫쭮 ) - ६饭 .
+ ) PageUp - ࠭筮 ⠭ .
+ ) PageDown - ࠭筮 ⠭ .
+ ) Home - 砫 ⠫ 䠩.
+ ) End - ⠫ 䠩.
+2) Enter - ⢨ 䠩 樨 ண 室 뤥:
+ ) 室 .
+ ) ணࠬ.
+3) :
+ Alt+F1 - 맮 롮 ᪠.
+ Alt+F2 - 맮 .
+ Alt+F3 - 맮 䨫樨.
+ :
+ ५ ६饭 㭪⠬.
+ Esc - .
+ Enter - ⢥ত 㭪.
+ ५ ࠢ ६饭 ᥤ .
+4) Ctrl+R - ᮤন ४ਨ.
+5) Backspace (५ 冷 Insert) - 室 ४ਨ.
+6) Insert - 뤥 梥⮬ 䠩 室 ६饭 1 .
+7) Ctrl+A Ctrl+(NumPad(+) Up) - 뤥 䠩 ४ ⨢ , ᪫祭 ४ਨ '..'
+8) Ctrl+(NumPad(-) Up) - 뤥 䠩 ४ ⨢ , ᪫祭 ४ਨ '..'
+9) Ctrl+(NumPad(*) Up) - 뤥 䠩 ४ ⨢ , ᪫祭 ४ਨ '..'
+10) Esc - 襭 ࠡ ணࠬ, 䠩.
diff --git a/programs/media/zsea/animat.inc b/programs/media/zsea/animat.inc
new file mode 100644
index 0000000000..e3c854f75f
--- /dev/null
+++ b/programs/media/zsea/animat.inc
@@ -0,0 +1,345 @@
+;---------------------------------------------------------------------
+RAW1_processing:
+; mov ebx,[raw_pointer]
+; mov eax,[ebx+16]
+; mov [raw_pointer],eax
+; jmp convert.all_ok
+ xor eax,eax
+ mov [Repeat_N],eax
+ inc eax
+ mov [RAW1_flag],al
+
+ mov ebx,[raw_pointer]
+ mov [RAW1_pointer],ebx
+ mov eax,[ebx+4]
+ mov [Total_Repeat_N],eax
+ cmp eax,1
+ jne @f
+ xor eax,eax
+ mov [RAW1_flag],al
+@@:
+; mov [test1],eax
+ mov eax,[ebx+8]
+ mov [img_width],eax
+ mov [img_width_2],eax
+; mov [test1],eax
+ mov ecx,[ebx+12]
+ mov [img_high],ecx
+ mov [img_high_2],ecx
+; mov [test2],ecx
+ imul ecx,eax
+
+; mov eax,ecx
+; shl ecx,1
+; add ecx,eax
+ shl ecx,2
+
+ add ecx,256*4
+ add ecx,44
+ push ecx
+
+ mcall 68,12
+
+ mov [raw_pointer],eax
+ mov ebx,[RAW1_pointer]
+ mov ecx,[ebx+8]
+ mov [eax+4],ecx ; x
+ mov ecx,[ebx+12]
+ mov [eax+8],ecx ; y
+ mov [eax+12],dword 32 ;8
+ mov [eax+20],dword 44
+ mov [eax+24],dword 1024
+ mov [eax+28],dword 44+1024
+; mov [eax+32],
+
+; mov [img_palette],eax
+ add eax,44+1024
+ mov [soi],eax
+ pop ecx
+
+ cmp [Total_Repeat_N],1
+ je @f
+
+ sub ecx,44+1024
+ mov [RAW1_size],ecx
+ mov edi,[soi]
+ mov eax,-1
+ shr ecx,2
+ cld
+ rep stosd
+
+ mov ecx,[RAW1_size]
+ mcall 68,12
+ mov [previous_frame_pointer],eax
+@@:
+ mov [img_resolution_2],8
+ mov [img_resolution],32
+
+ call copy_next_frame
+
+; inc [Repeat_N]
+; call copy_next_frame
+; inc [Repeat_N]
+; call copy_next_frame
+; mov [Repeat_N],0
+
+ jmp convert.img_resolution_ok
+;---------------------------------------------------------------------
+copy_next_frame:
+ mov eax,[RAW1_pointer]
+ mov ebx,[eax+8]
+ mov [RAW1_size_x],ebx
+
+ mov eax,[Repeat_N]
+ shl eax,4
+ ; eax = (start of current Repeat_N) - 16
+ add eax,[RAW1_pointer]
+ mov esi,[eax+16]
+
+ ; esi = pointer to current RAW
+; mov ebx,[RAW1_pointer]
+ mov edi,[RAW1_size_x] ;[ebx+8]
+ mov ebx,[eax+24]
+ shl ebx,2
+ imul edi,ebx
+ mov ebx,[eax+20]
+ shl ebx,2
+ add edi,ebx
+; add edi,[raw_pointer]
+; add edi,44
+ add edi,[soi]
+ ; edi = pointer to start for current frame
+ mov ebx,[eax+28]
+
+ test bx,bx
+ jnz @f
+; inc ebx
+ mov bx,10
+@@:
+ mov [Frame_delay],bx
+ shr ebx,16
+ mov [Transp_index],bh
+
+ mov al,bl
+ shr al,2
+ and al,111b
+ mov [Disposal_Method],al
+; cmp al,2
+; jne @f
+; call save_previous_frame
+;@@:
+ cmp al,3
+ jne @f
+ call save_previous_frame
+@@:
+ and bl,1b
+ mov [Transp_flag],bl
+
+ mov ebx,[esi+4] ; X size og current frame
+ mov ecx,[esi+8] ; Y size og current frame
+
+ mov eax,[esi+20]
+ add eax,esi
+ mov [img_palette],eax
+
+ pusha
+ mov ebx,[raw_pointer]
+ mov edi,[ebx+20]
+ add edi,ebx
+ mov esi,eax
+ mov ecx,256
+ xor eax,eax
+ cld
+ rep movsd
+ popa
+
+ mov eax,[esi+28]
+ add esi,eax
+.y:
+ push edi
+ push ebx
+.x:
+ cld
+ lodsb
+ cmp [Transp_flag],0
+ je @f
+ cmp [Transp_index],al
+ jne @f
+; cmp [Disposal_Method],2
+; jne .not_disposal_backgr
+; mov [edi],dword -1 ; 0xff
+; inc edi
+;.not_disposal_backgr:
+ add edi,4
+ jmp .no_store
+@@:
+ push ebx edi
+ mov ebx,[raw_pointer]
+ mov edi,[ebx+20]
+ add edi,ebx
+ and eax,0xff
+ shl eax,2
+ add edi,eax
+ mov eax,[edi]
+ pop edi ebx
+ stosd
+.no_store:
+ dec ebx
+ jnz .x
+
+ pop ebx
+ pop edi
+ mov eax,[RAW1_size_x]
+ shl eax,2
+ add edi,eax
+ dec ecx
+ jnz .y
+ inc [Repeat_N]
+ mov eax,[Repeat_N]
+; mov [test2],eax
+ cmp [Total_Repeat_N],eax
+ ja @f
+ xor eax,eax
+ mov [Repeat_N],eax
+@@:
+ mcall 26,9
+ movzx ebx,word [Frame_delay]
+ add eax,ebx
+ mov [Animation_timer],eax
+ ret
+;---------------------------------------------------------------------
+animation_handler:
+ mcall 23,1
+; pusha
+; mcall 26,9
+; cmp [Animation_timer],eax
+; ja @f
+; call .draw_image
+;@@:
+; popa
+ cmp [open_file_flag],1
+ je kopen_1
+ cmp [sort_directory_flag],byte 1
+ je red_sort_directory
+ cmp [redraw_flag],byte 1
+ je redraw_window
+ cmp eax,1 ; ?
+ je red ; - red
+ cmp eax,2 ; ?
+ je key ; - key
+ cmp eax,3 ; ?
+ je button ; - button
+ cmp eax,6
+ je mouse
+ mcall 26,9
+ cmp [Animation_timer],eax
+ ja animation_handler ;@f
+.1:
+ call .draw_image
+; mov eax,[scaling_mode]
+; jmp zoom_plus.2
+ jmp still
+;@@:
+; mcall 23,1
+; jmp still.1
+;---------------------------------------------------------------------
+.draw_image:
+; mov eax,[Repeat_N]
+; test eax,eax
+; jz .first_frame
+ mov al,[Disposal_Method]
+ cmp al,2
+ jne @f
+ call restore_background
+ jmp .first_frame
+@@:
+ cmp al,3
+ jne @f
+ call restore_previous_frame
+@@:
+.first_frame:
+ call copy_next_frame
+ mov [no_fill],1
+ call drawimage
+ mov [no_fill],0
+ ret
+;---------------------------------------------------------------------
+restore_background:
+; cmp [Transp_flag],0
+; je @f
+; pusha
+; mov edi,[soi]
+; mov eax,[fill_color] ; -1
+; mov ecx,[RAW1_size]
+; shr ecx,2
+; cld
+; rep stosd
+; popa
+; ret
+;@@:
+ pusha
+ mov eax,[Repeat_N]
+ test eax,eax
+ jz @f
+ dec eax
+@@:
+ shl eax,4
+ ; eax = (start of current Repeat_N) - 16
+ add eax,[RAW1_pointer]
+ mov esi,[eax+16]
+ ; esi = pointer to current RAW
+ mov edi,[RAW1_size_x] ;[ebx+8]
+ mov ebx,[eax+24]
+ shl ebx,2
+ imul edi,ebx
+ mov ebx,[eax+20]
+ shl ebx,2
+ add edi,ebx
+ add edi,[soi]
+ ; edi = pointer to start for current frame
+ mov ebx,[esi+4] ; X size og current frame
+ mov ecx,[esi+8] ; Y size og current frame
+.y:
+ push edi
+ push ebx
+ mov eax,[fill_color]
+.x:
+ cld
+ stosd
+
+ dec ebx
+ jnz .x
+
+ pop ebx
+ pop edi
+ mov eax,[RAW1_size_x]
+ shl eax,2
+ add edi,eax
+ dec ecx
+ jnz .y
+
+ popa
+ ret
+;---------------------------------------------------------------------
+restore_previous_frame:
+ pusha
+ mov esi,[previous_frame_pointer]
+ mov edi,[soi]
+ mov ecx,[RAW1_size]
+ shr ecx,2
+ cld
+ rep movsd
+ popa
+ ret
+;---------------------------------------------------------------------
+save_previous_frame:
+ pusha
+ mov esi,[soi]
+ mov edi,[previous_frame_pointer]
+ mov ecx,[RAW1_size]
+ shr ecx,2
+ cld
+ rep movsd
+ popa
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/build.bat b/programs/media/zsea/build.bat
new file mode 100644
index 0000000000..9bd8a31461
--- /dev/null
+++ b/programs/media/zsea/build.bat
@@ -0,0 +1,5 @@
+@echo lang fix en >lang.inc
+@fasm -m 16384 zSea.asm zSea
+@erase lang.inc
+@kpack zSea
+@pause
\ No newline at end of file
diff --git a/programs/media/zsea/build.sh b/programs/media/zsea/build.sh
new file mode 100644
index 0000000000..e1c1c272f3
--- /dev/null
+++ b/programs/media/zsea/build.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+# This script does for linux the same as build.bat for DOS
+ echo "lang fix en"
+ echo "lang fix en" > lang.inc
+ fasm -m 65536 zSea.asm zSea
+ @kpack zSea
+ rm -f lang.inc
+ read
+ exit 0
diff --git a/programs/media/zsea/clr_bcgr.inc b/programs/media/zsea/clr_bcgr.inc
new file mode 100644
index 0000000000..e6fcf7a2db
--- /dev/null
+++ b/programs/media/zsea/clr_bcgr.inc
@@ -0,0 +1,17 @@
+;---------------------------------------------------------------------
+clear_thread:
+ call get_memory_for_tread_stack
+ mov [clear_thread_stack],eax
+ mcall 51, 1, clear_thread_start ;, clear_thread_stack
+ ret
+;---------------------------------------------------------------------
+clear_thread_start:
+ mcall 5,100
+@@:
+ mcall 23,10
+ cmp eax,5
+ je @f
+ mcall 15,3
+ mcall 68,13,[clear_thread_stack]
+ mcall -1
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/config.inc b/programs/media/zsea/config.inc
new file mode 100644
index 0000000000..dc70bf9760
--- /dev/null
+++ b/programs/media/zsea/config.inc
@@ -0,0 +1 @@
+__CPU_type fix p5
diff --git a/programs/media/zsea/convert.inc b/programs/media/zsea/convert.inc
new file mode 100644
index 0000000000..f092129778
--- /dev/null
+++ b/programs/media/zsea/convert.inc
@@ -0,0 +1,258 @@
+;---------------------------------------------------------------------
+convert_plugin_invoke:
+ mov eax,[plugin_0_name]
+ call prepare_convert
+ push eax
+ call [Convert_plugin_0.Start]
+ call check_convert
+;-------------------------------
+ mov eax,[plugin_1_name]
+ call prepare_convert
+ push eax
+ call [Convert_plugin_1.Start]
+ call check_convert
+;-------------------------------
+ mov eax,[plugin_2_name]
+ call prepare_convert
+ push eax
+ call [Convert_plugin_2.Start]
+ call check_convert
+;-------------------------------
+ mov eax,[plugin_3_name]
+ call prepare_convert
+ push eax
+ call [Convert_plugin_3.Start]
+ call check_convert
+;-------------------------------
+ mov eax,[plugin_4_name]
+ call prepare_convert
+ push eax
+ call [Convert_plugin_4.Start]
+ call check_convert
+;-------------------------------
+ mov eax,[plugin_5_name]
+ call prepare_convert
+ push eax
+ call [Convert_plugin_5.Start]
+ call check_convert
+;-------------------------------
+ mov eax,[plugin_6_name]
+ call prepare_convert
+ push eax
+ call [Convert_plugin_6.Start]
+ call check_convert
+;-------------------------------
+ mov eax,[plugin_7_name]
+ call prepare_convert
+ push eax
+ call [Convert_plugin_7.Start]
+ call check_convert
+;-------------------------------
+ mov eax,[plugin_8_name]
+ call prepare_convert
+ push eax
+ call [Convert_plugin_8.Start]
+ mov eax,[return_code]
+ call check_convert
+;-------------------------------
+ mov eax,[plugin_9_name]
+ call prepare_convert
+ push eax
+ call [Convert_plugin_9.Start]
+;-------------------------------
+.end:
+ mov ecx,[image_file]
+ mcall 68, 13,
+ ret
+;---------------------------------------------------------------------
+prepare_convert:
+ cmp eax,dword 'NoKe'
+ je .1 ;@f
+ xor eax,eax
+ mov [return_code],eax
+ mov eax,image_file
+ ret
+.1:
+ add esp,4
+ jmp convert_plugin_invoke.end
+;---------------------------------------------------------------------
+check_convert:
+ mov eax,[return_code]
+ test eax,eax
+ jz prepare_convert.1
+ cmp eax,dword 2
+ je prepare_convert.1
+ ret
+;---------------------------------------------------------------------
+convert:
+ xor eax,eax
+ cmp [error_fs],eax
+ jnz .error
+
+ call convert_plugin_invoke
+
+ cmp [return_code],dword 0
+ je .all_ok
+ xor eax,eax
+;-------------------------------
+.error_1:
+ mov [img_size],eax
+ mov [img_width],eax
+ mov [img_width_2],eax
+ mov [img_high],eax
+ mov [img_high_2],eax
+ mov [img_resolution],eax
+ mov [img_resolution_2],eax
+ mov [img_palette],eax
+ mov [soi],eax
+ mov [file_name],eax
+ mov [Total_Repeat_N],eax
+ mov [RAW1_pointer],eax
+ mov [RAW1_flag],al
+
+ mov [scaling_mode],dword 100
+ call error_window
+ ret
+;-------------------------------
+.error:
+ xor eax,eax
+ mov [return_code],eax
+ jmp .error_1
+;-------------------------------
+.all_ok:
+ mov ebx,[raw_pointer]
+ cmp [ebx],dword 'RAW1'
+ je RAW1_processing
+ xor eax,eax
+ mov [RAW1_flag],al
+ mov [RAW1_pointer],eax
+ inc eax
+ mov [Total_Repeat_N],eax
+ mov eax,[ebx+4]
+ mov [img_width],eax
+ mov [img_width_2],eax
+ mov eax,[ebx+8]
+ mov [img_high],eax
+ mov [img_high_2],eax
+ mov eax,[ebx+12]
+ mov [img_resolution_2],eax
+; mov eax,[ebx+20]
+; add eax,ebx
+; mov [img_palette],eax
+; mov eax,[ebx+28]
+; add eax,ebx
+; mov [soi],eax
+;-------------------------------
+; xor eax,eax
+; mov [raw_pointer_2],eax
+ mov eax,image_file
+; call [plugin_convert]
+ call [convert_Start]
+
+ mov ebx,[raw_pointer]
+ mov eax,[ebx+12]
+; cmp [ebx+18],word 2
+; jne @f
+; shr eax,1
+;@@:
+ cmp eax,15
+ jne @f
+ inc eax
+@@:
+ mov [img_resolution],eax
+
+ mov eax,[ebx+20]
+ add eax,ebx
+ mov [img_palette],eax
+
+ mov eax,[ebx+28]
+ add eax,ebx
+ mov [soi],eax
+
+; mov eax,[raw_pointer_2]
+; test eax,eax
+; jz @f
+; mov [soi],eax
+;@@:
+
+;-------------------------------
+; mov eax,[img_resolution]
+; cmp eax,32
+; ja @f
+; cmp [ebx+18],word 2
+; je @f
+; cmp [ebx+18],word 1
+; jne .img_resolution_ok
+;.grayscale_16:
+; cmp eax,16
+; jne .img_resolution_ok
+; shr eax,1
+; mov [img_resolution],eax
+; jmp .img_resolution_ok
+;@@:
+; shr eax,1
+; cmp eax,16
+; jne @f
+; shr eax,1
+;@@:
+; mov [img_resolution],eax
+
+.img_resolution_ok:
+ xor eax,eax
+ mov [scroll_bar_data_vertical.position],eax
+ mov [scroll_bar_data_horizontal.position],eax
+ call get_window_param
+ test [window_status],1b
+ jnz .end
+ cmp [scaling_mode],dword 100
+ jne .end
+ mov ebx,[img_high]
+ mov eax,[img_width]
+ test ebx, ebx
+ jns @f
+ neg ebx
+@@:
+ add eax,9
+ cmp eax,770
+ jae @f
+ mov eax,770
+@@:
+ add ebx,54
+ cmp ebx,150
+ jae @f
+ mov ebx,150
+@@:
+ mov [wnd_width],eax
+ mov [wnd_height],ebx
+
+ mcall 14
+
+ mov ebx,eax
+ and eax,0xffff
+ shr ebx,16
+ inc eax
+ inc ebx
+ cmp eax,[wnd_height]
+ jae @f
+ xor eax,eax
+ mov ax,[scroll_bar_data_vertical.size_x]
+ add [wnd_width],eax
+@@:
+ cmp ebx,[wnd_width]
+ jae @f
+ xor eax,eax
+ mov ax,[scroll_bar_data_horizontal.size_y]
+ add [wnd_height],eax
+@@:
+ mov eax,[wnd_width]
+ mov ebx,[wnd_height]
+
+ test [bWasDraw],1
+ jz @f
+ mov esi,ebx
+ mov edx,eax
+ mcall 67,-1,-1
+@@:
+.end:
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/dat_area.inc b/programs/media/zsea/dat_area.inc
new file mode 100644
index 0000000000..254b00cd18
--- /dev/null
+++ b/programs/media/zsea/dat_area.inc
@@ -0,0 +1,102 @@
+string:
+; rb string+257-$
+ rb 4096
+;string_1:
+; rb 4096
+;----------------------
+path:
+ rb 4096
+;----------------------
+;plugin_pach_1:
+; rb 4096
+;----------------------
+plugin_pach:
+ rb 4096
+;----------------------
+library_path:
+ rb 4096
+;----------------------
+Filter:
+ rb 4096
+;----------------------
+Help_path:
+ rb 1024 ;4096
+;----------------------
+Editor_path:
+ rb 1024 ;4096
+;----------------------
+OpenDialog_path:
+ rb 1024 ;4096
+;----------------------
+key_help_name:
+ rb 128
+;----------------------
+plugin_0_name:
+ rb 128
+plugin_1_name:
+ rb 128
+plugin_2_name:
+ rb 128
+plugin_3_name:
+ rb 128
+plugin_4_name:
+ rb 128
+plugin_5_name:
+ rb 128
+plugin_6_name:
+ rb 128
+plugin_7_name:
+ rb 128
+plugin_8_name:
+ rb 128
+plugin_9_name:
+ rb 128
+;----------------------
+file_name:
+ rb 1024
+;----------------------
+temp_area:
+ rb 4096
+;----------------------
+procinfo:
+process_info:
+ rb 1024
+;----------------------
+procinfo_threads:
+ rb 1024
+;----------------------
+; clear bacground thread
+; rb 512
+;clear_thread_stack:
+;----------------------
+; window option
+; rb 1024 ;4096
+;thread_stack_7:
+;----------------------
+; window error message
+; rb 1024 ;4096
+;thread_stack_6:
+;----------------------
+; window set sort mode
+; rb 1024 ;4096
+;thread_stack_5:
+;----------------------
+; window background
+; rb 1024 ;4096
+;thread_stack_4:
+;----------------------
+; window about
+; rb 1024 ;4096
+;thread_stack_3:
+;----------------------
+; file info
+; rb 1024 ;4096
+;thread_stack_2:
+;----------------------
+; file open
+; rb 1024 ;4096
+;thread_stack:
+;----------------------
+ rb 4096
+stacktop:
+;----------------------
\ No newline at end of file
diff --git a/programs/media/zsea/data.inc b/programs/media/zsea/data.inc
new file mode 100644
index 0000000000..1168e499a7
--- /dev/null
+++ b/programs/media/zsea/data.inc
@@ -0,0 +1,1710 @@
+;---------------------------------------------------------------------
+; DATA AREA
+;---------------------------------------------------------------------
+lsz labelt1,\
+ en, 'File',\
+ ru, '',\
+ de, 'Datei'
+ db 0
+
+;---------------------------------------------------------------------
+lsz labelt2,\
+ en, 'File info',\
+ ru, 'ଠ 䠩',\
+ de, 'Dateiinfo'
+ db 0
+
+lsz fitext,\
+ en, 'File name ',\
+ en, 'File size ',\
+ en, 'X size ',\
+ en, 'Y size ',\
+ en, 'Resolution ',\
+ en, 'Frames total ',\
+ \
+ ru, ' 䠩 ',\
+ ru, ' 䠩 ',\
+ ru, 'ਭ ',\
+ ru, ' ',\
+ ru, ' ᥫ ',\
+ ru, 'ᥣ ',\
+ \
+ de, 'Datei Namen ',\
+ de, 'Fateigroesse ',\
+ de, 'X groesse ',\
+ de, 'Y groesse ',\
+ de, 'Die Tiefe ',\
+ de, 'Zahl Frames '
+ db 0
+;---------------------------------------------------------------------
+Authors_text:
+.1: db 'zSea version: 1.00 RC3 Date: 12/06/2011',0
+.2: db 'Authors:',0
+.3: db 'Marat Zakiyanov aka Mario(Mario79)',0
+.4: db 'zSea program, modules: cnv_bmp.obj,',0
+.5: db 'cnv_png.obj, convert.obj, rotate.obj ',0
+.6: db 'scaling.obj, box_lib.obj, OpenDialog',0
+.7: db 'proc_lib.obj',0
+
+.8: db 'Evgeny Grechnikov aka Diamond',0
+.9: db 'modules: cnv_jpeg.obj, cnv_gif.obj,',0
+.10: db 'archiver.obj, sort.obj ',0
+
+.11: db 'Alexey Teplov aka ',0
+.12: db 'modules: box_lib.obj, load_lib.mac',0
+
+.13: db 'Mihail Semenyako aka Mike.dld',0
+.14: db 'modules: libini.obj, libio.obj',0
+;---------------------------------------------------------------------
+status dd 0 ;bit0=1 if file thread is created
+;process dd 0
+
+bWasDraw db 0
+vflag: db 'x'
+bgrmode: dd 1
+
+wnd_width dd 210
+wnd_height dd 53
+;---------------------------------
+lsz labelt3,\
+ en, 'About program',\
+ ru, ' ணࠬ',\
+ de, 'Uber das programm'
+ db 0
+;---------------------------------
+lsz labelt4,\
+ en, 'Set wallpaper',\
+ ru, '⠭ 䮭',\
+ de, 'Installation hintergrund'
+ db 0
+;---------------------------------
+lsz labelt5,\
+ en, 'Select sorting mode',\
+ ru, ' ४ਨ',\
+ de, 'Regimes der Sortierung'
+ db 0
+;---------------------------------
+lsz bgrdtext,\
+ en, 'Set as background:',\
+ ru, ' :',\
+ de, 'Als hintergrund'
+ db 0
+;---------------------------------
+lsz sorttext,\
+ en, 'Directory sorting mode:',\
+ ru, ' ४ਨ:',\
+ de, 'Regime der Sortierung des Verzeichnisses:'
+ db 0
+;---------------------------------
+lsz errortext,\
+ en, 'File system error:',\
+ ru, '訡 䠩 ⥬:',\
+ de, 'Fehler files systemes:'
+ db 0
+;---------------------------------
+lsz optiontext,\
+ en, 'Options:',\
+ ru, 'ன:',\
+ de, 'Optionen:'
+ db 0
+;---------------------------------
+;lsz tiled,\
+; en, 'Tiled',\
+; ru, '',\
+; de, 'Gekachelt'
+
+;lsz stretch,\
+; en, 'Stretch',\
+; ru, '',\
+; de, 'Gestreckt'
+;---------------------------------
+lsz ok_btn,\
+ en, 'Ok',\
+ ru, 'Ok',\
+ de, 'Ok'
+ db 0
+;---------------------------------
+lsz slide_show_delay_title,\
+ en, 'Slide show delay:',\
+ ru, 'প :',\
+ de, 'Verzug der schau:'
+ db 0
+;---------------------------------
+lsz arrows_offset_title,\
+ en, 'Arrows offset:',\
+ ru, '饭 ५:',\
+ de, 'Bewegung von den zeigern:'
+ db 0
+;---------------------------------
+slide_show_delay_text:
+ db '+ -',0
+;---------------------------------------------------------------------
+zoom_auto_factor:
+ dd 0
+zoom_auto_text:
+ db 'auto',0
+zoom_factors:
+ dd zoom_factors.100
+.1: dd 0
+.min:
+ dd 1
+ dd 2
+ dd 3
+ dd 4
+ dd 5
+ dd 7
+ dd 10
+ dd 17
+ dd 25
+ dd 37
+ dd 50
+ dd 62
+ dd 75
+ dd 87
+.100:
+ dd 100
+ dd 125
+ dd 150
+ dd 175
+ dd 200
+ dd 225
+ dd 250
+ dd 275
+ dd 300
+ dd 350
+ dd 400
+ dd 450
+ dd 500
+ dd 600
+ dd 700
+ dd 800
+ dd 900
+ dd 1000
+ dd 1100
+ dd 1200
+ dd 1300
+ dd 1400
+ dd 1500
+ dd 1750
+ dd 2000
+ dd 2250
+ dd 2500
+ dd 2750
+ dd 3000
+ dd 3500
+ dd 4000
+ dd 4500
+.max:
+ dd 5000
+
+zoom_factors_old dd 0
+;---------------------------------------------------------------------
+; not change this section!!!
+; start section
+;---------------------------------------------------------------------
+align 4
+image_file dd 0 ;+0
+raw_pointer dd 0 ;+4
+return_code dd 0 ;+8
+img_size dd 0 ;+12
+deflate_unpack dd 0 ;+16
+raw_pointer_2 dd 0 ;+20
+;---------------------------------------------------------------------
+; end section
+;---------------------------------------------------------------------
+test1 dd 0 ;+24
+test2 dd 0 ;+28
+test3 dd 0 ;+32
+test4 dd 0 ;+36
+test5 dd 0 ;+40
+test6 dd 0 ;+44
+test7 dd 0 ;+48
+;---------------------------------------------------------------------
+align 4
+soi dd 0
+img_width dd 0
+img_width_2 dd 0
+img_high dd 0
+img_high_2 dd 0
+img_resolution dd 0
+img_resolution_2 dd 0
+img_palette dd 0
+
+background_color dd 0xffffff
+
+RAW1_pointer dd 0
+RAW1_size_x dd 0
+RAW1_size dd 0
+Repeat_N dd 0
+Total_Repeat_N dd 1
+previous_frame_pointer dd 0
+Animation_timer dd 0
+Frame_delay dw 0
+Transp_flag db 0
+Transp_index db 0
+Disposal_Method db 0
+RAW1_flag db 0
+no_fill db 0
+redraw_wallpaper_flag db 0
+
+calc_next_value_plus db 0
+calc_next_value_minus db 0
+;---------------------------------------------------------------------
+align 4
+;plugin dd 0
+;plugin_1 dd 0
+;plugin_2 dd 0
+;plugin_3 dd 0
+
+;plugin_validate dd 0
+;plugin_validate_1 dd 0
+;plugin_validate_2 dd 0
+;plugin_validate_3 dd 0
+
+;plugin_format dd 0
+;plugin_format_1 dd 0
+;plugin_format_2 dd 0
+;plugin_format_3 dd 0
+
+;plugin_convert dd 0
+;plugin_convert_background dd 0
+;plugin_sort dd 0
+;plugin_rotate dd 0
+;plugin_scaling dd 0
+
+slide_show_delay dd 500 ; cost of 0,01 sec.
+slide_show_delay_old dd 0
+
+sort_type dd 2
+sort_type_old dd 0
+;---------------------------------------------------------------------
+expansion_length dd 0
+expansion_start dd 0
+
+timer dd 0
+;---------------------------------------------------------------------
+mouse_scroll_data:
+ .vertical dw 0
+ .horizontal dw 0
+
+mouse_position:
+ .y dw 0
+ .x dw 0
+
+mouse_position_old:
+ .y dw 0
+ .x dw 0
+
+mouse_keys dd 0
+mouse_keys_old dd 0
+
+arrows_offset dd 10
+arrows_offset_old dd 10
+
+option_pointer dd 0
+plus_pointer dd 0
+minus_pointer dd 0
+space_pointer dd 0
+
+;---------------------------------------------------------------------
+pos: dd 6
+
+work_area_LR_old dd 0
+work_area_TB_old dd 0
+
+scaling_mode dd 100
+scaling_mode_old dd 100
+
+window_start_x_old dd 0
+window_start_y_old dd 0
+window_high_old dd 0
+window_width_old dd 0
+
+window_start_x dd 0
+window_start_y dd 0
+window_high dd 0
+window_width dd 0
+;skin_high dd 0
+window_status dd 0
+draw_SB db 0
+draw_SB1 db 0
+correct_w db 0
+correct_h db 0
+wa_width dw 0
+wa_high dw 0
+
+wa_width_1 dw 0
+wa_width_2 dw 0
+
+wa_high_1 dw 0
+wa_high_2 dw 0
+
+image_start_coordinates dd 0
+image_draw_size:
+.y: dw 0
+.x: dw 0
+
+vertical_position_coorect dd 0
+horizontal_position_coorect dd 0
+
+fill_color dd 0xffffff
+fill_color_old dd 0xffffff
+
+position_coorect db 0
+
+open_file_flag db 0
+sort_directory_flag db 0
+redraw_flag db 0
+
+press_Enter_flag db 0
+
+capture_image_area_flag db 0
+
+correct_scrollbar_100_flag db 0
+;---------------------------------------------------------------------
+;test_area:
+;dd test_area.end - test_area
+;db 'BMP',0
+;.end:
+;db 0,0,0,0,0,0,0,0,0,0,0,0,0
+;---------------------------------------------------------------------
+aApplicationsPaths db 'ApplicationsPaths',0
+aOther db 'Other',0
+
+aHelp db 'Help',0
+aEditor db 'Editor',0
+aOpenDialog db 'OpenDialog',0
+akey_help db 'HelpFile',0
+
+aConvertPlugins db 'ConvertPlugins',0
+
+ConvertPlugins_no_key db 'NoKey',0
+
+aCP0 db 'CP0',0
+aCP1 db 'CP1',0
+aCP2 db 'CP2',0
+aCP3 db 'CP3',0
+aCP4 db 'CP4',0
+aCP5 db 'CP5',0
+aCP6 db 'CP6',0
+aCP7 db 'CP7',0
+aCP8 db 'CP8',0
+aCP9 db 'CP9',0
+;---------------------------------------------------------------------
+plugin_BMP_name db 'cnv_bmp.obj',0
+plugin_PNG_name db 'cnv_png.obj',0
+plugin_JPEG_name db 'cnv_jpeg.obj',0
+plugin_GIF_name db 'cnv_gif.obj',0
+
+;plugin_convert_name db 'convert.obj',0
+;plugin_sort_name db 'sort.obj',0
+;plugin_rotate_name db 'rotate.obj',0
+;plugin_scaling_name db 'scaling.obj',0
+;plugin_UNPACK_name db 'archiver.obj',0
+;boxlib_name db 'box_lib.obj',0
+;Libini_name db 'libini.obj',0
+plugins_directory db 'plugins/',0
+ini_file_name db 'zsea.ini',0
+
+button_name db 'buttons.png',0
+;buttons_passive_name db '1.png',0
+;buttons_active_name db '2.png',0
+;buttons_click_name db '3.png',0
+
+buttons_directory db 'buttons/',0
+;UNPACK_function_name db 'deflate_unpack',0
+;UNPACK_function_name_end:
+;UNPACK_function_name db 'deflate_unpack2',0
+;UNPACK_function_name_end:
+
+system_dir_Boxlib db '/sys/lib/box_lib.obj',0
+system_dir_Libini db '/sys/lib/libini.obj',0
+system_dir_Sort db '/sys/lib/sort.obj',0
+system_dir_UNPACK db '/sys/lib/archiver.obj',0
+system_dir_Convert db '/sys/lib/convert.obj',0
+system_dir_Rotate db '/sys/lib/rotate.obj',0
+system_dir_Scaling db '/sys/lib/scaling.obj',0
+system_dir_ProcLib db '/sys/lib/proc_lib.obj',0
+
+err_message_found_lib1 db 'box_lib.obj - Not found!',0
+err_message_found_lib2 db 'libini.obj - Not found!',0
+err_message_found_lib3 db 'sort.obj - Not found!',0
+err_message_found_lib4 db 'archiver.obj - Not found!',0
+err_message_found_lib5 db 'convert.obj - Not found!',0
+err_message_found_lib6 db 'rotate.obj - Not found!',0
+err_message_found_lib7 db 'scaling.obj - Not found!',0
+err_message_found_lib8 db 'proc_lib.obj - Not found!',0
+
+err_message_import1 db 'box_lib.obj - Wrong import!',0
+err_message_import2 db 'libini.obj - Wrong import!',0
+err_message_import3 db 'sort.obj - Wrong import!',0
+err_message_import4 db 'archiver.obj - Wrong import!',0
+err_message_import5 db 'convert.obj - Wrong import!',0
+err_message_import6 db 'rotate.obj - Wrong import!',0
+err_message_import7 db 'scaling.obj - Wrong import!',0
+err_message_import8 db 'proc_lib.obj - Wrong import!',0
+
+head_f_i:
+head_f_l db 'Errors of PLugins:',0
+
+;---------------------------------------------------------------------
+l_libs_start:
+library01 l_libs system_dir_Boxlib+9, path, library_path, system_dir_Boxlib, \
+err_message_found_lib1, head_f_l, Box_lib_import, err_message_import1, head_f_i, plugins_directory
+
+library02 l_libs system_dir_Libini+9, path, library_path, system_dir_Libini, \
+err_message_found_lib2, head_f_l, Libini_import, err_message_import2, head_f_i, plugins_directory
+
+library03 l_libs system_dir_Sort+9, path, library_path, system_dir_Sort, \
+err_message_found_lib3, head_f_l, Sort_import, err_message_import3, head_f_i, plugins_directory
+
+library04 l_libs system_dir_UNPACK+9, path, library_path, system_dir_UNPACK, \
+err_message_found_lib4, head_f_l, UNPACK_import, err_message_import4, head_f_i, plugins_directory
+
+library05 l_libs system_dir_Convert+9, path, library_path, system_dir_Convert, \
+err_message_found_lib5, head_f_l, Convert_import, err_message_import5, head_f_i, plugins_directory
+
+library06 l_libs system_dir_Rotate+9, path, library_path, system_dir_Rotate, \
+err_message_found_lib6, head_f_l, Rotate_import, err_message_import6, head_f_i, plugins_directory
+
+library07 l_libs system_dir_Scaling+9, path, library_path, system_dir_Scaling, \
+err_message_found_lib7, head_f_l, Scaling_import, err_message_import7, head_f_i, plugins_directory
+
+library08 l_libs system_dir_ProcLib+9, path, library_path, system_dir_ProcLib, \
+err_message_found_lib8, head_f_l, ProcLib_import, err_message_import8, head_f_i, plugins_directory
+
+end_l_libs:
+;---------------------------------------------------------------------
+align 4
+cnv_plugin_name_pointer dd plugin_0_name
+cnv_plugin_import_pointer dd Convert_plugin_0
+
+system_path db '/sys/lib/'
+.1: rb 128
+err_message_found_lib db 'Not found - '
+.1: rb 128
+err_message_import db 'Wrong import - '
+.1: rb 128
+;---------------------------------------------------------------------
+Convert_plugin_0:
+.Start dd aCP_Start
+.Version dd aCP_Version
+.Check dd aCP_Check
+.Assoc dd aCP_Assoc
+ dd 0
+ dd 0
+Convert_plugin_1:
+.Start dd aCP_Start
+.Version dd aCP_Version
+.Check dd aCP_Check
+.Assoc dd aCP_Assoc
+ dd 0
+ dd 0
+Convert_plugin_2:
+.Start dd aCP_Start
+.Version dd aCP_Version
+.Check dd aCP_Check
+.Assoc dd aCP_Assoc
+ dd 0
+ dd 0
+Convert_plugin_3:
+.Start dd aCP_Start
+.Version dd aCP_Version
+.Check dd aCP_Check
+.Assoc dd aCP_Assoc
+ dd 0
+ dd 0
+Convert_plugin_4:
+.Start dd aCP_Start
+.Version dd aCP_Version
+.Check dd aCP_Check
+.Assoc dd aCP_Assoc
+ dd 0
+ dd 0
+Convert_plugin_5:
+.Start dd aCP_Start
+.Version dd aCP_Version
+.Check dd aCP_Check
+.Assoc dd aCP_Assoc
+ dd 0
+ dd 0
+Convert_plugin_6:
+.Start dd aCP_Start
+.Version dd aCP_Version
+.Check dd aCP_Check
+.Assoc dd aCP_Assoc
+ dd 0
+ dd 0
+Convert_plugin_7:
+.Start dd aCP_Start
+.Version dd aCP_Version
+.Check dd aCP_Check
+.Assoc dd aCP_Assoc
+ dd 0
+ dd 0
+Convert_plugin_8:
+.Start dd aCP_Start
+.Version dd aCP_Version
+.Check dd aCP_Check
+.Assoc dd aCP_Assoc
+ dd 0
+ dd 0
+Convert_plugin_9:
+.Start dd aCP_Start
+.Version dd aCP_Version
+.Check dd aCP_Check
+.Assoc dd aCP_Assoc
+ dd 0
+ dd 0
+aCP_Start db 'START',0
+aCP_Version db 'version',0
+aCP_Check db 'Check_Header',0
+aCP_Assoc db 'Associations',0
+;---------------------------------------------------------------------
+
+file_mount: db 'File N: Amount: Zoom:',0
+.end:
+
+current_key_code db 0
+old_key_code db 0
+;---------------------------------------------------------------------
+; Tokens
+;---------------------------------------------------------------------
+aSortMode db 'SortMode',0
+aSlideShowDelay db 'SlideShowDelay',0
+aArrowsOffset db 'ArrowsOffset',0
+aShowFileName db 'ShowFileName',0
+aFilteringFlag db 'FilteringFlag',0
+;---------------------------------------------------------------------
+;Sections
+;---------------------------------------------------------------------
+aVariables db 'Variables',0
+;aVar db 'Var',0
+;aTemp db 'Temp',0
+;---------------------------------------------------------------------
+align 4
+ProcLib_import:
+OpenDialog_Init dd aOpenDialog_Init
+OpenDialog_Start dd aOpenDialog_Start
+;OpenDialog__Version dd aOpenDialog_Version
+ dd 0
+ dd 0
+aOpenDialog_Init db 'OpenDialog_init',0
+aOpenDialog_Start db 'OpenDialog_start',0
+;aOpenDialog_Version db 'Version_OpenDialog',0
+;---------------------------------------------------------------------
+align 4
+Scaling_import:
+Scaling_Start dd aScaling_Start
+Scaling_Version dd aScaling_Version
+ dd 0
+ dd 0
+aScaling_Start db 'START',0
+aScaling_Version db 'version',0
+;---------------------------------------------------------------------
+align 4
+Rotate_import:
+rotate_Start dd aRotate_Start
+rotate_Version dd aRotate_Version
+ dd 0
+ dd 0
+aRotate_Start db 'START',0
+aRotate_Version db 'version',0
+;---------------------------------------------------------------------
+align 4
+Convert_import:
+convert_Start dd aConvert_Start
+convert_Version dd aConvert_Version
+convert_Conv_24b dd aConvert_Conv_24b
+ dd 0
+ dd 0
+aConvert_Start db 'START',0
+aConvert_Version db 'version',0
+aConvert_Conv_24b db 'Convert24b',0
+;---------------------------------------------------------------------
+align 4
+UNPACK_import:
+;unpack_Version dd aUnpack_Version
+;unpack_PluginLoad dd aUnpack_PluginLoad
+;unpack_OpenFilePlugin dd aUnpack_OpenFilePlugin
+;unpack_ClosePlugin dd aUnpack_ClosePlugin
+;unpack_ReadFolder dd aUnpack_ReadFolder
+;unpack_SetFolder dd aUnpack_SetFolder
+;unpack_GetFiles dd aUnpack_GetFiles
+;unpack_GetOpenPluginInfo dd aUnpack_GetOpenPluginInfo
+;unpack_Getattr dd aUnpack_Getattr
+;unpack_Open dd aUnpack_Open
+;unpack_Read dd aUnpack_Read
+;unpack_Setpos dd aUnpack_Setpos
+;unpack_Close dd aUnpack_Close
+;unpack_DeflateUnpack dd aUnpack_DeflateUnpack
+unpack_DeflateUnpack2 dd aUnpack_DeflateUnpack2
+ dd 0
+ dd 0
+
+;aUnpack_Version db 'version',0
+;aUnpack_PluginLoad db 'plugin_load',0
+;aUnpack_OpenFilePlugin db 'OpenFilePlugin',0
+;aUnpack_ClosePlugin db 'ClosePlugin',0
+;aUnpack_ReadFolder db 'ReadFolder',0
+;aUnpack_SetFolder db 'SetFolder',0
+;aUnpack_GetFiles db 'GetFiles',0
+;aUnpack_GetOpenPluginInfo db 'GetOpenPluginInfo',0
+;aUnpack_Getattr db 'getattr',0
+;aUnpack_Open db 'open',0
+;aUnpack_Read db 'read',0
+;aUnpack_Setpos db 'setpos',0
+;aUnpack_Close db 'close',0
+;aUnpack_DeflateUnpack db 'deflate_unpack',0
+aUnpack_DeflateUnpack2 db 'deflate_unpack2',0
+
+;---------------------------------------------------------------------
+align 4
+Sort_import:
+sort_init dd aSort_init
+sort_version dd aSort_version
+sort_dir dd aSort_SortDir
+sort_strcmpi dd aSort_strcmpi
+ dd 0
+ dd 0
+
+aSort_init db 'START',0
+aSort_version db 'version',0
+aSort_SortDir db 'SortDir',0
+aSort_strcmpi db 'strcmpi',0
+
+;---------------------------------------------------------------------
+align 4
+Libini_import:
+lib_init dd aLib_init
+version_lib_ini dd aVersion_lib_ini
+ini_enum_sections dd aIni_enum_sections
+ini_enum_keys dd aIni_enum_keys
+ini_get_str dd aIni_get_str
+ini_get_int dd aIni_get_int
+ini_get_color dd aIni_get_color
+ini_set_str dd aIni_set_str
+ini_set_int dd aIni_set_int
+ini_set_color dd aIni_set_color
+ dd 0
+ dd 0
+
+aLib_init db 'lib_init',0
+aVersion_lib_ini db 'version',0
+aIni_enum_sections db 'ini_enum_sections',0
+aIni_enum_keys db 'ini_enum_keys',0
+aIni_get_str db 'ini_get_str',0
+aIni_get_int db 'ini_get_int',0
+aIni_get_color db 'ini_get_color',0
+aIni_set_str db 'ini_set_str',0
+aIni_set_int db 'ini_set_int',0
+aIni_set_color db 'ini_set_color',0
+
+;---------------------------------------------------------------------
+align 4
+Box_lib_import:
+;init_lib dd a_init
+;version_lib dd a_version
+
+edit_box_draw dd aEdit_box_draw
+edit_box_key dd aEdit_box_key
+edit_box_mouse dd aEdit_box_mouse
+;version_ed dd aVersion_ed
+
+check_box_draw dd aCheck_box_draw
+check_box_mouse dd aCheck_box_mouse
+;version_ch dd aVersion_ch
+
+option_box_draw dd aOption_box_draw
+option_box_mouse dd aOption_box_mouse
+;version_op dd aVersion_op
+
+scrollbar_ver_draw dd aScrollbar_ver_draw
+scrollbar_ver_mouse dd aScrollbar_ver_mouse
+scrollbar_hor_draw dd aScrollbar_hor_draw
+scrollbar_hor_mouse dd aScrollbar_hor_mouse
+;version_scrollbar dd aVersion_scrollbar
+
+dinamic_button_draw dd aDbutton_draw
+dinamic_button_mouse dd aDbutton_mouse
+;version_dbutton dd aVersion_dbutton
+
+menu_bar_draw dd aMenu_bar_draw
+menu_bar_mouse dd aMenu_bar_mouse
+menu_bar_activate dd aMenu_bar_activate
+;version_menu_bar dd aVersion_menu_bar
+
+;FileBrowser_draw dd aFileBrowser_draw
+;FileBrowser_mouse dd aFileBrowser_mouse
+;FileBrowser_key dd aFileBrowser_key
+;Version_FileBrowser dd aVersion_FileBrowser
+ dd 0
+ dd 0
+
+;a_init db 'lib_init',0
+;a_version db 'version',0
+
+aEdit_box_draw db 'edit_box',0
+aEdit_box_key db 'edit_box_key',0
+aEdit_box_mouse db 'edit_box_mouse',0
+;aVersion_ed db 'version_ed',0
+
+aCheck_box_draw db 'check_box_draw',0
+aCheck_box_mouse db 'check_box_mouse',0
+;aVersion_ch db 'version_ch',0
+
+aOption_box_draw db 'option_box_draw',0
+aOption_box_mouse db 'option_box_mouse',0
+;aVersion_op db 'version_op',0
+
+aScrollbar_ver_draw db 'scrollbar_v_draw',0
+aScrollbar_ver_mouse db 'scrollbar_v_mouse',0
+aScrollbar_hor_draw db 'scrollbar_h_draw',0
+aScrollbar_hor_mouse db 'scrollbar_h_mouse',0
+;aVersion_scrollbar db 'version_scrollbar',0
+
+aDbutton_draw db 'dbutton_draw',0
+aDbutton_mouse db 'dbutton_mouse',0
+;aVersion_dbutton db 'version_dbutton',0
+
+aMenu_bar_draw db 'menu_bar_draw',0
+aMenu_bar_mouse db 'menu_bar_mouse',0
+aMenu_bar_activate db 'menu_bar_activate',0
+;aVersion_menu_bar db 'version_menu_bar',0
+
+;aFileBrowser_draw db 'FileBrowser_draw',0
+;aFileBrowser_mouse db 'FileBrowser_mouse',0
+;aFileBrowser_key db 'FileBrowser_key',0
+;aVersion_FileBrowser db 'version_FileBrowser',0
+;---------------------------------------------------------------------
+align 4
+load_directory_pointer dd 0
+file_name_length dd 0
+load_file_number dd 0
+error_fs dd 0
+error_pointer dd 0
+;error_locate dd 0
+error_window_x: dd 100 shl 16 + 300
+error_window_y: dd 100 shl 16 + 100
+
+PID dd 0
+PID1 dd 0
+PID2 dd 0
+PID3 dd 0
+PID4 dd 0
+PID5 dd 0
+PID6 dd 0
+PID7 dd 0
+active_process dd 0
+timer_counter dd 0
+draw_scrollbar_counter dd 0
+;---------------------------------------------------------------------
+align 4
+error_fs_text_pointers:
+ dd error_fs_text_0
+ dd error_fs_text_1
+ dd error_fs_text_2
+ dd error_fs_text_3
+ dd error_fs_text_4
+ dd error_fs_text_5
+ dd error_fs_text_6
+ dd error_fs_text_7
+ dd error_fs_text_8
+ dd error_fs_text_9
+ dd error_fs_text_10
+ dd error_fs_text_11
+
+error_fs_text_0: db 'Success full',0
+error_fs_text_1: db 'Base and/or partition of a hard disk is not defined',0
+error_fs_text_2: db 'Function is not supported for the given file system',0
+error_fs_text_3: db 'Unknown file system',0
+error_fs_text_4: db 'Reserved, is never returned in the current implementation',0
+error_fs_text_5: db 'File not found',0
+error_fs_text_6: db 'End of file, EOF',0
+error_fs_text_7: db 'Pointer lies outside of application memory',0
+error_fs_text_8: db 'Disk is full',0
+error_fs_text_9: db 'FAT table is destroyed',0
+error_fs_text_10: db 'Access denied',0
+error_fs_text_11: db 'Device error',0
+;---------------------------------------------------------------------
+error_type:
+ db 'File system error',0
+;---------------------------------------------------------------------
+error_not_supported_file:
+ db 'Unsupported file or corrupt data',0
+;---------------------------------------------------------------------
+error_not_enough_memory:
+ db 'Not_enough_memory',0
+;---------------------------------------------------------------------
+error_unknown:
+ db 'Unknown error',0
+;---------------------------------------------------------------------
+extended_key db 0
+no_draw_window db 0
+
+shift_flag db 0
+ctrl_flag db 0
+alt_flag db 0
+;---------------------------------------------------------------------
+; for EDITBOX
+align 4
+name_editboxes:
+edit1 edit_box 200,10,30,0xffffff,0xbbddff,0,0,0,255,string,mouse_dd,ed_focus+ed_always_focus,0
+name_editboxes_end:
+
+;mouse_flag: dd 0x0
+
+mouse_dd rd 1
+;---------------------------------------------------------------------
+align 4
+; option_boxes_bcgr:
+op1 option_box option_group1,60,40,6,12,0xFFFFFF,0,0xffffff,op_text.1,op_text.e1-op_text.1
+op2 option_box option_group1,60,55,6,12,0xFFFFFF,0,0xffffff,op_text.2,op_text.e2-op_text.2
+option_boxes_bcgr_end:
+
+op_text:
+.1 db 'Tiled'
+.e1:
+.2 db 'Stretch'
+.e2:
+
+option_group1 dd op1
+
+option_boxes_bcgr: dd op1, op2,0
+;---------------------------------------------------------------------
+align 4
+;option_boxes_sort:
+sort0 option_box option_group2,60,40,6,12,0xFFFFFF,0,0xffffff,op_text_1.1,op_text_1.e1-op_text_1.1
+sort2 option_box option_group2,60,55,6,12,0xFFFFFF,0,0xffffff,op_text_1.2,op_text_1.e2-op_text_1.2
+sort4 option_box option_group2,60,70,6,12,0xFFFFFF,0,0xffffff,op_text_1.3,op_text_1.e3-op_text_1.3
+sort6 option_box option_group2,60,85,6,12,0xFFFFFF,0,0xffffff,op_text_1.4,op_text_1.e4-op_text_1.4
+option_boxes_sort_end:
+
+op_text_1:
+.1 db 'Name'
+.e1:
+.2 db 'Type'
+.e2:
+.3 db 'Date'
+.e3:
+.4 db 'Size'
+.e4:
+
+option_group2 dd sort2
+option_group2_old dd 0
+
+option_boxes_sort dd sort0, sort2, sort4, sort6,0
+;---------------------------------------------------------------------
+check1 check_box 120,50,6,12,0xFFFFFF,0,0xffffff,check_text1,14,0 ;ch_flag_en
+
+check_text1 db 'Show file name'
+
+show_file_name_old dd 0
+;---------------------------------------------------------------------
+check2 check_box 120,70,6,12,0xFFFFFF,0,0xffffff,check_text2,14,0 ;ch_flag_en
+
+check_text2 db 'Bilinear filtering'
+
+filtering_flag dd 0
+filtering_flag_old dd 0
+;---------------------------------------------------------------------
+align 4
+scroll_bar_data_vertical:
+.x:
+.size_x dw 15 ;+0
+.start_x dw 500 ;+2
+.y:
+.size_y dw 300 ;+4
+.start_y dw 30 ;+6
+.btn_high dd 15 ;+8
+.type dd 1 ;+12
+.max_area dd 10 ;+16
+.cur_area dd 2 ;+20
+.position dd 0 ;+24
+.bckg_col dd 0xeeeeee ;+28
+.frnt_col dd 0x8aeaa0 ;0xbbddff ;+32
+.line_col dd 0 ;+36
+.redraw dd 0 ;+40
+.delta dw 0 ;+44
+.delta2 dw 0 ;+46
+.run_x:
+.r_size_x dw 0 ;+48
+.r_start_x dw 0 ;+50
+.run_y:
+.r_size_y dw 0 ;+52
+.r_start_y dw 0 ;+54
+.m_pos dd 0 ;+56
+.m_pos_2 dd 0 ;+60
+.m_keys dd 0 ;+64
+.run_size dd 0 ;+68
+.position2 dd 0 ;+72
+.work_size dd 0 ;+76
+.all_redraw dd 0 ;+80
+.ar_offset dd 10 ;+84
+;---------------------------------------------------------------------
+align 4
+scroll_bar_data_horizontal:
+.x:
+.size_x dw 300 ;0 ;+0
+.start_x dw 10 ;0 ;+2
+.y:
+.size_y dw 15 ;0 ;+4
+.start_y dw 300 ;0 ;+6
+.btn_high dd 15 ;+8
+.type dd 1 ;+12
+.max_area dd 10 ;+16
+.cur_area dd 2 ;+20
+.position dd 0 ;+24
+.bckg_col dd 0xeeeeee ;+28
+.frnt_col dd 0x8aeaa0 ;0xbbddff ;+32
+.line_col dd 0 ;+36
+.redraw dd 0 ;+40
+.delta dw 0 ;+44
+.delta2 dw 0 ;+46
+.run_x:
+.r_size_x dw 0 ;+48
+.r_start_x dw 0 ;+50
+.run_y:
+.r_size_y dw 0 ;+52
+.r_start_y dw 0 ;+54
+.m_pos dd 0 ;+56
+.m_pos_2 dd 0 ;+60
+.m_keys dd 0 ;+64
+.run_size dd 0 ;+68
+.position2 dd 0 ;+72
+.work_size dd 0 ;+76
+.all_redraw dd 0 ;+80
+.ar_offset dd 10 ;+84
+;---------------------------------------------------------------------
+align 4
+menu_data_1:
+.type: dd 0 ;+0
+.x:
+.size_x dw 35 ;+4
+.start_x dw 5 ;+6
+.y:
+.size_y dw 15 ;+8
+.start_y dw 3 ;+10
+.text_pointer: dd menu_text_area_1 ;0 ;+12
+.pos_pointer: dd menu_text_area_1.1 ;0 ;+16
+.text_end dd menu_text_area_1.end ;0 ;+20
+.ret_key dd 0 ;+24
+.mouse_keys dd 0 ;+28
+.x1:
+.size_x1 dw 70 ;+32
+.start_x1 dw 5 ;+34
+.y1:
+.size_y1 dw 100 ;+36
+.start_y1 dw 18 ;+38
+.bckg_col dd 0xe5e5e5 ;+40
+.frnt_col dd 0xff ;+44
+.menu_col dd 0xeef0ff ;0xffffff ;+48
+.select dd 0 ;+52
+.out_select dd 0 ;+56
+.buf_adress dd 0 ;+60
+.procinfo dd 0 ;+64
+.click dd 0 ;+68
+.cursor dd 0 ;+72
+.cursor_old dd 0 ;+76
+.interval dd 16 ;+80
+.cursor_max dd 0 ;+84
+.extended_key dd 0 ;+88
+.menu_sel_col dd 0x00cc00 ;+92
+.bckg_text_col dd 0 ; +96
+.frnt_text_col dd 0xffffff ;+100
+.mouse_keys_old dd 0 ;+104
+.font_height dd 8 ;+108
+.cursor_out dd 0 ;+112
+.get_mouse_flag dd 0 ;+116
+;---------------------------------------------------------------------
+menu_text_area_1:
+db 'File',0
+.1:
+db 'Open',0
+db 'Properties',0
+db 'Exit',0
+.end:
+db 0
+;---------------------------------------------------------------------
+align 4
+menu_data_2:
+.type: dd 0 ;+0
+.x:
+.size_x dw 35 ;+4
+.start_x dw 40 ;+6
+.y:
+.size_y dw 15 ;+8
+.start_y dw 3 ;+10
+.text_pointer: dd menu_text_area_2 ;0 ;+12
+.pos_pointer: dd menu_text_area_2.1 ;0 ;+16
+.text_end dd menu_text_area_2.end ;0 ;+20
+.ret_key dd 0 ;+24
+.mouse_keys dd 0 ;+28
+.x1:
+.size_x1 dw 90 ;+32
+.start_x1 dw 40 ;+34
+.y1:
+.size_y1 dw 100 ;+36
+.start_y1 dw 18 ;+38
+.bckg_col dd 0xe5e5e5 ;+40
+.frnt_col dd 0xff ;+44
+.menu_col dd 0xeef0ff ;0xffffff ;+48
+.select dd 0 ;+52
+.out_select dd 0 ;+56
+.buf_adress dd 0 ;+60
+.procinfo dd 0 ;+64
+.click dd 0 ;+68
+.cursor dd 0 ;+72
+.cursor_old dd 0 ;+76
+.interval dd 16 ;+80
+.cursor_max dd 0 ;+84
+.extended_key dd 0 ;+88
+.menu_sel_col dd 0x00cc00 ;+92
+.bckg_text_col dd 0 ; +96
+.frnt_text_col dd 0xffffff ;+100
+.mouse_keys_old dd 0 ;+104
+.font_height dd 8 ;+108
+.cursor_out dd 0 ;+112
+.get_mouse_flag dd 0 ;+116
+;---------------------------------------------------------------------
+menu_text_area_2:
+db 'Edit',0
+.1:
+db 'Rotate Clock.',0
+db 'Rotate CClock.',0
+db 'Invert L to R',0
+db 'Invert U to D',0
+.end:
+db 0
+;---------------------------------------------------------------------
+align 4
+menu_data_3:
+.type: dd 0 ;+0
+.x:
+.size_x dw 35 ;+4
+.start_x dw 75 ;+6
+.y:
+.size_y dw 15 ;+8
+.start_y dw 3 ;+10
+.text_pointer: dd menu_text_area_3 ;0 ;+12
+.pos_pointer: dd menu_text_area_3.1 ;0 ;+16
+.text_end dd menu_text_area_3.end ;0 ;+20
+.ret_key dd 0 ;+24
+.mouse_keys dd 0 ;+28
+.x1:
+.size_x1 dw 90 ;+32
+.start_x1 dw 75 ;+34
+.y1:
+.size_y1 dw 100 ;+36
+.start_y1 dw 18 ;+38
+.bckg_col dd 0xe5e5e5 ;+40
+.frnt_col dd 0xff ;+44
+.menu_col dd 0xeef0ff ;0xffffff ;+48
+.select dd 0 ;+52
+.out_select dd 0 ;+56
+.buf_adress dd 0 ;+60
+.procinfo dd 0 ;+64
+.click dd 0 ;+68
+.cursor dd 0 ;+72
+.cursor_old dd 0 ;+76
+.interval dd 16 ;+80
+.cursor_max dd 0 ;+84
+.extended_key dd 0 ;+88
+.menu_sel_col dd 0x00cc00 ;+92
+.bckg_text_col dd 0 ; +96
+.frnt_text_col dd 0xffffff ;+100
+.mouse_keys_old dd 0 ;+104
+.font_height dd 8 ;+108
+.cursor_out dd 0 ;+112
+.get_mouse_flag dd 0 ;+116
+;---------------------------------------------------------------------
+menu_text_area_3:
+db 'View',0
+.1:
+db 'Sort Directory',0
+db 'Full Screen',0
+db 'Reload',0
+.end:
+db 0
+;---------------------------------------------------------------------
+align 4
+menu_data_4:
+.type: dd 0 ;+0
+.x:
+.size_x dw 35 ;+4
+.start_x dw 110 ;+6
+.y:
+.size_y dw 15 ;+8
+.start_y dw 3 ;+10
+.text_pointer: dd menu_text_area_4 ;0 ;+12
+.pos_pointer: dd menu_text_area_4.1 ;0 ;+16
+.text_end dd menu_text_area_4.end ;0 ;+20
+.ret_key dd 0 ;+24
+.mouse_keys dd 0 ;+28
+.x1:
+.size_x1 dw 40 ;+32
+.start_x1 dw 110 ;+34
+.y1:
+.size_y1 dw 100 ;+36
+.start_y1 dw 18 ;+38
+.bckg_col dd 0xe5e5e5 ;+40
+.frnt_col dd 0xff ;+44
+.menu_col dd 0xeef0ff ;0xffffff ;+48
+.select dd 0 ;+52
+.out_select dd 0 ;+56
+.buf_adress dd 0 ;+60
+.procinfo dd 0 ;+64
+.click dd 0 ;+68
+.cursor dd 0 ;+72
+.cursor_old dd 0 ;+76
+.interval dd 16 ;+80
+.cursor_max dd 0 ;+84
+.extended_key dd 0 ;+88
+.menu_sel_col dd 0x00cc00 ;+92
+.bckg_text_col dd 0 ; +96
+.frnt_text_col dd 0xffffff ;+100
+.mouse_keys_old dd 0 ;+104
+.font_height dd 8 ;+108
+.cursor_out dd 0 ;+112
+.get_mouse_flag dd 0 ;+116
+;---------------------------------------------------------------------
+menu_text_area_4:
+db 'Zoom',0
+.1:
+db 'Normal',0
+db 'More',0
+db 'Less',0
+db 'Auto',0
+.end:
+db 0
+;---------------------------------------------------------------------
+align 4
+menu_data_5:
+.type: dd 0 ;+0
+.x:
+.size_x dw 40 ;+4
+.start_x dw 145 ;+6
+.y:
+.size_y dw 15 ;+8
+.start_y dw 3 ;+10
+.text_pointer: dd menu_text_area_5 ;0 ;+12
+.pos_pointer: dd menu_text_area_5.1 ;0 ;+16
+.text_end dd menu_text_area_5.end ;0 ;+20
+.ret_key dd 0 ;+24
+.mouse_keys dd 0 ;+28
+.x1:
+.size_x1 dw 80 ;+32
+.start_x1 dw 145 ;+34
+.y1:
+.size_y1 dw 100 ;+36
+.start_y1 dw 18 ;+38
+.bckg_col dd 0xe5e5e5 ;+40
+.frnt_col dd 0xff ;+44
+.menu_col dd 0xeef0ff ;0xffffff ;+48
+.select dd 0 ;+52
+.out_select dd 0 ;+56
+.buf_adress dd 0 ;+60
+.procinfo dd 0 ;+64
+.click dd 0 ;+68
+.cursor dd 0 ;+72
+.cursor_old dd 0 ;+76
+.interval dd 16 ;+80
+.cursor_max dd 0 ;+84
+.extended_key dd 0 ;+88
+.menu_sel_col dd 0x00cc00 ;+92
+.bckg_text_col dd 0 ; +96
+.frnt_text_col dd 0xffffff ;+100
+.mouse_keys_old dd 0 ;+104
+.font_height dd 8 ;+108
+.cursor_out dd 0 ;+112
+.get_mouse_flag dd 0 ;+116
+;---------------------------------------------------------------------
+menu_text_area_5:
+db 'Tools',0
+.1:
+db 'Image Editor',0
+db 'Wallpaper',0
+db 'Slide Show',0
+db 'Options',0
+.end:
+db 0
+;---------------------------------------------------------------------
+align 4
+menu_data_6:
+.type: dd 0 ;+0
+.x:
+.size_x dw 35 ;+4
+.start_x dw 185 ;+6
+.y:
+.size_y dw 15 ;+8
+.start_y dw 3 ;+10
+.text_pointer: dd menu_text_area_6 ;0 ;+12
+.pos_pointer: dd menu_text_area_6.1 ;0 ;+16
+.text_end dd menu_text_area_6.end ;0 ;+20
+.ret_key dd 0 ;+24
+.mouse_keys dd 0 ;+28
+.x1:
+.size_x1 dw 50 ;+32
+.start_x1 dw 185 ;+34
+.y1:
+.size_y1 dw 100 ;+36
+.start_y1 dw 18 ;+38
+.bckg_col dd 0xe5e5e5 ;+40
+.frnt_col dd 0xff ;+44
+.menu_col dd 0xeef0ff ;0xffffff ;+48
+.select dd 0 ;+52
+.out_select dd 0 ;+56
+.buf_adress dd 0 ;+60
+.procinfo dd 0 ;+64
+.click dd 0 ;+68
+.cursor dd 0 ;+72
+.cursor_old dd 0 ;+76
+.interval dd 16 ;+80
+.cursor_max dd 0 ;+84
+.extended_key dd 0 ;+88
+.menu_sel_col dd 0x00cc00 ;+92
+.bckg_text_col dd 0 ; +96
+.frnt_text_col dd 0xffffff ;+100
+.mouse_keys_old dd 0 ;+104
+.font_height dd 8 ;+108
+.cursor_out dd 0 ;+112
+.get_mouse_flag dd 0 ;+116
+;---------------------------------------------------------------------
+menu_text_area_6:
+db 'Help',0
+.1:
+db 'Help',0
+db 'About',0
+.end:
+db 0
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_1: ; open file
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 230 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_2: ; reload file
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 255 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_3: ; left limit
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 285 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_4: ; left arrow
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 310 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_5: ; slide show
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 335 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_6: ; right arrow
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 360 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_7: ; right limit
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 385 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_8: ; zoom +
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 415 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_9: ; zoom -
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 440 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_10: ; zoom 100%
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 465 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_11: ; rotate clockwise
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 495 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_12: ; rotate counter-clockwise
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 520 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_13: ; file information
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 550 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_14: ; wallpaper
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 575 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dinamic_button_data_15: ; settings
+.type dd 0 ;+0
+.x:
+.size_x dw 20 ;+4
+.start_x dw 600 ;+6
+.y:
+.size_y dw 20 ;+8
+.start_y dw 3 ;+10
+.mouse_pos dd 0 ;+12
+.mouse_keys dd 0 ;+16
+.mouse_keys_old dd 0 ;+20
+.active_raw dd 0 ;+24
+.passive_raw dd 0 ;+28
+.click_raw dd 0 ;+32
+.resolution_raw dd 0 ;+36
+.palette_raw dd 0 ;+40
+.offset_raw dd 0 ;+44
+.select dd 0 ;+48
+.click dd 0 ;+52
+;---------------------------------------------------------------------
+align 4
+dirinfo:
+.subfunction dd 1
+.start dd 0
+.flags dd 0
+.size dd 0
+.return dd procinfo
+ db 0
+.name: dd plugin_pach
+;---------------------------------------------------------------------
+align 4
+fileinfo:
+.subfunction dd 5
+.Offset dd 0
+.Offset_1 dd 0
+.size dd 0
+.return dd process_info
+ db 0
+.name: dd string
+;---------------------------------------------------------------------
+align 4
+start_appl:
+.subfunction dd 7
+.flags dd 0
+.parameter dd library_path
+.reserved1 dd 0
+.reserved2 dd 0
+ db 0
+.name: dd Help_path
+;---------------------------------------------------------------------
+align 4
+dir_header:
+.version dd 0 ;+0
+.curn_blocks dd 0 ;+4
+.totl_blocks dd 0 ;+8
+.other rb 20
+;---------------------------------------------------------------------
+OpenDialog_data:
+.type dd 0
+.procinfo dd procinfo ;+4
+.com_area_name dd communication_area_name ;+8
+.com_area dd 0 ;+12
+.opendir_pach dd plugin_pach ;+16
+.dir_default_pach dd communication_area_default_pach ;+20
+.start_path dd library_path ;+24
+.draw_window dd draw_window ;+28
+.status dd 0 ;+32
+.openfile_pach dd string ;+36
+.filename_area dd 0 ;+40
+.filter_area dd Filter
+.x:
+.x_size dw 420 ;+48 ; Window X size
+.x_start dw 10 ;+50 ; Window X position
+.y:
+.y_size dw 320 ;+52 ; Window y size
+.y_start dw 10 ;+54 ; Window Y position
+
+communication_area_name:
+ db 'FFFFFFFF_open_dialog',0
+open_dialog_name:
+ db 'opendial',0
+communication_area_default_pach:
+ db '/rd/1',0
+;communication_area dd 0
+;---------------------------------------------------------------------
+; clear bacground thread
+clear_thread_stack:
+ dd 0
+;----------------------
+; window option
+thread_stack_7:
+ dd 0
+;----------------------
+; window error message
+thread_stack_6:
+ dd 0
+;----------------------
+; window set sort mode
+thread_stack_5:
+ dd 0
+;----------------------
+; window background
+thread_stack_4:
+ dd 0
+;----------------------
+; window about
+thread_stack_3:
+ dd 0
+;----------------------
+; file info
+thread_stack_2:
+ dd 0
+;----------------------
+; file open
+thread_stack:
+ dd 0
+;---------------------------------------------------------------------
+;size_before_open_dir:
+; dd 0
+;size_before_open_file:
+; dd 0
+;size_after_open_file:
+; dd 0
+;size_after_convert:
+; dd 0
+;size_after_convert_2:
+; dd 0
+;size_before_draw_image:
+; dd 0
+;size_after_draw_image:
+; dd 0
+;size_before_scaling:
+; dd 0
+;size_after_scaling:
+; dd 0
\ No newline at end of file
diff --git a/programs/media/zsea/dll.inc b/programs/media/zsea/dll.inc
new file mode 100644
index 0000000000..aceef7ac97
--- /dev/null
+++ b/programs/media/zsea/dll.inc
@@ -0,0 +1,144 @@
+;-----------------------------------------------------------------------------
+proc dll.Load, import_table:dword
+ mov esi,[import_table]
+.next_lib:
+ mov edx,[esi]
+ or edx,edx
+ jz .exit
+ push esi
+ mov esi,[esi+4]
+ mov edi,s_libdir.fname
+@@:
+ lodsb
+ stosb
+ or al,al
+ jnz @b
+ mcall 68,19,s_libdir
+ or eax,eax
+ jz .fail
+ stdcall dll.Link,eax,edx
+ stdcall dll.Init,[eax+4]
+ pop esi
+ add esi,8
+ jmp .next_lib
+.exit:
+ xor eax,eax
+ ret
+.fail:
+ add esp,4
+ xor eax,eax
+ inc eax
+ ret
+endp
+;-----------------------------------------------------------------------------
+proc dll.Link, exp:dword,imp:dword
+ push eax
+ mov esi,[imp]
+ test esi,esi
+ jz .done
+.next:
+ lodsd
+ test eax,eax
+ jz .done
+ stdcall dll.GetProcAddress,[exp],eax
+ or eax,eax
+ jz @f
+ mov [esi-4],eax
+ jmp .next
+@@:
+ mov dword[esp],0
+.done:
+ pop eax
+ ret
+endp
+;-----------------------------------------------------------------------------
+proc dll.Init, dllentry:dword
+ pushad
+ mov eax,mem.Alloc ;libini_alloc
+ mov ebx,mem.Free ;libini_free
+ mov ecx,mem.ReAlloc ;libini_realloc
+ mov edx,dll.Load
+ stdcall [dllentry]
+ popad
+ ret
+endp
+;-----------------------------------------------------------------------------
+proc dll.GetProcAddress, exp:dword,sz_name:dword
+ mov edx,[exp]
+ xor eax,eax
+.next:
+ or edx,edx
+ jz .end
+ cmp dword[edx],0
+ jz .end
+ stdcall strcmp,[edx],[sz_name]
+ test eax,eax
+ jz .ok
+ add edx,8
+ jmp .next
+.ok:
+ mov eax,[edx+4]
+ .end:
+ ret
+endp
+;-----------------------------------------------------------------------------
+proc strcmp, str1:dword,str2:dword
+ push esi edi
+ mov esi,[str1]
+ mov edi,[str2]
+ xor eax,eax
+@@:
+ lodsb
+ scasb
+ jne .fail
+ or al,al
+ jnz @b
+ jmp .ok
+.fail:
+ or eax,-1
+.ok:
+ pop edi esi
+ ret
+endp
+;-----------------------------------------------------------------------------
+s_libdir:
+ db '/sys/lib/'
+ .fname rb 32
+;-----------------------------------------------------------------------------
+proc mem.Alloc,size
+ push ebx ecx
+ mov ecx,[size]
+ mcall 68,12
+ pop ecx ebx
+ ret
+endp
+;-----------------------------------------------------------------------------
+proc mem.ReAlloc,mptr,size
+ push ebx ecx edx
+ mov ecx,[size]
+ or ecx,ecx
+ jz @f
+@@:
+ mov edx,[mptr]
+ or edx,edx
+ jz @f
+@@:
+ mcall 68,20
+ or eax,eax
+ jz @f
+@@:
+ pop edx ecx ebx
+ ret
+endp
+;-----------------------------------------------------------------------------
+proc mem.Free,mptr
+ push ebx ecx
+ mov ecx,[mptr]
+ or ecx,ecx
+ jz @f
+@@:
+ mcall 68,13
+ pop ecx ebx
+ ret
+endp
+;-----------------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/draw_img.inc b/programs/media/zsea/draw_img.inc
new file mode 100644
index 0000000000..4ae74a069a
--- /dev/null
+++ b/programs/media/zsea/draw_img.inc
@@ -0,0 +1,469 @@
+;;****************************************************************************
+;****************************************************************************
+; Draw output part of the image and SCROLLBAR's
+;****************************************************************************
+;****************************************************************************
+ drawimage:
+
+
+ call get_window_param
+ ;mov edx,5*65536+50
+ mov edx,0*65536+28
+ mov esi,[img_resolution] ;24
+ cmp esi,32
+ ja .exit_error ;.exit
+ mov edi,[img_palette]
+;****************************************************************************
+; Calculation of sizes of an output part of the image
+;****************************************************************************
+ xor eax,eax
+ mov [draw_SB],al
+ mov [draw_SB1],al
+ mov eax,[window_width]
+; sub eax,9
+ mov [wa_width],ax
+ mov [wa_width_1],ax
+ mov [wa_width_2],ax
+ mov ebx,[img_width]
+ test ebx,ebx
+ jz .exit_error ;.exit
+ cmp ax,bx
+ jae @f
+ sub ax,[scroll_bar_data_vertical.size_x]
+ mov [draw_SB],1
+ jmp .size_y
+@@:
+ mov ax,bx
+
+
+.size_y:
+ mov ebx,[img_high]
+ test ebx,ebx
+ jz .exit_error ;.exit
+ shl eax,16
+ add eax,[window_high]
+ cmp ax,50-22
+ jbe @f
+ sub ax,50-22
+@@:
+ mov [wa_high],ax
+ mov [wa_high_1],ax
+ mov [wa_high_2],ax
+ cmp ax,bx
+ jae @f
+ sub ax,[scroll_bar_data_horizontal.size_y]
+ mov [draw_SB1],1
+ jmp .continue
+@@:
+ mov ax,bx
+.continue:
+ mov ecx,eax
+;****************************************************************************
+;
+;****************************************************************************
+ cmp [draw_SB1],1
+ je @f
+ cmp [draw_SB],0
+ je @f
+ ror ecx,16
+ add cx,[scroll_bar_data_vertical.size_x]
+ rol ecx,16
+@@:
+ cmp [draw_SB],1
+ je @f
+ cmp [draw_SB1],0
+ je @f
+ add cx,[scroll_bar_data_horizontal.size_y]
+@@:
+; call check_8bit_less
+;.continue_1:
+;****************************************************************************
+; Prepare of data for SCROLLBAR's
+;****************************************************************************
+ call correct_cur_area
+
+ mov eax,[img_width]
+ push edx
+ imul eax,[scaling_mode]
+ mov ebx,100
+ xor edx,edx
+ div ebx
+ mov [scroll_bar_data_horizontal.max_area],eax
+ pop edx
+
+
+ mov ebx,[img_high]
+ push eax edx
+ mov eax,ebx
+ imul eax,[scaling_mode]
+ mov ebx,100
+ xor edx,edx
+ div ebx
+ mov ebx,eax
+ pop edx eax
+ mov [scroll_bar_data_vertical.max_area],ebx
+
+; cmp [scaling_mode],100
+; jne .continue_1
+
+ call correct_width
+ call correct_cur_area
+
+ cmp [correct_w],0
+ je @f
+
+ call correct_high
+ call correct_cur_area
+ jmp .continue_1
+
+@@:
+ call correct_high
+ call correct_cur_area
+
+ cmp [correct_h],0
+ je @f
+
+ call correct_width
+ call correct_cur_area
+@@:
+
+; call check_8bit_less
+
+.continue_1:
+; mov eax,[window_high]
+; sub eax,55
+; ror eax,16
+; mov ax,dx
+; rol eax,16
+ mov eax,edx
+ shl eax,16
+ mov ax,cx
+ mov [scroll_bar_data_vertical.y],eax
+
+; mov eax,[window_width]
+; sub eax,10
+; ror eax,16
+; ror edx,16
+; mov ax,dx
+; rol edx,16
+; rol eax,16
+ mov eax,edx
+ mov ebx,ecx
+ shr ebx,16
+ mov ax,bx
+ mov [scroll_bar_data_horizontal.x],eax
+
+
+; mov eax,edx
+; mov ebx,ecx
+; shr ebx,16
+; shr eax,16
+; add ax,bx
+ mov eax,[window_width]
+ sub ax,[scroll_bar_data_vertical.size_x]
+; sub ax,4
+ mov [scroll_bar_data_vertical.start_x],ax
+
+; mov eax,edx
+; add ax,cx
+ mov eax,[window_high]
+ sub ax,[scroll_bar_data_horizontal.size_y]
+; sub ax,4
+ mov [scroll_bar_data_horizontal.start_y],ax
+
+;****************************************************************************
+; Check necessity prepare of data
+;****************************************************************************
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ mov ebx,[scroll_bar_data_vertical.max_area]
+ cmp ebx,[scroll_bar_data_vertical.cur_area]
+ ja @f
+ cmp eax,[scroll_bar_data_horizontal.cur_area]
+ ja @f
+
+ mov ebp,0
+ mov ebx,[soi]
+ jmp .end
+@@:
+;****************************************************************************
+; Calculate offset of next row data relative to previous row data
+;****************************************************************************
+ mov ebp,eax
+ mov ebx,ecx
+ shr ebx,16
+ sub ebp,ebx
+ imul ebp,esi
+ mov eax,ebp
+ shr ebp,3
+;****************************************************************************
+; Vertical SCROLLBAR
+; At a case of resizing of the window
+; Check the position of a runner has crossed a limit
+;****************************************************************************
+ mov eax,[scroll_bar_data_vertical.max_area]
+ sub eax,[scroll_bar_data_vertical.cur_area]
+ cmp eax,[scroll_bar_data_vertical.position]
+ jae @f
+ mov [scroll_bar_data_vertical.position],eax
+@@:
+;****************************************************************************
+; Horizontal SCROLLBAR
+; At a case of resizing of the window
+; Check the position of a runner has crossed a limit
+;****************************************************************************
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ sub eax,[scroll_bar_data_horizontal.cur_area]
+ cmp eax,[scroll_bar_data_horizontal.position]
+ jae @f
+ mov [scroll_bar_data_horizontal.position],eax
+@@:
+;****************************************************************************
+; Calculate offset from a beginning of a image
+;****************************************************************************
+ mov ebx,[scroll_bar_data_horizontal.max_area]
+ imul ebx,esi
+ mov eax,ebx
+ shr ebx,3
+ imul ebx,[scroll_bar_data_vertical.position]
+ mov eax,[scroll_bar_data_horizontal.position]
+ imul eax,esi
+ shr eax,3
+ add ebx,eax
+ add ebx,[soi]
+.end:
+ cmp [soi],0
+ je .exit_error ;.exit
+;****************************************************************************
+; Draw image
+;****************************************************************************
+ cmp [img_resolution_2],15
+ jne @f
+ mov esi,15
+@@:
+ mov [image_start_coordinates],edx
+ mov [image_draw_size],ecx
+ cmp [scaling_mode],dword 100
+ je .100
+ cmp [scaling_mode],dword 0
+ jne @f
+ call scaling.1
+ ret
+@@:
+ mov [correct_scrollbar_100_flag],0
+ call zoom_all
+ ret
+.100:
+ mov al,[correct_scrollbar_100_flag]
+ test al,al
+ jnz @r
+;******************************
+ mov eax,wa_width_1
+ mov eax,[eax]
+ push eax
+ mov eax,wa_high_1
+ mov eax,[eax]
+ push eax
+;******************************
+ rol ecx,16
+ mov eax,[scroll_bar_data_vertical.max_area]
+ cmp eax,[scroll_bar_data_vertical.cur_area]
+ mov ax,[wa_width_1]
+ jbe @f
+ sub ax,[scroll_bar_data_vertical.size_x]
+ mov [wa_width_1],ax
+@@:
+ sub ax,cx
+ mov [wa_width_2],cx
+ ror ecx,16
+ shr ax,1
+ shl eax,16
+ add edx,eax
+ shr eax,16
+ test eax,eax
+ jz @f
+ call scaling.fill_for_L_R
+@@:
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ cmp eax,[scroll_bar_data_horizontal.cur_area]
+ mov ax,[wa_high_1]
+ jbe @f
+ sub ax,[scroll_bar_data_horizontal.size_y]
+ mov [wa_high_1],ax
+@@:
+ sub ax,cx
+ mov [wa_high_2],cx
+ shr ax,1
+ add edx,eax
+ test eax,eax
+ jz @f
+ call scaling.fill_for_U_D
+@@:
+;******************************
+ mcall 65, ;[soi]
+;******************************
+ pop eax
+ mov ebx,wa_high_1
+ mov [ebx],eax
+
+ pop eax
+ mov ebx,wa_width_1
+ mov [ebx],eax
+;******************************
+.exit:
+ call draw_file_name_to_work_area
+ ret
+
+.exit_error:
+ xor eax,eax
+ mov [scroll_bar_data_vertical.cur_area],eax
+ mov [scroll_bar_data_horizontal.cur_area],eax
+ ret
+;****************************************************************************
+draw_file_name_to_work_area:
+ mov eax,[check1+32]
+ test eax,10b
+ jz @f
+ mov ebx,[file_name_length]
+ mov eax,ebx
+ lea ebx,[ebx*5]
+ add ebx,eax
+ add ebx,13 shl 16
+ mcall 13,,<59,11>,0xe5e5e5
+ mcall 4,<16,60>,0x80000000,file_name,,0xe5e5e5
+@@:
+ ret
+;****************************************************************************
+;check_8bit_less:
+; cmp esi,8
+; jae .no_8bit_less
+; mov eax,ecx
+; ror eax,16
+;; mov ebx,eax
+; xor ecx,ecx
+;
+; inc ecx
+; shr ax,1
+;
+; cmp esi,4
+; je @f
+;
+; inc ecx
+; shr ax,1
+;
+; cmp esi,2
+; je @f
+;
+; inc ecx
+; shr ax,1
+;@@:
+;; test ebx,ecx
+;; jz @f
+;; inc eax
+;;@@:
+; shl ax,cl
+; rol eax,16
+; mov ecx,eax
+;.no_8bit_less:
+; ret
+;****************************************************************************
+correct_width:
+ mov [correct_w],0
+ mov ebx,[scroll_bar_data_vertical.max_area]
+ cmp ebx,[scroll_bar_data_vertical.cur_area]
+ jbe @f
+ mov eax,ecx
+ shr eax,16
+ push eax
+ mov ax,[scroll_bar_data_vertical.size_x]
+ sub [wa_width],ax
+ pop eax
+ cmp [wa_width],ax
+ jae @f
+ ror ecx,16
+ mov cx,[wa_width]
+ rol ecx,16
+ mov [correct_w],1
+@@:
+ ret
+;****************************************************************************
+correct_high:
+ mov [correct_h],0
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ cmp eax,[scroll_bar_data_horizontal.cur_area]
+ jbe @f
+ push eax
+ mov ax,[scroll_bar_data_horizontal.size_y]
+ sub [wa_high],ax
+ pop eax
+ cmp [wa_high],cx
+ jae @f
+ mov cx,[wa_high]
+ mov [correct_h],1
+@@:
+ ret
+;****************************************************************************
+correct_cur_area:
+ mov eax,ecx
+ xor ebx,ebx
+ mov bx,ax
+ mov [scroll_bar_data_vertical.cur_area],ebx
+ shr eax,16
+ mov [scroll_bar_data_horizontal.cur_area],eax
+ ret
+;****************************************************************************
+; Check draw vertical scrollbar
+;****************************************************************************
+draw_scrollbars:
+ xor eax,eax
+ mov [draw_scrollbar_counter],eax
+ mov eax,[scroll_bar_data_vertical.max_area]
+ cmp eax,[scroll_bar_data_vertical.cur_area]
+ jbe @f
+ cmp [scroll_bar_data_vertical.cur_area],0
+ je @f
+ push dword scroll_bar_data_vertical
+ call [scrollbar_ver_draw]
+; draw_scroll_bar_vertical scroll_bar_data_vertical
+ inc [draw_scrollbar_counter]
+@@:
+;****************************************************************************
+; Check draw horizontal scrollbar
+;****************************************************************************
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ cmp eax,[scroll_bar_data_horizontal.cur_area]
+ jbe @f
+ cmp [scroll_bar_data_horizontal.cur_area],0
+ je @f
+ push dword scroll_bar_data_horizontal
+ call [scrollbar_hor_draw]
+; draw_scroll_bar_horizontal scroll_bar_data_horizontal
+ inc [draw_scrollbar_counter]
+@@:
+; nodrawimage:
+ cmp [draw_scrollbar_counter],2
+ jne @f
+ mov ebx,[scroll_bar_data_vertical.x]
+ mov ecx,[scroll_bar_data_horizontal.y]
+ mcall 13, , ,0xffffff
+@@:
+ ret
+;****************************************************************************
+;debug_1:
+; pushad
+; mov eax,ecx
+; shr eax,16
+; mov ebx,ecx
+; shl ebx,16
+; shr ebx,16
+; mov eax,[image_file]
+; mov ebx,edi
+; mov [temp_eax],eax
+; mov [temp_ebx],ebx
+; mcall 13,<90,500>,<2,20>,0
+; mcall 47,0xa0000,[temp_eax],<100, 5>,0xffffff
+; mcall 47,0xa0000,[temp_ebx],<300, 5>,0xffffff
+; popad
+; ret
+;temp_eax dd 0
+;temp_ebx dd 0
+;****************************************************************************
\ No newline at end of file
diff --git a/programs/media/zsea/draw_win.inc b/programs/media/zsea/draw_win.inc
new file mode 100644
index 0000000000..d95d6ea2fb
--- /dev/null
+++ b/programs/media/zsea/draw_win.inc
@@ -0,0 +1,248 @@
+
+; *********************************************
+; ******* WINDOW DEFINITIONS AND DRAW ********
+; *********************************************
+
+
+draw_window:
+
+ or [bWasDraw],1
+
+ mcall 12,1
+
+ ; DRAW WINDOW
+ xor eax,eax ; function 0 : define and draw window
+; mov ebx,350 ; [x start] *65536 + [x size]
+; mov ecx,400 ; [y start] *65536 + [y size]
+ mov ebx,0*65536+0
+ mov ecx,0*65536+0
+ add ebx,[wnd_width]
+ add ecx,[wnd_height]
+ cmp cx,55
+ ja @f
+ mov cx,55
+@@:
+ mov edx,0x63ffffff ; color of work area RRGGBB,8->color gl
+; pusha
+ xor esi,esi
+ mcall
+; popa
+; imul ecx,[load_file_number],304
+; add ecx,32+40
+; add ecx,[load_directory_pointer]
+ mov ecx,Authors_text.1 ; communication_area_name
+; mov ecx,[communication_area]
+; add ecx,4
+; mov ecx,string
+ mcall 71,1, ;labelt ; plugin_pach ;file_name ;plugin_pach ;plugin_pach
+
+ call get_window_param
+
+ call draw_other
+
+
+ push dword menu_data_1
+ call [menu_bar_draw]
+ push dword menu_data_2
+ call [menu_bar_draw]
+ push dword menu_data_3
+ call [menu_bar_draw]
+ push dword menu_data_4
+ call [menu_bar_draw]
+ push dword menu_data_5
+ call [menu_bar_draw]
+ push dword menu_data_6
+ call [menu_bar_draw]
+
+; draw_menu_bar menu_data_1
+; draw_menu_bar menu_data_2
+; draw_menu_bar menu_data_3
+; draw_menu_bar menu_data_4
+; draw_menu_bar menu_data_5
+; draw_menu_bar menu_data_6
+
+ push dword dinamic_button_data_1
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_2
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_3
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_4
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_5
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_6
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_7
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_8
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_9
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_10
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_11
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_12
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_13
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_14
+ call [dinamic_button_draw]
+ push dword dinamic_button_data_15
+ call [dinamic_button_draw]
+
+; draw_dinamic_button dinamic_button_data_1 ; open file
+; draw_dinamic_button dinamic_button_data_2 ; reload file
+; draw_dinamic_button dinamic_button_data_3 ; left limit
+; draw_dinamic_button dinamic_button_data_4 ; left arrow
+; draw_dinamic_button dinamic_button_data_5 ; slide show
+; draw_dinamic_button dinamic_button_data_6 ; right arrow
+; draw_dinamic_button dinamic_button_data_7 ; right limit
+; draw_dinamic_button dinamic_button_data_8 ; zoom +
+; draw_dinamic_button dinamic_button_data_9 ; zoom -
+; draw_dinamic_button dinamic_button_data_10 ; zoom 100%
+; draw_dinamic_button dinamic_button_data_11 ; rotate clockwise
+; draw_dinamic_button dinamic_button_data_12 ; rotate counter-clockwise
+; draw_dinamic_button dinamic_button_data_13 ; file information
+; draw_dinamic_button dinamic_button_data_14 ; wallpaper
+; draw_dinamic_button dinamic_button_data_15 ; settings
+
+ mcall 13,<225,2>,<3,22>,0
+ mcall ,<280,2>
+ mcall ,<410,2>
+ mcall ,<490,2>
+ mcall ,<545,2>
+ mcall ,<625,2>
+ mcall ,<720,2>
+ ; WINDOW LABEL
+
+; mov esi, file_mount - file_mount_end
+ mcall 4,<630,3>,0x80000000, file_mount ;, file_mount - file_mount.end
+; cmp [soi],0
+; je @f
+
+ mcall 13,<677,40>,<13,11>,0xe5e5e5
+
+ mov ecx,[load_directory_pointer]
+ mov ecx,[ecx+4]
+ mcall 47,0x80060000, ,<679, 15>,0
+
+ mcall 8,[dinamic_button_data_5.x],[dinamic_button_data_5.y],0x40000002
+;@@:
+ mcall 12,2
+
+ ret
+;---------------------------------------------------------------------
+set_draw_scrollbar_all:
+ xor eax,eax
+ inc eax
+ mov [scroll_bar_data_vertical.all_redraw],eax
+ mov [scroll_bar_data_horizontal.all_redraw],eax
+ ret
+;---------------------------------------------------------------------
+set_nodraw_scrollbar_all:
+ xor eax,eax
+ mov [scroll_bar_data_vertical.all_redraw],eax
+ mov [scroll_bar_data_horizontal.all_redraw],eax
+ ret
+;---------------------------------------------------------------------
+draw_other:
+ call drawimage
+@@:
+ mov ebx,0 ;5
+ shl ebx,16
+ add ebx,[window_width]
+; sub ebx,9
+; push ebx
+ xor ecx,ecx
+; mov ecx,[skin_high]
+ shl ecx,16
+ add ecx,50-22
+; sub ecx,[skin_high]
+ mov edx,0xffffff
+ cmp [no_draw_window],0
+ jne @f
+ mcall 13 ; fill top area
+@@:
+ mov eax,[soi]
+ test eax,eax
+ jnz @f
+ mov ecx,[window_high]
+ sub ecx,28 ;50+4
+ add ecx,(50-22) shl 16
+ mcall 13
+@@:
+
+ call draw_number_of_file
+
+ call draw_zoom_factors
+
+ cmp [scaling_mode],dword 0
+ jne @f
+; pop ebx
+ ret
+@@:
+; mov ecx,[scroll_bar_data_vertical.cur_area]
+; mov ebx,[scroll_bar_data_horizontal.cur_area]
+; push ecx
+; add ebx,5
+; mov ax,bx
+; shl ebx,16
+; add ebx,[window_width]
+; sub ebx,4
+; sub bx,ax
+; cmp bx,0
+; jbe @f
+; add ecx,50 shl 16
+; mcall 13, , ,0xffffff
+;
+;@@:
+; pop ecx
+; pop ebx
+
+; add ecx,50
+; mov ax,cx
+; shl ecx,16
+; add ecx,[window_high]
+; sub cx,ax
+; sub ecx,4
+; cmp cx,0
+; jbe @f
+; mcall 13, , ,0xffffff
+
+;@@:
+ call set_draw_scrollbar_all
+ call draw_scrollbars
+ call set_nodraw_scrollbar_all
+
+ ret
+;---------------------------------------------------------------------
+draw_number_of_file:
+
+ mcall 13,<630,42>,<13,11>,0xe5e5e5
+
+ xor ecx,ecx
+ mov eax,[load_directory_pointer]
+ cmp [eax+4],dword 0
+ je @f
+ mov ecx,[load_file_number]
+ inc ecx
+@@:
+ mcall 47,0x80060000, ,<632, 15>,0
+ ret
+;---------------------------------------------------------------------
+draw_zoom_factors:
+ mcall 13,<725,30>,<13,11>,0xe5e5e5
+
+ mov ecx,[zoom_factors]
+ mov ecx,[ecx]
+ mov [scaling_mode],ecx
+ test ecx,ecx
+ jnz @f
+ mcall 4,<727,14>,0x80000000, zoom_auto_text
+ ret
+@@:
+ mcall 47,0x80060000, ,<727, 15>,0
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/full_win.inc b/programs/media/zsea/full_win.inc
new file mode 100644
index 0000000000..7eb32fa175
--- /dev/null
+++ b/programs/media/zsea/full_win.inc
@@ -0,0 +1,446 @@
+;---------------------------------------------------------------------
+full_screen:
+ xor eax,eax
+ mov [Repeat_N],eax
+
+ xor eax,eax
+ mov [press_Enter_flag],al
+
+ mov eax,[zoom_factors]
+ mov [zoom_factors_old],eax
+
+ mov eax,[scaling_mode]
+ mov [scaling_mode_old],eax
+
+ call get_window_param_1
+ mov eax,[window_start_x]
+ mov [window_start_x_old],eax
+ mov eax,[window_start_y]
+ mov [window_start_y_old],eax
+ mov eax,[window_high]
+ mov [window_high_old],eax
+ mov eax,[window_width]
+ mov [window_width_old],eax
+;----------------------------------------
+; get current work area
+ mcall 48,5
+ mov [work_area_LR_old],eax
+ mov [work_area_TB_old],ebx
+;----------------------------------------
+ mov eax,[soi]
+ test eax,eax
+ jz still
+ mov eax,scaling_mode
+ xor ebx,ebx
+ mov [eax],ebx ;dword 0
+ mov [zoom_factors],dword zoom_factors.1
+
+ mcall 14
+ xor ebx,ebx
+ xor ecx,ecx
+ mov edx,eax
+ shr edx,16
+ xor esi,esi
+ mov si,ax
+ inc ax
+ mov [wa_high_1],ax
+ mov [wa_high_2],ax
+ shr eax,16
+ inc ax
+ mov [wa_width_1],ax
+ mov [wa_width_2],ax
+ mcall 67
+;----------------------------------------
+; set max work area
+ mov ecx,edx
+ mov dx,si
+ mcall 48,6
+;----------------------------------------
+ mov eax,[fill_color]
+ mov [fill_color_old],eax
+ xor eax,eax
+ mov [fill_color],eax
+
+ jmp .still
+;----------------------------------------
+.red:
+ call .draw_window
+.still:
+ cmp [RAW1_flag],1
+ je .animation_handler
+ mcall 10
+ cmp eax,1 ; ?
+ je .red ; - red
+ cmp eax,2 ; ?
+ je .key ; - key
+ cmp eax,3 ; ?
+ je .button ; - button
+ jmp .still ; -
+;----------------------------------------
+.animation_handler:
+ mcall 23,1
+; pusha
+; mcall 26,9
+; cmp [Animation_timer],eax
+; ja @f
+; call animation_handler.draw_image
+;@@:
+; popa
+ cmp eax,1 ; ?
+ je .red ; - red
+ cmp eax,2 ; ?
+ je .key ; - key
+ cmp eax,3 ; ?
+ je .button ; - button
+ mcall 26,9
+ cmp [Animation_timer],eax
+ ja .animation_handler
+
+ mov al,[Disposal_Method]
+ cmp al,2
+ jne @f
+ call restore_background
+ jmp .first_frame
+@@:
+ cmp al,3
+ jne @f
+ call restore_previous_frame
+@@:
+.first_frame:
+
+ call copy_next_frame
+ mov [no_fill],1
+ call .draw_image
+ mov [no_fill],0
+; call animation_handler.draw_image
+ jmp .still
+;----------------------------------------
+.key:
+ mcall 2
+ cmp [extended_key],1
+ je .extended_key
+ test al, al
+ jnz .still
+ cmp ah, 0xE0
+ jne @f
+ mov [extended_key],1
+ jmp .still
+@@:
+ cmp ah,1 ; Esc
+ je .restore_main_window
+ cmp ah,156 ; Enter
+ je .restore_main_window_1
+ jmp .still
+;----------------------------------------
+.extended_key:
+ mov [extended_key],0
+ mov [current_key_code],ah
+ cmp ah,73
+ je move_to_left_1
+ cmp ah,81
+ je move_to_right_1
+ cmp ah,71
+ je left_limit_1
+ cmp ah,79
+ je right_limit_1
+
+ cmp ah,156 ; Enter
+ je .restore_main_window_1
+
+ cmp ah,183 ; Print Screen - Slides Show
+ je slide_show_1.3
+ jmp .still
+;----------------------------------------
+.button:
+ mcall 17
+ cmp ah,1 ; button id=1 ?
+; je START.exit
+; jmp .still ;red_1
+ jne .still
+.exit:
+ call restore_work_area
+ jmp START.exit
+;---------------------------------------------------------------------
+.restore_main_window_1:
+ cmp [press_Enter_flag],1
+ je .restore_main_window
+ inc [press_Enter_flag]
+ jmp .still
+;---------------------------------------------------------------------
+.restore_main_window:
+ call restore_work_area
+
+ mov eax,[zoom_factors_old]
+ mov [zoom_factors],eax
+
+ mov eax,[scaling_mode_old]
+ mov [scaling_mode],eax
+
+ mov ebx,[window_start_x_old]
+ mov ecx,[window_start_y_old]
+ mov edx,[window_width_old]
+ mov esi,[window_high_old]
+ mcall 67
+
+; call get_window_param
+ mov eax,[fill_color_old]
+ mov [fill_color],eax
+
+ xor eax,eax
+ mov [Repeat_N],eax
+
+; mcall 15,3
+
+ mov [redraw_wallpaper_flag],1
+ jmp still ;red_1
+;---------------------------------------------------------------------
+.draw_window:
+ mcall 12,1
+ mcall 0,<0,800>,<0,600>,0x41000000,0,0
+; call get_window_param_1
+; mcall 8,0,0,1,0
+ call .draw_image
+ mcall 12,2
+ ret
+;---------------------------------------------------------------------
+.draw_image:
+ mcall 14
+ inc ax
+ mov [wa_high_1],ax
+ mov [wa_high_2],ax
+ shr eax,16
+ inc ax
+ mov [wa_width_1],ax
+ mov [wa_width_2],ax
+ mov [image_start_coordinates],0
+ mov [background_color],0
+ call scaling.1
+ mov [background_color],0xffffff
+ ret
+;---------------------------------------------------------------------
+get_window_param_1:
+ mcall 9, procinfo, -1
+ mov eax,[ebx+34]
+ mov [window_start_x],eax
+ mov eax,[ebx+38]
+ mov [window_start_y],eax
+ mov eax,[ebx+46]
+ mov [window_high],eax
+ mov eax,[ebx+42]
+ mov [window_width],eax
+ mov eax,[ebx+70]
+ mov [window_status],eax
+ ret
+;----------------------------------------
+restore_work_area:
+; restore old work area
+ mov ecx,[work_area_LR_old]
+ mov edx,[work_area_TB_old]
+ mcall 48,6
+ ret
+;---------------------------------------------------------------------
+move_to_left_1:
+ xor eax,eax
+ cmp [load_file_number],eax
+ je full_screen.still
+ dec [load_file_number]
+ jmp right_limit_1.2
+;----------------------------------------
+move_to_right_1:
+ mov eax,[load_directory_pointer]
+ mov eax,[eax+4]
+ test eax,eax
+ jz @f
+ dec eax
+@@:
+ cmp [load_file_number],eax
+ je full_screen.still
+ inc [load_file_number]
+ jmp right_limit_1.2
+;----------------------------------------
+left_limit_1:
+ xor eax,eax
+ jmp right_limit_1.1
+;----------------------------------------
+right_limit_1:
+ mov eax,[load_directory_pointer]
+ mov eax,[eax+4]
+ test eax,eax
+ jz @f
+ dec eax
+@@:
+.1:
+ cmp [load_file_number],eax
+ je full_screen.still
+ mov [load_file_number],eax
+.2:
+ imul ebx,[load_file_number],304
+ add ebx,32+40
+ add ebx,[load_directory_pointer]
+
+ mov esi,string
+ mov edi,plugin_pach
+ call copy_file_path
+
+ mov esi,plugin_pach
+ mov edi,string
+ mov ecx,4096/4
+ cld
+ rep movsd
+
+; jmp kopen
+ mov [open_file_flag],0
+ mov ecx,-1
+ call getappinfo
+ call load_image
+ test eax,eax
+ jnz kopen_1.err
+
+ call convert
+
+ call load_directory.copy_dir_path
+
+; call get_window_param
+; test [window_status],1b
+; jz @f ;draw_still
+; mov [no_draw_window],1
+;*** call draw_other
+; mov [no_draw_window],0
+; jmp .3
+;
+;@@:
+; call .draw_window
+ call full_screen.draw_image
+.3:
+ mov al,[old_key_code]
+ mov ah,[current_key_code]
+ mov [old_key_code],ah
+ cmp al,ah
+ jne full_screen.still ;key.extended_key ;still
+.still:
+ mcall 2
+ cmp [extended_key],1
+ je .extended_key
+ test al, al
+ jnz full_screen.still
+ cmp ah, 0xE0
+ jne @f
+ mov [extended_key],1
+ jmp .still
+@@:
+ jmp full_screen.still
+.extended_key:
+ mov [extended_key],0
+ mov [current_key_code],ah
+ jmp .3
+.4:
+ mov ah,[current_key_code]
+ mov [old_key_code],ah
+ jmp full_screen.extended_key ;key.extended_key
+;---------------------------------------------------------------------
+slide_show_1:
+ mov eax,[load_directory_pointer]
+ cmp [eax+4],dword 1
+ jbe full_screen.still
+ mcall 26,9
+ cmp [timer],eax
+ jbe .1
+ jmp .still
+.red:
+ call full_screen.draw_window
+.still:
+ mcall 23,10
+ cmp eax,1
+ je .red
+ cmp eax,2
+ je .key
+ cmp eax,3
+ je .button
+; mcall 68,1
+ jmp slide_show_1
+;-------------------------------------------
+.key:
+ mcall 2
+ cmp [extended_key],1
+ je .extended_key
+ test al, al
+ jnz .still
+ cmp ah, 0xE0
+ jne @f
+ mov [extended_key],1
+ jmp .still
+@@:
+ cmp ah,1 ; Esc
+ je full_screen.still
+ cmp ah,185 ; Space
+ je full_screen.still
+ jmp .still
+.extended_key:
+ mov [extended_key],0
+ mov [current_key_code],ah
+ jmp .still
+;-------------------------------------------
+.button: ; button
+ mov eax,17 ; get id
+ mcall
+ cmp ah,1 ; button id=1 ?
+ je full_screen.exit ;START.exit
+.noclose:
+ cmp ah,2
+ je full_screen.still
+ jmp slide_show_1
+;-------------------------------------------
+.1:
+; mcall 26,9
+; add eax,[slide_show_delay] ;500
+; mov [timer],eax
+
+ mov eax,[load_directory_pointer]
+ mov eax,[eax+4]
+ test eax,eax
+ jz @f
+ dec eax
+@@:
+ cmp [load_file_number],eax
+ je full_screen.still
+ inc [load_file_number]
+ imul ebx,[load_file_number],304
+ add ebx,32+40
+ add ebx,[load_directory_pointer]
+
+ mov esi,string
+ mov edi,plugin_pach
+ call copy_file_path
+
+ mov esi,plugin_pach
+ mov edi,string
+ mov ecx,4096/4
+ cld
+ rep movsd
+ mov [open_file_flag],0
+ mov ecx,-1
+ call getappinfo
+ call load_image
+
+ test eax,eax
+ jnz kopen_1.err
+
+ call convert
+; call get_window_param
+; test [window_status],1b
+; jz @f ;draw_still
+; mov [no_draw_window],1
+; call draw_other
+; mov [no_draw_window],0
+; jmp slide_show_1 ;.3
+;@@:
+; call draw_window
+ call load_directory.copy_dir_path
+ call full_screen.draw_image
+; jmp slide_show_1
+.3:
+ mcall 26,9
+ add eax,[slide_show_delay] ;500
+ mov [timer],eax
+ jmp slide_show_1
+;---------------------------------------------------------------------
diff --git a/programs/media/zsea/key.inc b/programs/media/zsea/key.inc
new file mode 100644
index 0000000000..66570d97c4
--- /dev/null
+++ b/programs/media/zsea/key.inc
@@ -0,0 +1,427 @@
+;---------------------------------------------------------------------
+ key: ; key
+ mcall 2
+ cmp [extended_key],1
+ je .extended_key
+ test al, al
+ jnz still
+ cmp ah, 0xE0
+ jne @f
+ mov [extended_key],1
+ jmp still
+@@:
+ cmp ah,151 ; i - file information
+ je kinfo
+ cmp ah,152 ; o - application options
+ je check_key_O ;k_option
+ cmp ah,159 ; s - sort mode
+ je k_sort_directory
+ cmp ah,145 ; w - wallpaper
+ je k_background
+ cmp ah,183 ; * - scaling to window
+ je scaling
+ cmp ah,139 ; 0 - scaling to window
+ je scaling
+ cmp ah,202 ; "-" - zoom minus
+ je zoom_minus
+ cmp ah,140 ; "-" - zoom minus
+ je zoom_minus
+ cmp ah,206 ; "+" - zoom plus
+ je zoom_plus
+ cmp ah,141 ; "+" - zoom plus
+ je zoom_plus
+ cmp ah,171 ; "\" - zoom 100%
+ je no_scaling
+
+ cmp ah,72 ; up arrow
+ je key_up_arrow
+ cmp ah,80 ; down arrow
+ je key_down_arrow
+ cmp ah,75 ; left arrow
+ je key_left_arrow
+ cmp ah,77 ; right arrow
+ je key_right_arrow
+
+ cmp ah,28 ; Enter
+ je full_screen
+ cmp ah,187 ; F1
+ je select_menu ;key_alt_down
+
+ cmp ah,42
+ je key_shift_up
+ cmp ah,54
+ je key_shift_up
+ cmp ah,170
+ je key_shift_down
+ cmp ah,182
+ je key_shift_down
+ cmp ah,29
+ je key_ctrl_up
+ cmp ah,157
+ je key_ctrl_down
+ cmp ah,56
+ je key_alt_up
+ cmp ah,184
+ je key_alt_down
+
+ jmp still
+.extended_key:
+ mov [extended_key],0
+ mov [current_key_code],ah
+; push eax
+; mcall 26,9
+; mov [timer_counter],eax
+; pop eax
+
+; mov al,ah
+; cmp al,130 ; 1
+; je kfile
+; cmp al,131 ; 2
+; je kopen
+; cmp al,132 ; 3
+; je kinfo
+; cmp al,133 ; 4
+; je kbgrd
+ cmp ah,73
+ je move_to_left
+ cmp ah,81
+ je move_to_right
+ cmp ah,71
+ je left_limit
+ cmp ah,79
+ je right_limit
+ cmp ah,181 ; / - zoom 100%
+ je no_scaling
+
+ cmp ah,72 ; up arrow
+ je key_up_arrow
+ cmp ah,80 ; down arrow
+ je key_down_arrow
+ cmp ah,75 ; left arrow
+ je key_left_arrow
+ cmp ah,77 ; right arrow
+ je key_right_arrow
+
+ cmp ah,28 ; Enter
+ je full_screen
+
+ cmp ah,183 ; Print Screen - Slides Show
+ je slide_show.3
+
+ cmp ah,29
+ je key_ctrl_up
+ cmp ah,157
+ je key_ctrl_down
+ cmp ah,56
+ je key_alt_up
+ cmp ah,184
+ je key_alt_down
+ jmp still
+;---------------------------------------------------------------------
+key_shift_up:
+ mov [shift_flag],1
+ jmp still
+;---------------------------------------------------------------------
+key_shift_down:
+ mov [shift_flag],0
+ jmp still
+;---------------------------------------------------------------------
+key_ctrl_up:
+ mov [ctrl_flag],1
+ jmp still
+;---------------------------------------------------------------------
+key_ctrl_down:
+ mov [ctrl_flag],0
+ jmp still
+;---------------------------------------------------------------------
+key_alt_up:
+ mov [alt_flag],1
+ jmp still
+;---------------------------------------------------------------------
+key_alt_down:
+ mov [alt_flag],0
+ jmp still
+;---------------------------------------------------------------------
+check_key_O:
+ cmp [ctrl_flag],0
+ jne kfile
+ jmp k_option
+;---------------------------------------------------------------------
+move_to_left:
+ xor eax,eax
+ cmp [load_file_number],eax
+ je still
+ dec [load_file_number]
+ jmp right_limit.2
+;----------------------------------------
+move_to_right:
+ mov eax,[load_directory_pointer]
+ mov eax,[eax+4]
+ test eax,eax
+ jz @f
+ dec eax
+@@:
+ cmp [load_file_number],eax
+ je still
+ inc [load_file_number]
+ jmp right_limit.2
+;----------------------------------------
+left_limit:
+ xor eax,eax
+ jmp right_limit.1
+;----------------------------------------
+right_limit:
+ mov eax,[load_directory_pointer]
+ mov eax,[eax+4]
+ test eax,eax
+ jz @f
+ dec eax
+@@:
+.1:
+ cmp [load_file_number],eax
+ je still
+ mov [load_file_number],eax
+.2:
+ imul ebx,[load_file_number],304
+ add ebx,32+40
+ add ebx,[load_directory_pointer]
+
+ mov esi,string
+ mov edi,plugin_pach
+ call copy_file_path
+
+ mov esi,plugin_pach
+ mov edi,string
+ mov ecx,4096/4
+ cld
+ rep movsd
+
+; jmp kopen
+ mov [open_file_flag],0
+ mov ecx,-1
+ call getappinfo
+ call load_image
+ test eax,eax
+ jnz kopen_1.err
+
+ call convert
+
+ call load_directory.copy_dir_path
+
+ call get_window_param
+ test [window_status],1b
+ jz @f ;draw_still
+ mov [no_draw_window],1
+ call draw_other
+ mov [no_draw_window],0
+ jmp .3
+
+@@:
+ call draw_window
+.3:
+ mov al,[old_key_code]
+ mov ah,[current_key_code]
+ mov [old_key_code],ah
+ cmp al,ah
+ jne still ;key.extended_key ;still
+.still:
+ mcall 2
+ cmp [extended_key],1
+ je .extended_key
+ test al, al
+ jnz still
+ cmp ah, 0xE0
+ jne @f
+ mov [extended_key],1
+ jmp .still
+@@:
+ jmp still
+.extended_key:
+ mov [extended_key],0
+ mov [current_key_code],ah
+ jmp .3
+.4:
+ mov ah,[current_key_code]
+ mov [old_key_code],ah
+ jmp key.extended_key
+;---------------------------------------------------------------------
+slide_show:
+ mov eax,[load_directory_pointer]
+ cmp [eax+4],dword 1
+ jbe still
+ mcall 26,9
+ cmp [timer],eax
+ jbe .1
+ jmp .still
+.red:
+ call draw_window
+.still:
+ mcall 23,10
+ cmp eax,1 ; ?
+ je .red
+ cmp eax,2 ; ?
+ je .key ; - key
+ cmp eax,3 ; ?
+ je .button ; - button
+; mcall 68,1
+ jmp slide_show
+;-------------------------------------------
+.key:
+ mcall 2
+ cmp [extended_key],1
+ je .extended_key
+ test al, al
+ jnz .still
+ cmp ah, 0xE0
+ jne @f
+ mov [extended_key],1
+ jmp .still
+@@:
+ cmp ah,1 ; Esc
+ je still
+ cmp ah,185 ; Space
+ je still
+ jmp .still
+.extended_key:
+ mov [extended_key],0
+ mov [current_key_code],ah
+ jmp .still
+;-------------------------------------------
+.button: ; button
+ mov eax,17 ; get id
+ mcall
+ cmp ah,1 ; button id=1 ?
+ je START.exit
+.noclose:
+ cmp ah,2
+ je still
+ jmp slide_show
+;-------------------------------------------
+.1:
+; mcall 26,9
+; add eax,[slide_show_delay] ;500
+; mov [timer],eax
+
+ mov eax,[load_directory_pointer]
+ mov eax,[eax+4]
+ test eax,eax
+ jz @f
+ dec eax
+@@:
+ cmp [load_file_number],eax
+ je still
+ inc [load_file_number]
+ imul ebx,[load_file_number],304
+ add ebx,32+40
+ add ebx,[load_directory_pointer]
+
+ mov esi,string
+ mov edi,plugin_pach
+ call copy_file_path
+
+ mov esi,plugin_pach
+ mov edi,string
+ mov ecx,4096/4
+ cld
+ rep movsd
+ mov [open_file_flag],0
+ mov ecx,-1
+ call getappinfo
+ call load_image
+
+ test eax,eax
+ jnz kopen_1.err
+
+ call convert
+ call load_directory.copy_dir_path
+
+ call get_window_param
+ test [window_status],1b
+ jz @f ;draw_still
+ mov [no_draw_window],1
+ call draw_other
+ mov [no_draw_window],0
+ jmp .3 ;slide_show
+@@:
+ call draw_window
+; jmp slide_show
+.3:
+ mcall 26,9
+ add eax,[slide_show_delay] ;500
+ mov [timer],eax
+ jmp slide_show
+;---------------------------------------------------------------------
+key_up_arrow:
+ mov eax,[scroll_bar_data_vertical.ar_offset]
+ mov ebx,scroll_bar_data_vertical.position
+ cmp [ebx],eax
+ jbe @f
+ sub [ebx],eax
+ jmp .1
+@@:
+ xor eax,eax
+ cmp [ebx],eax
+ je still
+ mov [ebx],eax
+.1:
+ call drawimage
+ call draw_scrollbars
+ jmp still
+;---------------------------------------------------------------------
+key_down_arrow:
+ mov ecx,[scroll_bar_data_vertical.ar_offset]
+ mov ebx,scroll_bar_data_vertical.position
+ mov eax,[scroll_bar_data_vertical.max_area]
+ sub eax,[scroll_bar_data_vertical.cur_area]
+ cmp [ebx],eax
+ je still
+ push eax
+ sub eax,ecx
+ cmp [ebx],eax
+ pop eax
+ jae @f
+ add [ebx],ecx
+ jmp key_up_arrow.1
+@@:
+ mov [ebx],eax
+ jmp key_up_arrow.1
+;---------------------------------------------------------------------
+key_left_arrow:
+ mov eax,[scroll_bar_data_horizontal.ar_offset]
+ mov ebx,scroll_bar_data_horizontal.position
+ cmp [ebx],eax
+ jbe @f
+ sub [ebx],eax
+ jmp key_up_arrow.1
+@@:
+ xor eax,eax
+ cmp [ebx],eax
+ je still
+ mov [ebx],eax
+ jmp key_up_arrow.1
+;---------------------------------------------------------------------
+key_right_arrow:
+ mov ecx,[scroll_bar_data_horizontal.ar_offset]
+ mov ebx,scroll_bar_data_horizontal.position
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ sub eax,[scroll_bar_data_horizontal.cur_area]
+ cmp [ebx],eax
+ je still
+ push eax
+ sub eax,ecx
+ cmp [ebx],eax
+ pop eax
+ jae @f
+ add [ebx],ecx
+ jmp key_up_arrow.1
+@@:
+ mov [ebx],eax
+
+; xor eax,eax
+; mov ax,[scroll_bar_data_horizontal.size_x]
+; sub eax,[scroll_bar_data_horizontal.btn_high]
+; sub eax,[scroll_bar_data_horizontal.btn_high]
+; sub eax,[scroll_bar_data_horizontal.run_size]
+; mov [scroll_bar_data_horizontal.position2],eax
+ jmp key_up_arrow.1
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/libini.inc b/programs/media/zsea/libini.inc
new file mode 100644
index 0000000000..9c14fb2710
--- /dev/null
+++ b/programs/media/zsea/libini.inc
@@ -0,0 +1,115 @@
+;---------------------------------------------------------------------
+Get_ini:
+
+ stdcall dll.Init,[lib_init]
+
+ mov ebx,ini_file_name
+ mov esi,path
+ mov edi,plugin_pach
+ call copy_file_path
+
+ invoke ini_get_int,plugin_pach,aVariables,aSortMode,2
+ cmp eax,0
+ jb .error_aSortMode
+ cmp eax,13
+ jb @f
+.error_aSortMode:
+ mov eax,2
+@@:
+ mov [sort_type],eax
+ invoke ini_get_int,plugin_pach,aVariables,aArrowsOffset,10
+ cmp eax,1
+ jb .error_aArrowsOffset
+ cmp eax,100
+ jb @f
+.error_aArrowsOffset:
+ mov eax,10
+@@:
+ mov [arrows_offset],eax
+ invoke ini_get_int,plugin_pach,aVariables,aSlideShowDelay,300
+ cmp eax,1
+ jb .error_aSlideShowDelay
+ cmp eax,99990
+ jb @f
+.error_aSlideShowDelay:
+ mov eax,300
+@@:
+ mov [slide_show_delay],eax
+ invoke ini_get_int,plugin_pach,aVariables,aShowFileName,0
+ cmp eax,0
+ jb .error_aShowFileName
+ cmp eax,1
+ jb @f
+.error_aShowFileName:
+ mov eax,1
+@@:
+ shl eax,1
+ mov [check1+32],eax
+ invoke ini_get_int,plugin_pach,aVariables,aFilteringFlag,0
+ cmp eax,0
+ jb .error_aFilteringFlag
+ cmp eax,1
+ jb @f
+.error_aFilteringFlag:
+ mov eax,1
+@@:
+ mov [filtering_flag],eax
+ shl eax,1
+ mov [check2+32],eax
+
+; get convert plugins names
+ invoke ini_get_str,plugin_pach,aConvertPlugins,aCP0,plugin_0_name,127,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aConvertPlugins,aCP1,plugin_1_name,127,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aConvertPlugins,aCP2,plugin_2_name,127,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aConvertPlugins,aCP3,plugin_3_name,127,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aConvertPlugins,aCP4,plugin_4_name,127,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aConvertPlugins,aCP5,plugin_5_name,127,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aConvertPlugins,aCP6,plugin_6_name,127,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aConvertPlugins,aCP7,plugin_7_name,127,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aConvertPlugins,aCP8,plugin_8_name,127,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aConvertPlugins,aCP9,plugin_9_name,127,ConvertPlugins_no_key
+
+ invoke ini_get_str,plugin_pach,aApplicationsPaths,aHelp,Help_path,1023,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aApplicationsPaths,aEditor,Editor_path,1023,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aApplicationsPaths,aOpenDialog,OpenDialog_path,1023,ConvertPlugins_no_key
+ invoke ini_get_str,plugin_pach,aOther,akey_help,key_help_name,127,ConvertPlugins_no_key
+ ret
+;---------------------------------------------------------------------
+Set_ini:
+ mov ebx,ini_file_name
+ mov esi,path
+ mov edi,plugin_pach
+ call copy_file_path
+
+ invoke ini_set_int,plugin_pach,aVariables,aSortMode,[sort_type]
+ invoke ini_set_int,plugin_pach,aVariables,aArrowsOffset,[arrows_offset]
+ invoke ini_set_int,plugin_pach,aVariables,aSlideShowDelay,[slide_show_delay]
+ mov eax,[check1+32]
+ shr eax,1
+ mov [check1+32],eax
+ invoke ini_set_int,plugin_pach,aVariables,aShowFileName,[check1+32]
+ invoke ini_set_int,plugin_pach,aVariables,aFilteringFlag,[filtering_flag]
+ ret
+;---------------------------------------------------------------------
+;libini_alloc:
+; push ecx
+; mov ecx, [esp+8]
+; mcall 68,12
+; pop ecx
+; ret 4
+;---------------------------------------------------------------------
+;libini_free:
+; push ecx
+; mov ecx, [esp+8]
+; mcall 68,13
+; pop ecx
+; ret 4
+;---------------------------------------------------------------------
+;libini_realloc:
+; push ecx edx
+; mov edx, [esp+8+4]
+; mov ecx, [esp+8+8]
+; mcall 68,20
+; pop edx ecx
+; ret 8
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/load.inc b/programs/media/zsea/load.inc
new file mode 100644
index 0000000000..8f1c299d3a
--- /dev/null
+++ b/programs/media/zsea/load.inc
@@ -0,0 +1,886 @@
+;---------------------------------------------------------------------
+load_plugins:
+
+load_libraries l_libs_start,end_l_libs
+
+ test eax,eax
+ jnz START.exit_1
+;---------------------------------------------------------------------
+; Get ini values
+ call Get_ini
+; jmp last_plugin
+;---------------------------------------------------------------------
+; mov [cnv_plugin_name_pointer],plugin_0_name
+load_convert_plugins:
+ mov ecx,10
+.1:
+ push ecx
+ mov esi,[cnv_plugin_name_pointer]
+ cmp [esi],dword 'NoKe'
+ je clear_current_load_convert_plugins_area ;last_plugin
+ mov edi,system_path.1
+ mov ecx,128/4
+ cld
+ rep movsd
+
+ mov esi,[cnv_plugin_name_pointer]
+ mov edi,err_message_found_lib.1
+ mov ecx,128/4
+ rep movsd
+
+ mov esi,[cnv_plugin_name_pointer]
+ mov edi,err_message_import.1
+ mov ecx,128/4
+ rep movsd
+
+load_library system_path.1, path, library_path, system_path, \
+err_message_found_lib, head_f_l, \
+[cnv_plugin_import_pointer], err_message_import, head_f_i, plugins_directory
+
+ test eax,eax
+ jnz START.exit_1
+load_convert_plugins_next:
+ add [cnv_plugin_import_pointer],dword 24
+ add [cnv_plugin_name_pointer],128
+ pop ecx
+ dec ecx
+ jnz load_convert_plugins.1
+
+; jmp load_convert_plugins
+
+last_plugin:
+; initialize sort
+ push dword 1
+ call dword [sort_init]
+; unpack deflate
+ mov eax,[unpack_DeflateUnpack2]
+ mov [deflate_unpack],eax
+ ret
+;-----------------------------------------
+clear_current_load_convert_plugins_area:
+ xor eax,eax
+ mov edi,[cnv_plugin_import_pointer]
+ cld
+ push ecx
+ mov ecx,24/4
+ rep stosd
+ pop ecx
+ jmp load_convert_plugins_next
+;---------------------------------------------------------------------
+copy_path_my:
+ xor eax,eax
+@@:
+ cld
+ lodsb
+ stosb
+ test eax,eax
+ jnz @b
+ mov esi,edi
+@@:
+ std
+ lodsb
+ cmp al,'/'
+ jnz @b
+ mov edi,esi
+ add edi,2
+ mov esi,ebx
+@@:
+ cld
+ lodsb
+ stosb
+ test eax,eax
+ jnz @b
+ mov esi,ecx
+ dec edi
+@@:
+ cld
+ lodsb
+ stosb
+ test eax,eax
+ jnz @b
+ ret
+;---------------------------------------------------------------------
+load_image:
+
+ call delete_RAW1
+ mov [fileinfo+0],dword 5
+ mov [fileinfo+12],dword 0
+ mov [fileinfo+16],dword process_info
+
+ cmp [soi],0
+ je @f
+ mov ecx,[raw_pointer]
+ mcall 68, 13,
+ mov [soi],0
+@@:
+; cmp [raw_pointer_2],dword 0
+; je @f
+; mov ecx,[raw_pointer_2] ;[soi]
+; mcall 68, 13,
+; mov [raw_pointer_2],0
+;@@:
+.1:
+ mcall 70, fileinfo
+ test eax,eax
+ jnz .end
+
+ mov [fileinfo+0],dword 0
+
+ mov ecx,[process_info+32]
+
+; for Diamond emulator, and broken files - size = 0
+; test ecx,ecx
+; jnz @f
+ cmp ecx,32
+ jae @f
+ mov eax,6
+ jmp .end
+@@:
+ mov [fileinfo+12],ecx
+ mov [img_size],ecx
+
+ mcall 68, 12
+
+ mov [fileinfo+16],eax
+ mov [image_file],eax
+
+ mcall 70, fileinfo
+.end:
+ mov [error_fs],eax
+
+ ret
+;---------------------------------------------------------------------
+delete_RAW1:
+ cmp [RAW1_pointer],0
+ jne @f
+ ret
+@@:
+ mcall 68, 13,[previous_frame_pointer]
+ xor eax,eax
+ mov [Repeat_N],eax
+
+@@:
+ mov edx,[Repeat_N]
+ shl edx,4
+ add edx,[RAW1_pointer]
+ mov ecx,[edx+16]
+ call .1
+
+ inc [Repeat_N]
+ mov eax,[Repeat_N]
+ cmp [Total_Repeat_N],eax
+ ja @r
+
+ mov ecx,[RAW1_pointer]
+ call .1
+
+ xor eax,eax
+ mov [RAW1_pointer],eax
+ ret
+.1:
+ mcall 68, 13,
+ ret
+;---------------------------------------------------------------------
+load_buttons:
+
+ mov esi,path
+ mov edi,plugin_pach
+ mov ebx,buttons_directory
+ mov ecx,button_name ;buttons_passive_name
+ call copy_path_my
+
+ mov [fileinfo.name], dword plugin_pach
+
+ xor eax,eax
+ mov [raw_pointer_2],eax
+
+ call load_image
+ mov eax,[error_fs]
+ test eax,eax
+ jnz START.exit_1
+
+ call convert_plugin_invoke
+ mov eax,[return_code]
+ test eax,eax
+ jnz START.exit_1
+
+
+ mov ebx,[raw_pointer]
+ mov eax,[ebx+4]
+ mov [dinamic_button_data_1.size_x],ax
+ mov [dinamic_button_data_1.size_y],ax
+ mov [dinamic_button_data_2.size_x],ax
+ mov [dinamic_button_data_2.size_y],ax
+ mov [dinamic_button_data_3.size_x],ax
+ mov [dinamic_button_data_3.size_y],ax
+ mov [dinamic_button_data_4.size_x],ax
+ mov [dinamic_button_data_4.size_y],ax
+ mov [dinamic_button_data_5.size_x],ax
+ mov [dinamic_button_data_5.size_y],ax
+ mov [dinamic_button_data_6.size_x],ax
+ mov [dinamic_button_data_6.size_y],ax
+ mov [dinamic_button_data_7.size_x],ax
+ mov [dinamic_button_data_7.size_y],ax
+ mov [dinamic_button_data_8.size_x],ax
+ mov [dinamic_button_data_8.size_y],ax
+ mov [dinamic_button_data_9.size_x],ax
+ mov [dinamic_button_data_9.size_y],ax
+ mov [dinamic_button_data_10.size_x],ax
+ mov [dinamic_button_data_10.size_y],ax
+ mov [dinamic_button_data_11.size_x],ax
+ mov [dinamic_button_data_11.size_y],ax
+ mov [dinamic_button_data_12.size_x],ax
+ mov [dinamic_button_data_12.size_y],ax
+ mov [dinamic_button_data_13.size_x],ax
+ mov [dinamic_button_data_13.size_y],ax
+ mov [dinamic_button_data_14.size_x],ax
+ mov [dinamic_button_data_14.size_y],ax
+ mov [dinamic_button_data_15.size_x],ax
+ mov [dinamic_button_data_15.size_y],ax
+ mov eax,[ebx+12]
+ mov [dinamic_button_data_1.resolution_raw],eax
+ mov [dinamic_button_data_2.resolution_raw],eax
+ mov [dinamic_button_data_3.resolution_raw],eax
+ mov [dinamic_button_data_4.resolution_raw],eax
+ mov [dinamic_button_data_5.resolution_raw],eax
+ mov [dinamic_button_data_6.resolution_raw],eax
+ mov [dinamic_button_data_7.resolution_raw],eax
+ mov [dinamic_button_data_8.resolution_raw],eax
+ mov [dinamic_button_data_9.resolution_raw],eax
+ mov [dinamic_button_data_10.resolution_raw],eax
+ mov [dinamic_button_data_11.resolution_raw],eax
+ mov [dinamic_button_data_12.resolution_raw],eax
+ mov [dinamic_button_data_13.resolution_raw],eax
+ mov [dinamic_button_data_14.resolution_raw],eax
+ mov [dinamic_button_data_15.resolution_raw],eax
+ mov eax,[ebx+20]
+ add eax,ebx
+ mov [dinamic_button_data_1.palette_raw],eax
+ mov [dinamic_button_data_2.palette_raw],eax
+ mov [dinamic_button_data_3.palette_raw],eax
+ mov [dinamic_button_data_4.palette_raw],eax
+ mov [dinamic_button_data_5.palette_raw],eax
+ mov [dinamic_button_data_6.palette_raw],eax
+ mov [dinamic_button_data_7.palette_raw],eax
+ mov [dinamic_button_data_8.palette_raw],eax
+ mov [dinamic_button_data_9.palette_raw],eax
+ mov [dinamic_button_data_10.palette_raw],eax
+ mov [dinamic_button_data_11.palette_raw],eax
+ mov [dinamic_button_data_12.palette_raw],eax
+ mov [dinamic_button_data_13.palette_raw],eax
+ mov [dinamic_button_data_14.palette_raw],eax
+ mov [dinamic_button_data_15.palette_raw],eax
+ mov eax,[ebx+28]
+ add eax,ebx
+ push eax
+ mov [dinamic_button_data_1.passive_raw],eax
+ mov ecx,[ebx+4]
+ imul ecx,[ebx+4]
+ imul ecx,[ebx+12]
+ shr ecx,3
+ add eax,ecx
+ mov [dinamic_button_data_2.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_3.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_4.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_5.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_6.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_7.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_8.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_9.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_10.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_11.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_12.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_13.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_14.passive_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_15.passive_raw],eax
+;------------------------------------
+ movzx ebx,word [dinamic_button_data_1.size_x]
+ movzx eax,word [dinamic_button_data_1.size_y]
+ imul eax,ebx
+ imul eax,15
+ mov ebx,[dinamic_button_data_1.resolution_raw]
+ shr ebx,3
+ imul ebx,eax
+
+ pop eax
+ add eax,ebx
+ push eax
+ mov [dinamic_button_data_1.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_2.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_3.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_4.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_5.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_6.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_7.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_8.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_9.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_10.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_11.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_12.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_13.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_14.active_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_15.active_raw],eax
+;------------------------------------
+ pop eax
+ add eax,ebx
+ mov [dinamic_button_data_1.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_2.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_3.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_4.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_5.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_6.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_7.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_8.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_9.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_10.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_11.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_12.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_13.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_14.click_raw],eax
+ add eax,ecx
+ mov [dinamic_button_data_15.click_raw],eax
+;------------------------------------
+ mov [fileinfo.name], dword string
+ xor eax,eax
+ mov [img_size],eax
+ ret
+;---------------------------------------------------------------------
+load_directory:
+ cmp [load_directory_pointer],dir_header ;dword 0
+ je @f
+ mcall 68, 13, [load_directory_pointer]
+@@:
+ call .copy_dir_path
+ mov [dirinfo.size],dword 0
+ mov [dirinfo.return],dir_header ;procinfo
+ mcall 70, dirinfo
+ test eax,eax
+ jnz .end_err
+
+ mov ecx,[dir_header.totl_blocks] ;[procinfo+8]
+ mov [dirinfo.size],ecx
+ imul ecx,304
+ add ecx,32
+ mcall 68, 12
+ mov [dirinfo.return],eax
+ mov [load_directory_pointer],eax
+
+ mcall 70, dirinfo
+ test eax,eax
+ jnz .end_err
+ call delete_unsupported_BDFE
+.sort:
+ call sort_directory
+; add [load_directory_pointer],2*304+32+40
+ mov ebp,[load_directory_pointer]
+ mov ebp,[ebp+4]
+; check ebp = 0
+ test ebp,ebp
+ jz .end_1 ;.start
+ dec ebp
+ jz .end_1
+
+.start:
+ mov esi,file_name
+ mov ecx,[file_name_length]
+ imul edi,ebp,304
+ add edi,32+40
+ add edi,[load_directory_pointer]
+@@:
+ cld
+ lodsb
+ call char_todown
+ xchg ah,al
+ xchg edi,esi
+ cld
+ lodsb
+ call char_todown
+; xchg ah,al
+ xchg edi,esi
+ dec ecx
+ jz .end
+ cmp ah,al
+ je @r
+
+ dec ebp
+ jnz .start
+.end_1:
+ xor eax,eax
+ mov [load_file_number],eax
+ ret
+.end:
+ mov [load_file_number],ebp
+ xor eax,eax
+.end_err:
+ ret
+;-------------------------------------------
+.copy_dir_path:
+ mov esi,string ;path
+ mov edi,plugin_pach
+ mov ebx,file_name
+ call copy_dir_path
+ mov [file_name_length],ebx
+ ret
+;---------------------------------------------------------------------
+sort_directory:
+; pusha
+ push dword [sort_type] ;2 ;
+ mov eax,[load_directory_pointer]
+ push dword [eax+4] ;[dirdata+4] ;
+ ; push ebx,
+ ; int 0x40
+ add eax,32
+ push eax ;dirdata+32 ;
+; call [plugin_sort]
+ call [sort_dir]
+; popa
+ ret
+;---------------------------------------------------------------------
+delete_unsupported_BDFE:
+
+ mov [fileinfo.subfunction],dword 0
+ mov [fileinfo.size],dword 32
+ mov [fileinfo.name], dword plugin_pach
+
+ mov eax,process_info
+ mov [fileinfo.return],eax
+ mov [image_file],eax
+
+ mov ebx,[load_directory_pointer]
+ add ebx,4
+ xor ecx,ecx
+ dec ecx
+
+ mov eax,[load_directory_pointer]
+ add eax,32+40
+ sub eax,304
+.start:
+ inc ecx
+ add eax,304
+.1:
+ cmp [ebx],ecx
+ je .end
+ cmp [eax],byte '.'
+ jne @f
+ cmp [eax+1],byte 0
+ je .delete
+@@:
+ cmp [eax],word '..'
+ jne @f
+ cmp [eax+2],byte 0
+ je .delete
+@@:
+ test [eax-40],byte 0x10
+ jnz .delete
+
+ push eax ebx
+ mov esi,eax
+ call search_expansion
+ test eax,eax
+ pop ebx eax
+ jnz .delete
+
+; mov edi,[test_area+4]
+; cmp [esi],edi
+; je .start
+
+ mov edi,plugin_0_name
+ cmp [edi],dword 'NoKe'
+ je .delete
+
+ push eax ebx ecx esi
+ mov edi,[Convert_plugin_0.Assoc]
+ test edi,edi
+ jnz @f
+ pop esi ecx ebx eax
+ jmp .delete
+@@:
+ call compare_expansion
+ test eax,eax
+ pop esi ecx ebx eax
+ jz .start
+
+ mov edi,plugin_1_name
+ cmp [edi],dword 'NoKe'
+ je .delete
+
+ push eax ebx ecx esi
+ mov edi,[Convert_plugin_1.Assoc]
+ test edi,edi
+ jnz @f
+ pop esi ecx ebx eax
+ jmp .delete
+@@:
+ call compare_expansion
+ test eax,eax
+ pop esi ecx ebx eax
+ jz .start
+
+ mov edi,plugin_2_name
+ cmp [edi],dword 'NoKe'
+ je .delete
+
+ push eax ebx ecx esi
+ mov edi,[Convert_plugin_2.Assoc]
+ test edi,edi
+ jnz @f
+ pop esi ecx ebx eax
+ jmp .delete
+@@:
+ call compare_expansion
+ test eax,eax
+ pop esi ecx ebx eax
+ jz .start
+
+ mov edi,plugin_3_name
+ cmp [edi],dword 'NoKe'
+ je .delete
+
+ push eax ebx ecx esi
+ mov edi,[Convert_plugin_3.Assoc]
+ test edi,edi
+ jnz @f
+ pop esi ecx ebx eax
+ jmp .delete
+@@:
+ call compare_expansion
+ test eax,eax
+ pop esi ecx ebx eax
+ jz .start
+
+ mov edi,plugin_4_name
+ cmp [edi],dword 'NoKe'
+ je .delete
+
+ push eax ebx ecx esi
+ mov edi,[Convert_plugin_4.Assoc]
+ test edi,edi
+ jnz @f
+ pop esi ecx ebx eax
+ jmp .delete
+@@:
+ call compare_expansion
+ test eax,eax
+ pop esi ecx ebx eax
+ jz .start
+
+ mov edi,plugin_5_name
+ cmp [edi],dword 'NoKe'
+ je .delete
+
+ push eax ebx ecx esi
+ mov edi,[Convert_plugin_5.Assoc]
+ test edi,edi
+ jnz @f
+ pop esi ecx ebx eax
+ jmp .delete
+@@:
+ call compare_expansion
+ test eax,eax
+ pop esi ecx ebx eax
+ jz .start
+
+ mov edi,plugin_6_name
+ cmp [edi],dword 'NoKe'
+ je .delete
+
+ push eax ebx ecx esi
+ mov edi,[Convert_plugin_6.Assoc]
+ test edi,edi
+ jnz @f
+ pop esi ecx ebx eax
+ jmp .delete
+@@:
+ call compare_expansion
+ test eax,eax
+ pop esi ecx ebx eax
+ jz .start
+
+ mov edi,plugin_7_name
+ cmp [edi],dword 'NoKe'
+ je .delete
+
+ push eax ebx ecx esi
+ mov edi,[Convert_plugin_7.Assoc]
+ test edi,edi
+ jnz @f
+ pop esi ecx ebx eax
+ jmp .delete
+@@:
+ call compare_expansion
+ test eax,eax
+ pop esi ecx ebx eax
+ jz .start
+
+ mov edi,plugin_8_name
+ cmp [edi],dword 'NoKe'
+ je .delete
+
+ push eax ebx ecx esi
+ mov edi,[Convert_plugin_8.Assoc]
+ test edi,edi
+ jnz @f
+ pop esi ecx ebx eax
+ jmp .delete
+@@:
+ call compare_expansion
+ test eax,eax
+ pop esi ecx ebx eax
+ jz .start
+
+ mov edi,plugin_9_name
+ cmp [edi],dword 'NoKe'
+ je .delete
+
+ push eax ebx ecx esi
+ mov edi,[Convert_plugin_9.Assoc]
+ test edi,edi
+ jnz @f
+ pop esi ecx ebx eax
+ jmp .delete
+@@:
+ call compare_expansion
+ test eax,eax
+ pop esi ecx ebx eax
+ jz .start
+;-------------------------------------------
+.delete:
+ dec dword [ebx]
+ mov esi,[ebx]
+ sub esi,ecx
+
+ push ecx
+ mov ecx,esi
+ imul ecx,304/4
+ mov edi,eax
+ sub edi,40
+ mov esi,edi
+ add esi,304
+ cld
+ rep movsd
+ pop ecx
+
+ jmp .1
+.end:
+ mov [fileinfo.name], dword string
+ ret
+;---------------------------------------------------------------------
+image_editor:
+ mov [start_appl.parameter],dword string
+ mov [start_appl.name],dword Editor_path
+ mcall 70, start_appl
+ jmp still
+;---------------------------------------------------------------------
+open_help:
+ mov ebx,key_help_name
+ mov esi,path
+ mov edi,library_path
+ call copy_file_path
+ mov [start_appl.parameter],dword library_path
+ mov [start_appl.name],dword Help_path
+ mcall 70, start_appl
+ jmp still
+;---------------------------------------------------------------------
+char_todown:
+; convert character to uppercase, using cp866 encoding
+; in: al=symbol
+; out: al=converted symbol
+ cmp al, 'A'
+ jb .ret
+ cmp al, 'Z'
+ jbe .az
+ cmp al, ''
+ jb .ret
+ cmp al, ''
+ jb .rus1
+ cmp al, ''
+ ja .ret
+; 0x90-0x9F -> 0xE0-0xEF
+ add al, ''-''
+.ret:
+ ret
+.rus1:
+; 0x80-0x8F -> 0xA0-0xAF
+.az:
+ add al, 0x20
+ ret
+;---------------------------------------------------------------------
+copy_dir_path:
+ xor eax,eax
+ cmp [esi],al
+ jne @f
+ mov [edi],al
+ mov [ebx],al
+ xor ebx,ebx
+ inc ebx
+ ret
+@@:
+ cld
+ lodsb
+ stosb
+ test eax,eax
+ jnz @b
+ mov esi,edi
+ dec esi
+@@:
+ std
+ lodsb
+ cmp al,'/'
+ jnz @b
+
+ push esi
+ add esi,2
+ mov edi,ebx ;file_name
+ xor ebx,ebx
+@@:
+ cld
+ lodsb
+ stosb
+ inc ebx
+ test eax,eax
+ jnz @b
+ pop esi
+
+ mov [esi+1], byte 0
+ cld
+ ret
+;---------------------------------------------------------------------
+copy_file_path:
+ xor eax,eax
+@@:
+ cld
+ lodsb
+ stosb
+ test eax,eax
+ jnz @b
+ mov esi,edi
+ dec esi
+@@:
+ std
+ lodsb
+ cmp al,'/'
+ jnz @b
+ mov edi,esi
+ add edi,2
+ mov esi,ebx
+@@:
+ cld
+ lodsb
+ stosb
+ test eax,eax
+ jnz @b
+ ret
+;---------------------------------------------------------------------
+search_expansion:
+ mov edi,esi
+ xor eax,eax
+@@:
+ cld
+ lodsb
+ test eax,eax
+ jnz @b
+ mov ebx,esi
+ dec esi
+@@:
+ std
+ lodsb
+ cmp esi,edi
+ jb .end_err
+ cmp al,'.'
+ jne @b
+
+ add esi,2
+ sub ebx,esi
+ dec ebx
+ mov [expansion_length],ebx
+ cld
+ xor eax,eax
+ ret
+
+.end_err:
+ cld
+ xor eax,eax
+ inc eax
+ ret
+;---------------------------------------------------------------------
+compare_expansion:
+ mov ebx,[edi]
+ add ebx,edi
+ add edi,3
+.start:
+ cmp ebx,edi
+ jb .end_err
+ mov ecx,[expansion_length]
+ inc edi
+
+ push esi edi
+@@:
+ cld
+ lodsb
+ xchg esi,edi
+ shl eax,8
+ lodsb
+ xchg esi,edi
+ call char_todown
+ xchg al,ah
+ call char_todown
+ cmp al,ah
+ jne @f
+ dec ecx
+ jnz @b
+ jmp .end
+@@:
+ pop edi esi
+ jmp .start
+
+; jnz .start
+.end:
+ pop edi esi
+ xor eax,eax
+ ret
+
+.end_err:
+ xor eax,eax
+ inc eax
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/menu_key.inc b/programs/media/zsea/menu_key.inc
new file mode 100644
index 0000000000..edf22a1c59
--- /dev/null
+++ b/programs/media/zsea/menu_key.inc
@@ -0,0 +1,171 @@
+select_menu:
+ call check_alt
+.1:
+ xor eax,eax
+ mov [menu_data_1.ret_key],eax
+
+ push dword menu_data_1
+ call [menu_bar_activate]
+
+ call clear_control_key_flag
+
+ mov eax,[menu_data_1.ret_key]
+ mov [menu_data_1.ret_key],dword 0
+ cmp eax,1
+ je .6
+
+ cmp eax,2
+ je .2
+
+ cmp [menu_data_1.click],dword 1
+ jne still
+
+ cmp [menu_data_1.cursor_out],dword 0
+ jne analyse_out_menu_1
+ jmp still
+;---------------------------------------------------------------------
+.2:
+ xor eax,eax
+ mov [menu_data_2.ret_key],eax
+
+ push dword menu_data_2
+ call [menu_bar_activate]
+
+ call clear_control_key_flag
+
+ mov eax,[menu_data_2.ret_key]
+ mov [menu_data_2.ret_key],dword 0
+ cmp eax,1
+ je .1
+
+ cmp eax,2
+ je .3
+
+
+ cmp [menu_data_2.click],dword 1
+ jne still
+
+ cmp [menu_data_2.cursor_out],dword 0
+ jne analyse_out_menu_2
+ jmp still
+;---------------------------------------------------------------------
+.3:
+ xor eax,eax
+ mov [menu_data_3.ret_key],eax
+
+ push dword menu_data_3
+ call [menu_bar_activate]
+
+ call clear_control_key_flag
+
+ mov eax,[menu_data_3.ret_key]
+ mov [menu_data_3.ret_key],dword 0
+ cmp eax,1
+ je .2
+
+ cmp eax,2
+ je .4
+
+
+ cmp [menu_data_3.click],dword 1
+ jne still
+
+ cmp [menu_data_3.cursor_out],dword 0
+ jne analyse_out_menu_3
+ jmp still
+;---------------------------------------------------------------------
+.4:
+ xor eax,eax
+ mov [menu_data_4.ret_key],eax
+
+ push dword menu_data_4
+ call [menu_bar_activate]
+
+ call clear_control_key_flag
+
+ mov eax,[menu_data_4.ret_key]
+ mov [menu_data_4.ret_key],dword 0
+ cmp eax,1
+ je .3
+
+ cmp eax,2
+ je .5
+
+
+ cmp [menu_data_4.click],dword 1
+ jne still
+
+ cmp [menu_data_4.cursor_out],dword 0
+ jne analyse_out_menu_4
+ jmp still
+;---------------------------------------------------------------------
+.5:
+ xor eax,eax
+ mov [menu_data_5.ret_key],eax
+
+ push dword menu_data_5
+ call [menu_bar_activate]
+
+ call clear_control_key_flag
+
+ mov eax,[menu_data_5.ret_key]
+ mov [menu_data_5.ret_key],dword 0
+ cmp eax,1
+ je .4
+
+ cmp eax,2
+ je .6
+
+
+ cmp [menu_data_5.click],dword 1
+ jne still
+
+ cmp [menu_data_5.cursor_out],dword 0
+ jne analyse_out_menu_5
+ jmp still
+;---------------------------------------------------------------------
+.6:
+ xor eax,eax
+ mov [menu_data_6.ret_key],eax
+
+ push dword menu_data_6
+ call [menu_bar_activate]
+
+ call clear_control_key_flag
+
+ mov eax,[menu_data_6.ret_key]
+ mov [menu_data_6.ret_key],dword 0
+ cmp eax,1
+ je .5
+
+ cmp eax,2
+ je .1
+
+
+ cmp [menu_data_6.click],dword 1
+ jne still
+
+ cmp [menu_data_6.cursor_out],dword 0
+ jne analyse_out_menu_6
+ jmp still
+;---------------------------------------------------------------------
+clear_control_key_flag:
+ push eax
+ xor eax,eax
+ mov [shift_flag],al
+ mov [ctrl_flag],al
+ mov [alt_flag],al
+ pop eax
+ ret
+;---------------------------------------------------------------------
+check_alt:
+ xor eax,eax
+ mov al,[alt_flag]
+ test eax,eax
+ jz @f
+ xor ebx,ebx
+ ret
+@@:
+ add esp,4
+ jmp still
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/mouse.inc b/programs/media/zsea/mouse.inc
new file mode 100644
index 0000000000..3d6fbc255d
--- /dev/null
+++ b/programs/media/zsea/mouse.inc
@@ -0,0 +1,596 @@
+;---------------------------------------------------------------------
+mouse:
+ mcall 18,7
+ cmp [active_process],eax
+ jne still
+
+ mcall 37,7
+ mov [mouse_scroll_data],eax
+
+ mov eax,[mouse_position]
+ mov [mouse_position_old],eax
+ mcall 37,1
+ mov [mouse_position],eax
+
+ mov eax,[mouse_keys]
+ mov [mouse_keys_old],eax
+ mcall 37,2
+ mov [mouse_keys],eax
+
+ cmp [soi],dword 0
+ je .menu_bar
+ cmp [scaling_mode],dword 0
+ je .menu_bar
+
+ cmp [capture_image_area_flag],1
+ je capture_image_area
+;-----------------------------------------------------
+ cmp [scroll_bar_data_vertical.delta2],0
+ jne .vertical
+.horizontal:
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ cmp eax,[scroll_bar_data_horizontal.cur_area]
+ jbe .vertical
+
+ push dword scroll_bar_data_horizontal
+ call [scrollbar_hor_mouse]
+
+ ; mouse_scroll_bar_horizontal scroll_bar_data_horizontal
+ cmp [scroll_bar_data_horizontal.redraw],0
+ je @f
+
+ mov [scroll_bar_data_horizontal.redraw],0
+ jmp .draw
+@@:
+ cmp [scroll_bar_data_horizontal.delta2],0
+ jne still
+;-----------------------------------------------------
+.vertical:
+ mov eax,[scroll_bar_data_vertical.max_area]
+ cmp eax,[scroll_bar_data_vertical.cur_area]
+ jbe .menu_bar
+
+ push dword scroll_bar_data_vertical
+ call [scrollbar_ver_mouse]
+
+; mouse_scroll_bar_vertical scroll_bar_data_vertical
+ cmp [scroll_bar_data_vertical.redraw],0
+ je .menu_bar ;still
+ mov [scroll_bar_data_vertical.redraw],0
+.draw:
+ call drawimage
+ jmp still
+;---------------------------------------------------
+.clear_mouse_keys_old:
+ xor eax,eax
+ mov [mouse_keys],eax
+ mov [mouse_keys_old],eax
+ ret
+;---------------------------------------------------
+.menu_bar:
+ cmp [scroll_bar_data_vertical.delta2],0
+ jne still
+ cmp [scroll_bar_data_horizontal.delta2],0
+ jne still
+; xor eax,eax
+; mov [menu_data_1.get_mouse_flag],eax
+; mov [menu_data_2.get_mouse_flag],eax
+; mov [menu_data_3.get_mouse_flag],eax
+; mov [menu_data_4.get_mouse_flag],eax
+; mov [menu_data_5.get_mouse_flag],eax
+; mov [menu_data_6.get_mouse_flag],eax
+
+.menu_bar_1:
+ call .set_mouse_flag
+@@:
+ push dword menu_data_1
+ call [menu_bar_mouse]
+; mouse_menubar menu_data_1
+ cmp [menu_data_1.click],dword 1
+ jne .menu_bar_2
+ call .clear_mouse_keys_old
+ cmp [menu_data_1.cursor_out],dword 0
+ jne analyse_out_menu_1
+ jmp .menu_bar_1
+;--------------------------------------------
+.menu_bar_2:
+; Edit
+ push dword menu_data_2
+ call [menu_bar_mouse]
+; mouse_menubar menu_data_2
+ cmp [menu_data_2.click],dword 1
+ jne .menu_bar_3
+ call .clear_mouse_keys_old
+ cmp [menu_data_2.cursor_out],dword 0
+ jne analyse_out_menu_2
+ jmp .menu_bar_1
+;--------------------------------------------
+.menu_bar_3:
+; View
+ push dword menu_data_3
+ call [menu_bar_mouse]
+; mouse_menubar menu_data_3
+ cmp [menu_data_3.click],dword 1
+ jne .menu_bar_4
+ call .clear_mouse_keys_old
+ cmp [menu_data_3.cursor_out],dword 0
+ jne analyse_out_menu_3 ;still
+ jmp .menu_bar_1
+;--------------------------------------------
+.menu_bar_4:
+; Zoom
+ push dword menu_data_4
+ call [menu_bar_mouse]
+; mouse_menubar menu_data_4
+ cmp [menu_data_4.click],dword 1
+ jne .menu_bar_5
+ call .clear_mouse_keys_old
+ cmp [menu_data_4.cursor_out],dword 0
+ jne analyse_out_menu_4
+ jmp .menu_bar_1
+;--------------------------------------------
+.menu_bar_5:
+; Tools
+ push dword menu_data_5
+ call [menu_bar_mouse]
+; mouse_menubar menu_data_5
+ cmp [menu_data_5.click],dword 1
+ jne .menu_bar_6
+ call .clear_mouse_keys_old
+ cmp [menu_data_5.cursor_out],dword 0
+ jne analyse_out_menu_5
+ jmp .menu_bar_1
+;--------------------------------------------
+.menu_bar_6:
+; Help
+ push dword menu_data_6
+ call [menu_bar_mouse]
+; mouse_menubar menu_data_6
+ cmp [menu_data_6.click],dword 1
+ jne .mouse_dinamic_button
+ call .clear_mouse_keys_old
+ cmp [menu_data_6.cursor_out],dword 0
+ jne analyse_out_menu_6
+ jmp .menu_bar_1
+;---------------------------------------------------
+.mouse_dinamic_button:
+; open file
+ push dword dinamic_button_data_1
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_1
+ mov eax,dinamic_button_data_1.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp kfile
+;-------------------------------------------------
+@@:
+; reload file
+ push dword dinamic_button_data_2
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_2
+ mov eax,dinamic_button_data_2.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp kopen
+;-------------------------------------------------
+@@:
+; left limit
+ push dword dinamic_button_data_3
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_3
+ mov eax,dinamic_button_data_3.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp left_limit
+;-------------------------------------------------
+@@:
+; left arrow
+ push dword dinamic_button_data_4
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_4
+ mov eax,dinamic_button_data_4.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp move_to_left
+;-------------------------------------------------
+@@:
+; slide show
+ push dword dinamic_button_data_5
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_5
+ mov eax,dinamic_button_data_5.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp slide_show.3
+;-------------------------------------------------
+@@:
+; right arrow
+ push dword dinamic_button_data_6
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_6
+ mov eax,dinamic_button_data_6.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp move_to_right
+;-------------------------------------------------
+@@:
+; right limit
+ push dword dinamic_button_data_7
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_7
+ mov eax,dinamic_button_data_7.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp right_limit
+;-------------------------------------------------
+@@:
+; zoom +
+ push dword dinamic_button_data_8
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_8
+ mov eax,dinamic_button_data_8.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp zoom_plus ;still
+;-------------------------------------------------
+@@:
+; zoom -
+ push dword dinamic_button_data_9
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_9
+ mov eax,dinamic_button_data_9.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp zoom_minus ;still
+;-------------------------------------------------
+@@:
+; zoom 100%
+ push dword dinamic_button_data_10
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_10
+ mov eax,dinamic_button_data_10.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp no_scaling ;still
+;-------------------------------------------------
+@@:
+; rotate clockwise
+ push dword dinamic_button_data_11
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_11
+ mov eax,dinamic_button_data_11.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp rotate_clockwise
+;-------------------------------------------------
+@@:
+; rotate counter-clockwise
+ push dword dinamic_button_data_12
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_12
+ mov eax,dinamic_button_data_12.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp rotate_counter_clockwise
+;-------------------------------------------------
+@@:
+; file information
+ push dword dinamic_button_data_13
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_13
+ mov eax,dinamic_button_data_13.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp kinfo
+;-------------------------------------------------
+@@:
+; wallpaper
+ push dword dinamic_button_data_14
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_14
+ mov eax,dinamic_button_data_14.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp k_background
+;-------------------------------------------------
+@@:
+; settings
+ push dword dinamic_button_data_15
+ call [dinamic_button_mouse]
+; mouse_dinamic_button dinamic_button_data_15
+ mov eax,dinamic_button_data_15.click
+ cmp [eax],dword 1
+ jne @f
+ mov [eax],dword 0
+ jmp k_option ;still
+;-------------------------------------------------
+@@:
+ jmp check_scroll_event
+; jmp still
+;---------------------------------------------------------------------
+.set_mouse_flag:
+ xor eax,eax
+ inc eax
+ mov [menu_data_1.get_mouse_flag],eax
+ mov [menu_data_2.get_mouse_flag],eax
+ mov [menu_data_3.get_mouse_flag],eax
+ mov [menu_data_4.get_mouse_flag],eax
+ mov [menu_data_5.get_mouse_flag],eax
+ mov [menu_data_6.get_mouse_flag],eax
+ ret
+;---------------------------------------------------------------------
+analyse_out_menu_1:
+; File
+ mov eax,[menu_data_1.cursor_out]
+ cmp eax,dword 1
+ je kfile
+ cmp eax,dword 2
+ je kinfo
+ cmp eax,dword 3
+ je START.exit
+ jmp still
+;---------------------------------------------------------------------
+analyse_out_menu_2:
+; Edit
+ mov eax,[menu_data_2.cursor_out]
+ cmp eax,dword 1
+ je rotate_clockwise
+ cmp eax,dword 2
+ je rotate_counter_clockwise
+ cmp eax,dword 3
+ je invert_left_to_right
+ cmp eax,dword 4
+ je invert_up_to_down
+ jmp still
+;---------------------------------------------------------------------
+analyse_out_menu_3:
+; View
+ mov eax,[menu_data_3.cursor_out]
+ cmp eax,dword 1
+ je k_sort_directory
+ cmp eax,dword 2
+ je full_screen
+ cmp eax,dword 3
+ je kopen
+ jmp still
+;---------------------------------------------------------------------
+analyse_out_menu_4:
+; Zoom
+ mov eax,[menu_data_4.cursor_out]
+ cmp eax,dword 1
+ je no_scaling
+ cmp eax,dword 2
+ je zoom_plus
+ cmp eax,dword 3
+ je zoom_minus
+ cmp eax,dword 4
+ je scaling
+ jmp still
+;---------------------------------------------------------------------
+analyse_out_menu_5:
+; Tools
+ mov eax,[menu_data_5.cursor_out]
+ cmp eax,dword 1
+ je image_editor
+ cmp eax,dword 2
+ je k_background
+ cmp eax,dword 3
+ je slide_show.3
+ cmp eax,dword 4
+ je k_option
+ jmp still
+;---------------------------------------------------------------------
+analyse_out_menu_6:
+; Help
+ cmp [menu_data_6.cursor_out],dword 1
+ je open_help
+ cmp [menu_data_6.cursor_out],dword 2
+ je kabout
+ jmp still
+;---------------------------------------------------------------------
+check_scroll_event:
+; jmp capture_image_area
+ mov eax,[mouse_scroll_data]
+ test eax,eax
+ jz capture_image_area ;still
+ test ax,0x8000
+ jnz .decr
+ shr eax,16
+ test ax,0x8000
+ jnz .decr_1
+ pusha
+ mov eax,[scaling_mode]
+ test eax,eax
+ jnz .continue_1
+ call calculation_next_value_minus
+ mov [calc_next_value_minus],1
+.continue_1:
+ popa
+ mov eax,zoom_factors
+ cmp [eax],dword zoom_factors.min
+ jbe still
+ xor ecx,ecx
+ mov cx,[mouse_scroll_data.vertical]
+ test ecx,ecx
+ jnz @f
+ mov cx,[mouse_scroll_data.horizontal]
+ test ecx,ecx
+ jz still
+@@:
+;----------------------------------------
+ cmp [calc_next_value_minus],1
+ jne @f
+ mov [calc_next_value_minus],0
+ dec ecx
+ jz zoom_plus.1
+@@:
+ mov ebx,4
+@@:
+ cmp [eax],dword zoom_factors.min
+ jbe @f
+ sub [eax],ebx
+ dec ecx
+ jnz @r
+ jmp zoom_plus.1
+@@:
+ mov [eax],dword zoom_factors.min
+ jmp zoom_plus.1
+;----------------------------------------
+.decr:
+ xor ebx,ebx
+ mov bx,[mouse_scroll_data.vertical]
+ jmp @f
+.decr_1:
+ xor ebx,ebx
+ mov bx,[mouse_scroll_data.horizontal]
+@@:
+ pusha
+ mov eax,[scaling_mode]
+ test eax,eax
+ jnz .continue_2
+ call calculation_next_value_plus
+ mov [calc_next_value_plus],1
+.continue_2:
+ popa
+ mov eax,zoom_factors
+ cmp [eax],dword zoom_factors.max
+ jae still
+ mov ecx,0xffff
+ sub ecx,ebx
+ inc ecx
+;---------------------------------------
+ cmp [calc_next_value_plus],1
+ jne @f
+ mov [calc_next_value_plus],0
+ dec ecx
+ jz zoom_plus.1
+@@:
+ mov ebx,4
+@@:
+ cmp [eax],dword zoom_factors.max
+ jae @f
+ add [eax],ebx
+ dec ecx
+ jnz @r
+ jmp zoom_plus.1
+@@:
+ mov [eax],dword zoom_factors.max
+ jmp zoom_plus.1
+;---------------------------------------------------------------------
+capture_image_area:
+ cmp [scroll_bar_data_vertical.delta2],0
+ jne .no_capture
+ cmp [scroll_bar_data_horizontal.delta2],0
+ jne .no_capture
+ xor eax,eax
+ mov [draw_scrollbar_counter],eax
+ mov eax,[scroll_bar_data_vertical.max_area]
+ cmp eax,[scroll_bar_data_vertical.cur_area]
+ jbe @f
+ inc [draw_scrollbar_counter]
+@@:
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ cmp eax,[scroll_bar_data_horizontal.cur_area]
+ jbe @f
+ inc [draw_scrollbar_counter]
+@@:
+ cmp [draw_scrollbar_counter],0
+ je still
+
+ mov eax,[mouse_position]
+ xor ebx,ebx
+ mov bx,ax ; EBX mouse y
+ shr eax,16 ; EAX mouse x
+
+ mov ecx,[image_start_coordinates]
+ xor edx,edx
+ mov dx,cx ; EDX start y
+ shr ecx,16 ; ECX start x
+
+ cmp ax,cx
+ jb still ; min x
+
+ cmp bx,dx
+ jb still ; min y
+
+ add cx,[wa_width_2]
+ cmp ax,cx
+ ja still ; max x
+
+ add dx,[wa_high_2]
+ cmp bx,dx
+ ja still ; max y
+
+ mov ecx,[mouse_keys]
+ test ecx,1b ; left button
+ jz .no_capture ;still
+
+ mov ecx,[mouse_keys_old]
+ test ecx,1b ; left button old
+ jz .no_capture ;still
+
+ mov [capture_image_area_flag],1
+
+ mov ecx,[mouse_position_old]
+ xor edx,edx
+ mov dx,cx ; EDX mouse y old
+ shr ecx,16 ; ECX mouse x old
+
+ cmp eax,ecx
+ je .y
+ ja @f
+ sub ecx,eax
+ add [scroll_bar_data_horizontal.position],ecx
+ jmp .y
+@@:
+ sub eax,ecx
+ cmp eax,[scroll_bar_data_horizontal.position]
+ jb @f
+ xor eax,eax
+ mov [scroll_bar_data_horizontal.position],eax
+ jmp .y
+@@:
+ sub [scroll_bar_data_horizontal.position],eax
+
+.y:
+ cmp ebx,edx
+ je .draw
+ ja @f
+ sub edx,ebx
+ add [scroll_bar_data_vertical.position],edx
+ jmp .draw
+@@:
+ sub ebx,edx
+
+ cmp ebx,[scroll_bar_data_vertical.position]
+ jb @f
+ xor eax,eax
+ mov [scroll_bar_data_vertical.position],eax
+ jmp .draw
+@@:
+ sub [scroll_bar_data_vertical.position],ebx
+
+.draw:
+ call drawimage
+ call draw_scrollbars
+ jmp still
+
+.no_capture:
+ mov [capture_image_area_flag],0
+.end:
+ jmp still
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/bmp/build.bat b/programs/media/zsea/plugins/bmp/build.bat
new file mode 100644
index 0000000000..b024f4a47e
--- /dev/null
+++ b/programs/media/zsea/plugins/bmp/build.bat
@@ -0,0 +1,3 @@
+@fasm -m 16384 cnv_bmp.asm cnv_bmp.obj
+@kpack cnv_bmp.obj
+@pause
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/bmp/build.sh b/programs/media/zsea/plugins/bmp/build.sh
new file mode 100644
index 0000000000..4897e7722b
--- /dev/null
+++ b/programs/media/zsea/plugins/bmp/build.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# This script does for Linux the same as build.bat for DOS,
+# it compiles the current KolibriOS applications
+
+ fasm -m 16384 cnv_bmp.asm cnv_bmp.obj
+ kpack cnv_bmp.obj
+ exit 0
+
+
+
diff --git a/programs/media/zsea/plugins/bmp/cnv_bmp.asm b/programs/media/zsea/plugins/bmp/cnv_bmp.asm
new file mode 100644
index 0000000000..46a0a106ea
--- /dev/null
+++ b/programs/media/zsea/plugins/bmp/cnv_bmp.asm
@@ -0,0 +1,660 @@
+;*****************************************************************************
+; BMP to RAW convert plugin - for zSea image viewer
+; Copyright (c) 2008-2011, Marat Zakiyanov aka Mario79, aka Mario
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;*****************************************************************************
+
+format MS COFF
+
+public EXPORTS
+
+section '.flat' code readable align 16
+
+;include 'macros.inc'
+include '../../../../macros.inc'
+;---------------------------------------------------------------------
+START:
+ pushad
+ mov eax,dword [esp+36]
+ call .check_header
+ je @f
+.no_bmp_file:
+ xor eax,eax
+ mov [raw_area],eax
+ inc eax ; data corrupt eax = 1
+ jmp .ret
+
+.check_header:
+ mov [pointer],eax
+ mov eax,[eax]
+ mov [image_file],eax
+ cmp [eax],word 'BM'
+ ret
+;---------------------------------------------------------------------
+@@:
+ mov [MinusHeight],byte 0
+ mov edx,[eax+22]
+ test edx,0x80000000
+ jz @f
+ neg edx
+ mov [eax+22],edx
+ mov [MinusHeight],byte 1
+@@:
+ xor edx,edx
+ mov dx,[eax+28] ; color resolution 1,4,8,16,24,32 bits
+; mov [ebx+16],edx ; store resolution BMP
+ mov [resolution],edx
+ mov ecx,[eax+30]
+ mov [compression],ecx
+;---------------------------------------------------------------------
+ mov ecx,[eax+18] ; width BMP
+ imul ecx,edx ;[resolution]
+ mov edi,ecx
+ shr ecx,3
+ test edi,7
+ jz @f
+ inc ecx
+@@:
+ imul ecx,[eax+22] ; size of pixels data area
+;---------------------------------------------------------------------
+ cmp edx,16
+ jae .get_memory ; no palette
+
+ mov eax,4
+ xchg cl,dl
+ shl eax,cl
+ xchg cl,dl
+ add ecx,eax ; palette size
+;---------------------------------------------------------------------
+.get_memory:
+ add ecx,44 ; header
+ mcall 68,12
+ cmp eax,0
+ jne @f
+ xor eax,eax
+ mov [raw_area],eax
+ mov eax,2 ; not enough memory
+ jmp .ret
+@@:
+ mov [raw_area],eax
+;---------------------------------------------------------------------
+ mov edi,eax
+ xor eax,eax
+ shr ecx,2
+ cld
+ rep stosd ; clear memory
+;---------------------------------------------------------------------
+; Create RAW header
+;---------------------------------------------------------------------
+ mov eax,[raw_area]
+ mov [eax],dword 'RAW '
+ mov ebx,[image_file]
+;---------------------------------------------------------------------
+ mov ecx,[ebx+18] ; width BMP
+ mov [eax+4],ecx ; width RAW
+;---------------------------------------------------------------------
+ mov ecx,[ebx+22] ; high BMP
+ mov [eax+8],ecx ; high RAW
+;---------------------------------------------------------------------
+ mov ecx,[resolution] ; color resolution BMP
+ mov [eax+12],ecx ; color resolution RAW
+;---------------------------------------------------------------------
+ mov ecx,[resolution]
+ cmp ecx,16
+ jb .1
+ push eax
+ mov eax,ecx
+ mov ecx,3
+ xor edx,edx
+ div ecx
+ cmp eax,8
+ jbe @f
+ mov eax,8
+@@:
+ mov ecx,eax
+ pop eax
+.1:
+ mov [eax+16],cx ; channel color resolution RAW
+;---------------------------------------------------------------------
+ mov ecx,[resolution]
+ cmp ecx,16
+ jae @f
+ mov [eax+18],word 1 ; channels amount RAW
+ jmp .2
+@@:
+ mov [eax+18],word 3 ; channels amount RAW
+.2:
+;---------------------------------------------------------------------
+ xor edx,edx
+ cmp ecx,16
+ jae @f
+ add edx,44
+@@:
+ mov [eax+20],edx ; palette pointer (offset from file start)
+;---------------------------------------------------------------------
+ mov ecx,[resolution]
+ cmp ecx,16
+ jae @f
+ mov ecx,[resolution]
+ push eax
+ mov eax,1
+ shl eax,cl
+ mov ecx,eax
+ pop eax
+ shl ecx,2
+ jmp .3
+@@:
+ xor ecx,ecx
+.3:
+ mov [eax+24],ecx ; palette area size
+;---------------------------------------------------------------------
+ add ecx,dword 44
+ mov [eax+28],ecx ; pixels pointer (offset from file start)
+;---------------------------------------------------------------------
+ mov ecx,[ebx+18] ; width BMP
+ imul ecx,[resolution]
+ mov edi,ecx
+ shr ecx,3
+ test edi,7
+ jz @f
+ inc ecx
+@@:
+ imul ecx,[ebx+22] ; high BMP
+ mov [eax+32],ecx ; pixels area size
+;---------------------------------------------------------------------
+ xor ecx,ecx ; Stub!!!
+ mov [eax+36],ecx ; Transparency pointer (offset from file start)
+ mov [eax+40],ecx ; Transparency area size
+
+;---------------------------------------------------------------------
+; Finish create RAW header
+;---------------------------------------------------------------------
+; mov ebx,[pointer]
+; mov [ebx+4],eax ; store [soi] pointer of image area
+; mov ecx,eax
+.convert:
+ cmp [resolution],16
+ jae .no_palette
+; mov [ebx+24],eax
+; mov edi,eax
+ mov edi,[raw_area]
+ mov edi,[edi+20] ; palette pointer (offset from file start)
+ add edi,[raw_area]
+ mov esi,[image_file]
+ add esi,54
+ mov ecx,[resolution]
+ mov eax,1
+ shl eax,cl
+ mov ecx,eax
+ rep movsd
+
+; mov [ebx+4],edi ; store [soi] pointer of image area
+.no_palette:
+ mov ecx,[raw_area]
+ mov ecx,[ecx+28] ; pixels pointer (offset from file start)
+ add ecx,[raw_area]
+;---------------------------------------------------------------------
+ mov eax,[image_file]
+ mov ebp,[eax+18] ; width BMP
+; mov [ebx+8],ebp ; store width
+ imul ebp,[resolution]
+ mov edi,ebp
+ shr ebp,3 ; ebp = size of output scanline
+ test edi,7
+ jz @f
+ inc ebp
+@@:
+ mov eax,[eax+22] ; high BMP
+; mov [ebx+12],eax ; store high
+ dec eax
+ mul ebp
+ add eax,ecx
+
+ mov edi,ecx
+ mov bl,[MinusHeight]
+ test bl,bl
+ jnz @f
+ mov edi,eax ; edi points to last scanline
+@@:
+ mov esi,[image_file]
+ add esi,[esi+10] ; start of pixels data
+ mov ebx,[image_file]
+ mov edx,[ebx+22] ; high BMP
+ add ebx,54
+ lea eax,[ebp*2]
+ mov [delta],eax
+ test edx,edx
+ jz .ret
+ jns @f
+ neg edx
+ and [delta], 0
+ mov edi,ecx
+@@:
+;---------------------------------------------------------------------
+ cmp [compression],3
+ je .BI_BITFIELDS ; @f
+ cmp [compression],2
+ je RLE4
+ cmp [compression],1
+ je RLE8
+ cmp [compression],0
+ je @f
+ jmp .no_bmp_file
+;---------------------------------------------------------------------
+@@:
+ cmp [resolution],16
+ jne .continue
+ mov ebx,[raw_area]
+ mov [ebx+12],dword 15
+ jmp .continue
+;---------------------------------------------------------------------
+.BI_BITFIELDS:
+ cmp [resolution],32
+ je .32
+ cmp [resolution],16
+ jne .continue
+ mov ebx,[raw_area]
+ mov eax,[image_file]
+ cmp [eax+54],dword 0x7C00
+ jne @f
+ mov [ebx+12],dword 15
+ jmp .continue
+;---------------------------------------------------------------------
+@@:
+ cmp [eax+54],dword 0xF800
+ jne @f
+ mov [ebx+12],dword 16
+ jmp .continue
+;---------------------------------------------------------------------
+@@:
+ cmp [eax+54],dword 0xF00
+ jne .no_bmp_file ; @f
+ mov [ebx+12],dword 15
+
+@@:
+ mov ebx,ebp
+ neg ebx
+ and ebx,3
+ mov [aligner],ebx
+ shr ebp,1
+ mov cl,[MinusHeight]
+ test cl,cl
+ jnz .start_16_1
+align 4
+.start_16:
+ mov ecx,ebp
+ call .process_16b_x4r4g4b4
+ sub edi,[delta]
+ add esi,[aligner]
+ dec edx
+ jnz .start_16
+ jmp .ret_ok
+;---------------------------------------------------------------------
+.process_16b_x4r4g4b4:
+ cld
+@@:
+ lodsw
+ xor ebx,ebx
+ mov bx,ax
+ xor eax,eax
+ ror ebx,8
+ and bl,0xf
+ mov al,bl
+ shl eax,6
+ rol ebx,4
+ and bx,0xf
+ shl bl,1
+ add ax,bx
+ shl eax,5
+ rol ebx,4
+ and bx,0xf
+ shl bl,1
+ add ax,bx
+ stosw
+ dec ecx
+ jnz @r
+ ret
+;---------------------------------------------------------------------
+.start_16_1: ;negative value of Height
+ mov ecx,ebp
+ call .process_16b_x4r4g4b4
+ add esi,[aligner]
+ dec edx
+ jnz .start_16_1
+ jmp .ret_ok
+;---------------------------------------------------------------------
+.32:
+ mov eax,[image_file]
+ cmp [eax+54],dword 0xFF000000
+ jne .no_bmp_file
+ shr ebp,2
+
+ mov al,[MinusHeight]
+ test al,al
+ jnz .start_32_1
+align 4
+.start_32:
+ mov ecx,ebp
+@@:
+ cld
+ lodsd
+ shr eax,8
+ stosd
+ dec ecx
+ jnz @r
+ sub edi,[delta]
+ dec edx
+ jnz .start_32
+ jmp .ret_ok
+;---------------------------------------------------------------------
+.start_32_1: ;negative value of Height
+ mov ecx,ebp
+ imul ecx,edx
+@@:
+ cld
+ lodsd
+ shr eax,8
+ stosd
+ dec ecx
+ jnz @r
+ jmp .ret_ok
+;---------------------------------------------------------------------
+.continue:
+ mov eax,ebp
+ neg eax
+ and eax,3
+ mov cl,[MinusHeight]
+ test cl,cl
+ jz .start_24
+ cld
+align 4
+@@: ;negative value of Height
+ mov ecx,ebp
+ rep movsb
+ add esi,eax
+ dec edx
+ jnz @r
+ jmp .ret_ok
+;---------------------------------------------------------------------
+align 4
+.start_24:
+@@:
+ mov ecx,ebp
+ rep movsb
+ sub edi,[delta]
+ add esi,eax
+ dec edx
+ jnz .start_24 ; @r
+.ret_ok:
+ mov eax,0 ; convert OK
+.ret:
+ mov ebx,[pointer]
+ mov [ebx+8],eax ; store return code
+ mov eax,[raw_area]
+ mov [ebx+4],eax ; store RAW pointer
+ popad
+ ret 4
+;---------------------------------------------------------------------
+RLE4:
+ cmp [resolution],4
+ jne START.no_bmp_file
+ xor ebx,ebx
+ xor edx,edx
+align 4
+.start:
+ cld
+ lodsb
+ cmp al,0
+ jnz .Encoded_Mode
+ cld
+ lodsb
+ cmp al,0
+ jz .end_line
+ cmp al,1
+ jz START.ret_ok ; .end_bitmap
+ cmp al,2
+ jz .Delta
+
+.Absolute_Mode:
+ xor ecx,ecx
+ mov cl,al
+ add ebx,ecx
+ cmp dl,0
+ je @f
+ mov dh,[esi]
+ shr dh,4
+ mov dl,[edi-1]
+ and dl,11110000b
+ add dl,dh
+ mov [edi-1],dl
+ dec ecx
+ xor edx,edx
+ mov dh,1
+@@:
+ test cl,1b
+ jz @f
+ inc ecx
+ inc edx
+@@:
+ shr ecx,1
+ cmp dh,1
+ je .1
+ mov eax,ecx
+ cld
+ rep movsb
+ test eax,1b
+ jz @f
+ inc esi
+@@:
+ jmp .start
+;---------------------------------------------------------------------
+.1:
+ mov dh,cl
+@@:
+ cld
+ lodsb
+ mov ah,[esi]
+ shl al,4
+ shr ah,4
+ add al,ah
+ cld
+ stosb
+ dec ecx
+ jnz @r
+ test dh,1b
+ jz @f
+ inc esi
+@@:
+ xor dh,dh
+ jmp .start
+;---------------------------------------------------------------------
+.Encoded_Mode:
+ xor ecx,ecx
+ mov cl,al
+ add ebx,ecx
+ cld
+ lodsb
+ cmp dl,0
+ je @f
+ rol al,4
+ mov dh,al
+ and dh,00001111b
+ mov dl,[edi-1]
+ and dl,11110000b
+ add dl,dh
+ mov [edi-1],dl
+ dec ecx
+ xor edx,edx
+@@:
+ test cl,1b
+ jz @f
+ inc ecx
+ inc edx
+@@:
+ shr ecx,1
+ cld
+ rep stosb
+ cmp dl,0
+ je @f
+ mov al,[edi-1]
+ and al,11110000b
+ mov [edi-1],al
+@@:
+ jmp .start
+;---------------------------------------------------------------------
+.Delta:
+ xor eax,eax
+ cld
+ lodsb
+ add ebx,eax
+ cmp dl,0
+ je @f
+ dec eax
+ xor edx,edx
+@@:
+ test al,1b
+ jz @f
+ inc eax
+ inc edx
+@@:
+ shr eax,1
+ add edi,eax
+ cld
+ lodsb
+ imul eax,ebp
+ sub edi,eax
+ jmp .start
+;---------------------------------------------------------------------
+.end_line:
+ mov eax,ebp
+ test ebx,1b
+ jz @f
+ inc ebx
+@@:
+ shr ebx,1
+ sub eax,ebx
+ add edi,eax
+ sub edi,[delta]
+ xor ebx,ebx
+ xor edx,edx
+ jmp .start
+;---------------------------------------------------------------------
+RLE8:
+ cmp [resolution],8
+ jne START.no_bmp_file
+ xor ebx,ebx
+align 4
+.start:
+ cld
+ lodsb
+ cmp al,0
+ jnz .Encoded_Mode
+ cld
+ lodsb
+ cmp al,0
+ jz .end_line
+ cmp al,1
+ jz START.ret_ok ; .end_bitmap
+ cmp al,2
+ jz .Delta
+
+.Absolute_Mode:
+ xor ecx,ecx
+ mov cl,al
+ add ebx,ecx
+ mov eax,ecx
+ cld
+ rep movsb
+ test eax,1b
+ jz @f
+ inc esi
+@@:
+ jmp .start
+;---------------------------------------------------------------------
+.Encoded_Mode:
+ xor ecx,ecx
+ mov cl,al
+ add ebx,ecx
+ cld
+ lodsb
+ rep stosb
+ jmp .start
+;---------------------------------------------------------------------
+.Delta:
+ xor eax,eax
+ cld
+ lodsb
+ add edi,eax
+ add ebx,eax
+ cld
+ lodsb
+ imul eax,ebp
+ sub edi,eax
+ jmp .start
+;---------------------------------------------------------------------
+.end_line:
+ mov eax,ebp
+ sub eax,ebx
+ add edi,eax
+ xor ebx,ebx
+ sub edi,[delta]
+ jmp .start
+;---------------------------------------------------------------------
+Check_Header:
+ pushad
+ mov eax,dword [esp+36]
+ call START.check_header
+ jne START.no_bmp_file
+ popad
+ ret 4
+;---------------------------------------------------------------------
+Associations:
+ dd Associations.end - Associations
+ db 'BMP',0
+.end:
+ db 0
+;---------------------------------------------------------------------
+align 16
+EXPORTS:
+ dd szStart, START
+ dd szVersion, 0x00010002
+ dd szCheck, Check_Header
+ dd szAssoc, Associations
+ dd 0
+
+pointer dd 0
+image_file dd 0
+delta dd 0
+aligner dd 0
+resolution dd 0
+compression dd 0
+raw_area dd 0
+MinusHeight db 0
+
+szStart db 'START',0
+szVersion db 'version',0
+szCheck db 'Check_Header',0
+szAssoc db 'Associations',0
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/convert/build.bat b/programs/media/zsea/plugins/convert/build.bat
new file mode 100644
index 0000000000..2d3ab7d7f2
--- /dev/null
+++ b/programs/media/zsea/plugins/convert/build.bat
@@ -0,0 +1,3 @@
+@fasm -m 16384 convert.asm convert.obj
+@kpack convert.obj
+@pause
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/convert/build.sh b/programs/media/zsea/plugins/convert/build.sh
new file mode 100644
index 0000000000..1db4896ffd
--- /dev/null
+++ b/programs/media/zsea/plugins/convert/build.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# This script does for Linux the same as build.bat for DOS,
+# it compiles the current KolibriOS applications
+
+ fasm -m 16384 convert.asm convert.obj
+ kpack convert.obj
+ exit 0
+
+
+
diff --git a/programs/media/zsea/plugins/convert/convert.asm b/programs/media/zsea/plugins/convert/convert.asm
new file mode 100644
index 0000000000..c82e17bff5
--- /dev/null
+++ b/programs/media/zsea/plugins/convert/convert.asm
@@ -0,0 +1,496 @@
+;*****************************************************************************
+; RAW to RAW convert plugin - for zSea image viewer
+; Copyright (c) 2008-2011, Marat Zakiyanov aka Mario79, aka Mario
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;*****************************************************************************
+
+; Convert:
+; 16b in 8b
+; 1b,2b,3b in 8b
+
+format MS COFF
+
+public EXPORTS
+
+section '.flat' code readable align 16
+
+;include 'macros.inc'
+include '../../../../macros.inc'
+;---------------------------------------------------------------------
+START:
+ pushad
+ mov [pointer],eax
+ mov eax,[eax+4]
+ mov [image_file],eax
+ mov esi,[eax+28]
+ add esi,eax
+ mov edi,esi
+ mov ecx,[eax+32]
+; xor ebx,ebx
+; mov [raw_area],ebx
+
+; mov ebx,[pointer]
+; movzx eax,word [eax+18]
+; mov [ebx+24],eax
+; jmp .ret_ok
+
+ cmp [eax+16],word 16
+ je .16b
+ cmp [eax+12],dword 1
+ je .1b
+ cmp [eax+12],dword 2
+ je .2b
+ cmp [eax+12],dword 4
+ je .4b
+;---------------------------------------------------------------------
+.ret_ok:
+; mov ebx,[pointer]
+; mov eax,[raw_area]
+; mov [ebx+20],eax ; store RAW pointer
+; mov [ebx+24],ecx
+
+ mov ebx,[image_file]
+ cmp [ebx+18],word 2
+ jne @f
+ mov eax,[ebx+12]
+ shr eax,1
+ mov [ebx+12],eax
+@@:
+
+ popad
+ ret
+;---------------------------------------------------------------------
+.less_8b:
+ mov edx,[image_file]
+ mov ecx,[area_size]
+ add ecx,[edx+28]
+ mcall 68,20
+ mov [image_file],eax
+
+
+ mov ecx,[area_size]
+ mov eax,ecx
+ shr ecx,2
+ test eax,3
+ jz @f
+ inc ecx
+@@:
+ mov esi,[raw_area]
+ mov edi,[image_file]
+ add edi,[edi+28]
+ cld
+ rep movsd
+
+ mov ecx,[raw_area]
+ mcall 68,13
+ mov eax,[image_file]
+ mov ebx,[pointer]
+ mov [ebx+4],eax
+ popad
+ ret
+;---------------------------------------------------------------------
+.16b:
+ cmp [eax+18],word 3
+ je @f ;.convert_16_in_8
+ cmp [eax+18],word 4
+ jne .16b_1
+@@:
+ xor ebx,ebx
+ mov bx,[eax+18]
+
+ xchg eax,ecx
+ xor edx,edx
+ div ebx
+ xchg ecx,eax
+
+ shr ecx,1
+
+ mov [eax+16],word 8
+ mov ebx,[eax+12]
+ shr ebx,1
+ mov [eax+12],ebx
+
+ mov ebx,eax
+; jmp .ret_ok
+
+.convert_16_in_8: ; converting 16 bit sample to 8 bit
+ cld
+ lodsw
+ mov al,ah
+ stosb
+
+ lodsw
+ mov al,ah
+ stosb
+
+ lodsw
+ mov al,ah
+ stosb
+
+ cmp [ebx+18],word 4
+ jne @f
+ lodsw
+ mov al,ah
+ stosb
+@@:
+ dec ecx
+ jnz .convert_16_in_8
+ jmp .16b_end
+;---------------------------------------------------------------------
+.16b_1:
+ cmp [eax+18],word 1
+ je @f ;.convert_16_in_8_1
+ cmp [eax+18],word 2
+ jne .16b_end
+@@:
+ shr ecx,1
+
+ mov [eax+16],word 8
+ mov ebx,[eax+12]
+ shr ebx,1
+ mov [eax+12],ebx
+
+.convert_16_in_8_1:
+ cld
+ lodsw
+; shr ax,8
+; mov al,ah
+ stosb
+ dec ecx
+ jnz .convert_16_in_8_1
+;---------------------------------------------------------------------
+.16b_end:
+ xor eax,eax
+ mov [raw_area],eax
+ jmp .ret_ok
+;---------------------------------------------------------------------
+.4b:
+ call .get_memory
+ mov edx,ebx
+ inc ebx
+ shr ebx,1
+.4b_1:
+ push ebx edi
+@@:
+ cld
+ lodsb
+ shl eax,8
+ mov al,ah
+ and ah,0xf
+ shr al,4
+ stosw
+
+ dec ebx
+ jnz @b
+ pop edi ebx
+ add edi,edx
+ dec ecx
+ jnz .4b_1
+
+ jmp .less_8b ;.ret_ok
+;---------------------------------------------------------------------
+.2b:
+ call .get_memory
+; jmp .ret_ok
+; shr ecx,1
+ mov edx,ebx
+ mov eax,ebx
+ shr ebx,2
+ test eax,3
+ jz @f
+ inc ebx
+@@:
+ mov ebp,ebx
+.2b_1:
+ push ebp edi
+@@:
+ cld
+ lodsb
+
+ mov bl,al
+
+ and al,11b
+ shl ax,8
+
+ mov al,bl
+ shr al,2
+ and al,11b
+ shl eax,8
+
+ mov al,bl
+ shr al,4
+ and al,11b
+ shl eax,8
+
+ mov al,bl
+ shr al,6
+ and al,11b
+
+ stosd
+
+ dec ebp
+ jnz @b
+ pop edi ebp
+
+ add edi,edx
+ dec ecx
+ jnz .2b_1
+
+ jmp .less_8b ;.ret_ok
+;---------------------------------------------------------------------
+.1b:
+ call .get_memory
+ mov edx,ebx
+ mov eax,ebx
+ shr ebx,3
+ test eax,7
+ jz @f
+ inc ebx
+@@:
+ mov ebp,ebx
+.1b_1:
+ push ebp edi
+@@:
+ cld
+ lodsb
+
+ mov bl,al
+ shr al,4
+ and al,1b
+ shl ax,8
+
+ mov al,bl
+ shr al,5
+ and al,1b
+ shl eax,8
+
+ mov al,bl
+ shr al,6
+ and al,1b
+ shl eax,8
+
+ mov al,bl
+ shr al,7
+; and al,1b
+; shl eax,8
+
+ stosd
+
+ mov al,bl
+ and al,1b
+ shl ax,8
+
+ mov al,bl
+ shr al,1
+ and al,1b
+ shl eax,8
+
+ mov al,bl
+ shr al,2
+ and al,1b
+ shl eax,8
+
+ mov al,bl
+ shr al,3
+ and al,1b
+
+ stosd
+
+ dec ebp
+ jnz @b
+ pop edi ebp
+
+ add edi,edx
+ dec ecx
+ jnz .1b_1
+ jmp .less_8b ;.ret_ok
+;---------------------------------------------------------------------
+.get_memory:
+ mov ebx,dword 8
+ mov [eax+16],bx
+ mov [eax+12],ebx
+; mov esi,[eax+28]
+; add esi,eax
+; push ecx
+ mov ecx,[eax+4]
+ imul ecx,[eax+8]
+ push eax
+ mov [area_size],ecx
+ mcall 68,12
+; pop ecx
+ mov [raw_area],eax
+ mov edi,eax
+ pop eax
+ mov ebx,[eax+4]
+ mov ecx,[eax+8]
+ ret
+;---------------------------------------------------------------------
+Convert24b:
+ pushad
+ mov [pointer],eax
+ mov eax,[eax+4]
+ mov [image_file],eax
+
+ mov esi,[eax+28]
+ add esi,eax
+
+ mov ebp,[eax+20]
+ add ebp,eax
+
+ mov ecx,[eax+4]
+ imul ecx,[eax+8]
+ push eax ecx
+ lea ecx,[ecx*3]
+ mcall 68,12
+ mov [raw_area],eax
+ mov edi,eax
+ pop ecx eax
+
+ cmp [eax+12],dword 32
+ je .32b
+ cmp [eax+12],dword 16
+ je .16b
+ cmp [eax+12],dword 15
+ je .15b
+ cmp [eax+12],dword 8
+ je .8b
+
+.ret_ok:
+ mov ebx,[pointer]
+ mov eax,[raw_area]
+ mov [ebx+20],eax ; store RAW pointer
+ popad
+ ret
+
+;---------------------------------------------------------------------
+.32b:
+ cld
+ lodsd
+
+ stosw
+ shr eax,16
+ stosb
+
+ dec ecx
+ jnz .32b
+
+ jmp .ret_ok
+;---------------------------------------------------------------------
+.16b:
+ cld
+ lodsw
+
+ xor ebx,ebx
+ ror ax,11
+ mov bl,al
+ and bl,11111b
+ shl bl,3
+ shl ebx,8
+ rol ax,6
+ mov bl,al
+ and bl,111111b
+ shl bl,2
+ shl ebx,8
+ rol ax,5
+ mov bl,al
+ and bl,11111b
+ shl bl,3
+ mov eax,ebx
+
+ cld
+ stosw
+ shr eax,16
+ stosb
+
+ dec ecx
+ jnz .16b
+
+ jmp .ret_ok
+;---------------------------------------------------------------------
+.15b:
+ cld
+ lodsw
+
+ xor ebx,ebx
+ ror ax,10
+ mov bl,al
+ and bl,11111b
+ shl bl,3
+ shl ebx,8
+ rol ax,5
+ mov bl,al
+ and bl,11111b
+ shl bl,3
+ shl ebx,8
+ rol ax,5
+ mov bl,al
+ and bl,11111b
+ shl bl,3
+ mov eax,ebx
+
+ cld
+ stosw
+ shr eax,16
+ stosb
+
+ dec ecx
+ jnz .15b
+
+ jmp .ret_ok
+;---------------------------------------------------------------------
+.8b:
+ xor eax,eax
+ cld
+ lodsb
+ shl eax,2
+ mov eax,[eax+ebp]
+
+ cld
+ stosw
+ shr eax,16
+ stosb
+
+ dec ecx
+ jnz .8b
+
+ jmp .ret_ok
+;---------------------------------------------------------------------
+align 16
+EXPORTS:
+ dd szStart, START
+ dd szVersion, 0x00010001
+ dd szConv_24b, Convert24b
+ dd 0
+
+szStart db 'START',0
+szVersion db 'version',0
+szConv_24b db 'Convert24b',0
+pointer dd 0
+image_file dd 0
+;delta dd 0
+;resolution dd 0
+;compression dd 0
+raw_area dd 0
+area_size dd 0
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/gif/build.bat b/programs/media/zsea/plugins/gif/build.bat
new file mode 100644
index 0000000000..fd251be2eb
--- /dev/null
+++ b/programs/media/zsea/plugins/gif/build.bat
@@ -0,0 +1,3 @@
+@fasm -m 16384 cnv_gif.asm cnv_gif.obj
+@kpack cnv_gif.obj
+@pause
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/gif/build.sh b/programs/media/zsea/plugins/gif/build.sh
new file mode 100644
index 0000000000..844984a50a
--- /dev/null
+++ b/programs/media/zsea/plugins/gif/build.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# This script does for Linux the same as build.bat for DOS,
+# it compiles the current KolibriOS applications
+
+ fasm -m 16384 cnv_gif.asm cnv_gif.obj
+ kpack cnv_gif.obj
+ exit 0
+
+
+
diff --git a/programs/media/zsea/plugins/gif/cnv_gif.asm b/programs/media/zsea/plugins/gif/cnv_gif.asm
new file mode 100644
index 0000000000..f54174b643
--- /dev/null
+++ b/programs/media/zsea/plugins/gif/cnv_gif.asm
@@ -0,0 +1,534 @@
+;*****************************************************************************
+; GIF to RAW1 convert plugin - for zSea image viewer
+; Copyright (c) 2009, Evgeny Grechnikov aka Diamond
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Evgeny Grechnikov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;*****************************************************************************
+; Based on gif_lite.inc (c) Ivuskin Andrey aka Willow and Diamond 2004-2007
+;*****************************************************************************
+; Some small changes (c) 2011 Marat Zakiyanov aka Mario79, aka Mario
+;*****************************************************************************
+
+format MS COFF
+
+public EXPORTS
+
+section '.flat' code readable align 16
+
+START:
+ pushad
+ mov eax,dword [esp+36]
+ mov esi, [eax] ; esi -> GIF data
+ mov ebp, [eax+12] ; ebp = file size
+ xor ebx, ebx ; ebx -> list of images, not allocated yet
+ call check_header_1
+ jz ReadGIF
+ReadGIF.end:
+; general exit from the function
+ xor eax, eax
+ cmp ebx, eax
+ jz .bad
+ cmp dword [ebx+4], eax
+ jnz ReadGIF.ret
+ mov ecx, ebx
+ push 68
+ pop eax
+ push 13
+ pop ebx
+ int 40h
+ xor ebx, ebx
+.bad:
+ inc eax ; bad image
+ReadGIF.ret:
+ mov ecx, [esp+28]
+ mov [ecx+4], ebx ; save RAW data ptr
+ mov [ecx+8], eax ; save result
+ popad
+ ret 4
+ReadGIF.animated.ret:
+ mov ebx, [ReadGIF.gifList]
+ jmp ReadGIF.ret
+_null fix 0x1000
+ReadGIF:
+; allocate one page for list of images
+ mov ecx, 0x1000
+ push 68
+ pop eax
+ push 12
+ pop ebx
+ int 40h
+ xchg eax, ebx
+ test ebx, ebx
+ jnz @f
+ mov al, 2 ; no memory
+ jmp .ret
+@@:
+ mov dword[ebx],'RAW1'
+ xor eax,eax
+ mov [.globalColor],eax
+ mov [.globalColorSize],eax
+ mov [.curImageIndex],eax
+ sub ebp,0xd
+ jb .end
+ movzx eax,word[esi+6]
+ mov [ebx+8],eax
+ movzx eax,word[esi+8]
+ mov [ebx+12],eax
+ mov cl,[esi+0xa]
+ add esi,0xd
+ test cl,cl
+ jns .nextblock
+ mov [.globalColor],esi
+ push ebx
+ call .Gif_skipmap
+ mov [.globalColorSize],ebx
+ pop ebx
+ jb .end
+ .nextblock:
+ dec ebp
+ js .end
+ cmp byte[esi],0x21
+ jne .noextblock
+ inc esi
+ cmp byte[esi],0xf9 ; Graphic Control Ext
+ jne .no_gc
+ sub ebp,7
+ jc .end
+ mov ecx,[ebx+4]
+ shl ecx,4
+ add ecx,ebx
+ mov eax,[esi+3]
+ mov [ecx+16+12],ax
+; test byte[esi+2],1
+; setnz byte[ecx+16+14]
+ mov al,[esi+2]
+ mov [ecx+16+14], al
+
+ mov al,[esi+5]
+ mov [ecx+16+15],al
+ add esi,7
+ jmp .nextblock
+ .no_gc:
+ inc esi
+ xor eax,eax
+ .block_skip:
+ dec ebp
+ js .end
+ lodsb
+ add esi,eax
+ sub ebp,eax
+ jc .end2
+ test eax,eax
+ jnz .block_skip
+ jmp .nextblock
+ .noextblock:
+ cmp byte[esi],0x2c ; image beginning
+ jne .end
+ inc esi
+ sub ebp,11
+ jc .end2
+ movzx ecx,word[esi+4] ; ecx = width
+ jecxz .end2
+ mov [.width],ecx
+ movzx eax,word[esi+6] ; eax = height
+ test eax,eax
+ jz .end2
+ push eax ecx
+ imul ecx,eax
+ cmp ecx,4000000h
+ jb @f
+ pop ecx eax
+.end2:
+ jmp .end
+@@:
+ push ebx
+ push ecx
+ add ecx,44+256*4
+ push 68
+ pop eax
+ push 12
+ pop ebx
+ int 0x40
+ pop ecx
+ pop ebx
+ test eax,eax
+ jnz @f
+ pop ecx ecx
+ jmp .end2
+@@:
+ xchg eax,edi
+ inc dword[ebx+4]
+ mov [edi+32],ecx ; size of pixels area
+ mov byte[edi+20],44 ; pointer to palette
+ mov byte[edi+24+1],4 ; size of palette=256*4
+ mov dword[edi+28],44+256*4 ; pointer to RAW data
+ pop ecx eax
+ mov dword[edi], 'RAW ' ; signature
+ mov dword[edi+4],ecx ; width
+ mov dword[edi+8],eax ; height
+ mov byte[edi+12],8 ; total pixel size
+ mov byte[edi+16],8 ; 8 bits per component
+ mov byte[edi+18],1 ; number of components
+ mov eax,[ebx+4]
+ shl eax,4
+ add eax,ebx
+ mov [eax],edi
+ movzx ecx,word[esi]
+ mov [eax+4],ecx
+ movzx ecx,word[esi+2]
+ mov [eax+8],ecx
+ mov eax,[edi+32]
+ mov [.img_end],eax
+ inc eax
+ mov [.row_end],eax
+ and [.pass],0
+ test byte[esi+8],40h
+ jz @f
+ mov ecx,[edi+4]
+ mov [.row_end],ecx
+@@:
+ mov cl,[esi+8]
+ add esi,9
+ add edi,44
+ push edi
+ test cl,cl
+ js .uselocal
+ push esi
+ mov esi,[.globalColor]
+ mov ecx,[.globalColorSize]
+ call .swap_palette
+ pop esi
+ jmp .setPal
+ .uselocal:
+ push ebx
+ call .Gif_skipmap
+ jnc @f
+ pop ebx
+ pop edi
+ jmp .end
+@@:
+ sub esi,ebx
+ mov ecx,ebx
+ pop ebx
+ call .swap_palette
+ .setPal:
+ movzx ecx,byte[esi]
+ inc ecx
+ mov [.codesize],ecx
+ dec ecx
+ inc esi
+ mov edi,.gif_workarea
+ xor eax,eax
+ lodsb ; eax - block_count
+ add eax,esi
+ mov [.block_ofs],eax
+ mov [.bit_count],8
+ mov eax,1
+ shl eax,cl
+ mov [.CC],eax
+ mov ecx,eax
+ inc eax
+ mov [.EOI],eax
+ mov eax, _null shl 16
+ .filltable:
+ stosd
+ inc eax
+ loop .filltable
+ pop edi
+ add edi,256*4
+ mov [.img_start],edi
+ add [.img_end],edi
+ add [.row_end],edi
+ mov [.ebx],ebx
+ .reinit:
+ mov edx,[.EOI]
+ inc edx
+ push [.codesize]
+ pop [.compsize]
+ call .Gif_get_sym
+ cmp eax,[.CC]
+ je .reinit
+ call .Gif_output
+ .cycle:
+ movzx ebx,ax
+ call .Gif_get_sym
+ cmp eax,edx
+ jae .notintable
+ cmp eax,[.CC]
+ je .reinit
+ cmp eax,[.EOI]
+ je .unpend
+ call .Gif_output
+ .add:
+ mov dword [.gif_workarea+edx*4],ebx
+ cmp edx,0xFFF
+ jae .cycle
+ inc edx
+ bsr ebx,edx
+ cmp ebx,[.compsize]
+ jne .noinc
+ inc [.compsize]
+ .noinc:
+ jmp .cycle
+ .notintable:
+ push eax
+ mov eax,ebx
+ call .Gif_output
+ push ebx
+ movzx eax,bx
+ call .Gif_output
+ pop ebx eax
+ jmp .add
+.unpend:
+ mov ebx,[.ebx]
+ add ebp,esi
+ mov esi,[.block_ofs]
+ sub ebp,esi
+ jc .end2
+ xor eax,eax
+@@:
+ dec ebp
+ js .end2
+ lodsb
+ test eax,eax
+ jz @f
+ sub ebp,eax
+ jc .end2
+ add esi,eax
+ jmp @b
+@@:
+ test ebp,ebp
+ jz .end2
+ cmp byte[esi],0x3b
+ jz .end2
+; next image
+ mov ecx,[ebx+4]
+ cmp cl,0xFF
+ jnz .noresize
+ mov edx,ebx
+ inc ecx
+ inc ecx
+ shl ecx,4
+ push 68
+ pop eax
+ push 20
+ pop ebx
+ int 40h
+ test eax,eax
+ jnz @f
+ mov ebx,edx
+ jmp .end2
+ @@:
+ xchg ebx,eax
+ .noresize:
+ jmp .nextblock
+
+.Gif_skipmap:
+; in: ecx - image descriptor, esi - pointer to colormap
+; out: edi - pointer to area after colormap
+
+ and ecx,111b ; color map size
+ mov ebx,3*2
+ shl ebx,cl
+ add esi,ebx
+ sub ebp,ebx
+ ret
+
+.Gif_get_sym:
+ mov ecx,[.compsize]
+ push ecx
+ xor eax,eax
+ .shift:
+ ror byte[esi],1
+ rcr eax,1
+ dec [.bit_count]
+ jnz .loop1
+ inc esi
+ cmp esi,[.block_ofs]
+ jb .noblock
+ push eax
+ xor eax,eax
+ dec ebp
+ js .dataend
+ lodsb
+ test eax,eax
+ jnz .nextbl
+ mov eax,[.EOI]
+ sub esi,2
+ add esp,8
+ jmp .exx
+ .nextbl:
+ add eax,esi
+ mov [.block_ofs],eax
+ pop eax
+ .noblock:
+ mov [.bit_count],8
+ .loop1:
+ loop .shift
+ pop ecx
+ rol eax,cl
+ .exx:
+ xor ecx,ecx
+ ret
+
+.dataend:
+ pop eax eax
+ mov ebx, [.ebx]
+ jmp .end2
+
+.Gif_output:
+ push esi eax edx
+ mov edx,.gif_workarea
+ .next:
+ push word[edx+eax*4]
+ mov ax,word[edx+eax*4+2]
+ inc ecx
+ cmp ax,_null
+ jnz .next
+ shl ebx,16
+ mov bx,[esp]
+ .loop2:
+ pop ax
+
+ stosb
+
+ cmp edi,[.row_end]
+ jb .norowend
+ mov eax,[.width]
+ push eax
+ sub edi,eax
+ add eax,eax
+ cmp [.pass],3
+ jz @f
+ add eax,eax
+ cmp [.pass],2
+ jz @f
+ add eax,eax
+@@:
+ add edi,eax
+ pop eax
+ cmp edi,[.img_end]
+ jb .nextrow
+ mov edi,[.img_start]
+ inc [.pass]
+ add edi,eax
+ cmp [.pass],3
+ jz @f
+ add edi,eax
+ cmp [.pass],2
+ jz @f
+ add edi,eax
+ add edi,eax
+@@:
+.nextrow:
+ add eax,edi
+ mov [.row_end],eax
+ xor eax,eax
+.norowend:
+
+ loop .loop2
+ pop edx eax esi
+ ret
+
+.swap_palette:
+ xor eax,eax
+@@:
+ lodsb
+ mov ah,al
+ lodsb
+ shl eax,8
+ lodsb
+ stosd
+ sub ecx,3
+ jnz @b
+ ret
+;---------------------------------------------------------------------
+check_header_1:
+ and dword [eax+8], 0
+ cmp dword [eax+12], 6
+ jb .err
+ push eax
+ mov eax, [eax]
+ cmp dword [eax], 'GIF8'
+ jnz .errpop
+ cmp byte [eax+5], 'a'
+ jnz .errpop
+ cmp byte [eax+4], '7'
+ jz @f
+ cmp byte [eax+4], '9'
+ jnz .errpop
+@@:
+ pop eax
+ ret
+.errpop:
+ pop eax
+.err:
+ inc dword [eax+8]
+ ret
+;---------------------------------------------------------------------
+check_header:
+ pushad
+ mov eax,dword [esp+36]
+ call check_header_1
+ popad
+ ret 4
+;---------------------------------------------------------------------
+Associations:
+dd Associations.end - Associations
+db 'GIF',0
+.end:
+db 0
+;---------------------------------------------------------------------
+align 4
+EXPORTS:
+ dd szStart, START
+ dd szVersion, 0x00010002
+ dd szCheck, check_header
+ dd szAssoc, Associations
+ dd 0
+
+szStart db 'START',0
+szVersion db 'version',0
+szCheck db 'Check_Header',0
+szAssoc db 'Associations',0
+
+section '.data' data readable writable align 16
+ ReadGIF.globalColor rd 1
+ ReadGIF.globalColorSize rd 1
+ ReadGIF.cur_info rd 1 ; image table pointer
+ ReadGIF.codesize rd 1
+ ReadGIF.compsize rd 1
+ ReadGIF.bit_count rd 1
+ ReadGIF.CC rd 1
+ ReadGIF.EOI rd 1
+ ReadGIF.block_ofs rd 1
+ ReadGIF.row_end rd 1
+ ReadGIF.img_end rd 1
+ ReadGIF.img_start rd 1
+ ReadGIF.pass rd 1
+ ReadGIF.width rd 1
+ ReadGIF.ebx rd 1
+ ReadGIF.gifList rd 1
+ ReadGIF.curImageIndex rd 1
+ ReadGIF.gif_workarea rb 16*1024
diff --git a/programs/media/zsea/plugins/jpeg/build.bat b/programs/media/zsea/plugins/jpeg/build.bat
new file mode 100644
index 0000000000..35cf3e4f03
--- /dev/null
+++ b/programs/media/zsea/plugins/jpeg/build.bat
@@ -0,0 +1,3 @@
+@fasm -m 16384 cnv_jpeg.asm cnv_jpeg.obj
+@kpack cnv_jpeg.obj
+@pause
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/jpeg/build.sh b/programs/media/zsea/plugins/jpeg/build.sh
new file mode 100644
index 0000000000..2b9efbe564
--- /dev/null
+++ b/programs/media/zsea/plugins/jpeg/build.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# This script does for Linux the same as build.bat for DOS,
+# it compiles the current KolibriOS applications
+
+ fasm -m 16384 cnv_jpeg.asm cnv_jpeg.obj
+ kpack cnv_jpeg.obj
+ exit 0
+
+
+
diff --git a/programs/media/zsea/plugins/jpeg/cnv_jpeg.asm b/programs/media/zsea/plugins/jpeg/cnv_jpeg.asm
new file mode 100644
index 0000000000..c6eb93f29b
--- /dev/null
+++ b/programs/media/zsea/plugins/jpeg/cnv_jpeg.asm
@@ -0,0 +1,2378 @@
+;*****************************************************************************
+; JPEG to RAW convert plugin - for zSea image viewer
+; Copyright (c) 2008, 2009, Evgeny Grechnikov aka Diamond
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Evgeny Grechnikov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;*****************************************************************************
+; Some small changes (c) 2011 Marat Zakiyanov aka Mario79, aka Mario
+;*****************************************************************************
+
+format MS COFF
+
+public EXPORTS
+
+section '.flat' code readable align 16
+
+START:
+ pushad
+ finit
+ mov eax,dword [esp+36]
+ mov esi, [eax] ; esi -> JPEG data
+ mov ebp, [eax+12] ; ebp = file size
+ mov [_esp], esp
+; initialize constant tables, if not yet
+ cmp [color_table_1+4], 0
+ jnz @f
+ call initialize_color_table
+@@:
+ xor ebx, ebx ; ebx -> RAW data, not allocated yet
+ mov [dct_buffer], ebx
+ mov [_ebx], ebx
+; check for SOI [Start-Of-Image] marker
+ call get_marker
+ jc .end
+ cmp al, 0xD8 ; SOI?
+ jz .soi_ok
+.end:
+; general exit from the function
+; for progressive mode: convert loaded DCT coefficients to image
+ call handle_progressive
+; convert full-color images to RGB
+ call convert_to_rgb
+ xor eax, eax
+ test ebx, ebx
+ jnz @f
+ inc eax ; ebx=0 => bad image
+@@:
+.ret:
+ mov ecx, [esp+28]
+ mov [ecx+4], ebx ; save RAW data ptr
+ mov [ecx+8], eax ; save result
+ popad
+ ret 4
+.soi_ok:
+ mov [restart_interval], ebx
+ mov [adobe_ycck], 0
+; loop until start of frame (real data), parse markers
+.markers_loop:
+ call get_marker
+ jc .end
+; markers RSTn do not have parameters
+; N.B. They can not exist in this part of JPEG, but let's be liberal :)
+ cmp al, 0xD0
+ jb @f
+ cmp al, 0xD8
+ jb .markers_loop
+@@:
+ cmp al, 0xD9 ; EOI? [invalid here]
+ jz .end
+; ok, this is marker segment
+; first word is length of the segment
+ cmp ebp, 2
+ jb .end
+ xor edx, edx
+ mov dl, [esi+1]
+ mov dh, [esi] ; edx = marker length, al = marker value
+ sub ebp, edx
+ jb .end
+ cmp al, 0xDB ; DQT?
+ jz .dqt
+ cmp al, 0xC4 ; DHT?
+ jz .dht
+ cmp al, 0xCC ; DAC? [ignored - no arithmetic coding]
+ jz .next_marker
+ cmp al, 0xDD ; DRI?
+ jz .dri
+ cmp al, 0xDA ; SOS?
+ jz .sos
+ cmp al, 0xC0
+ jb @f
+ cmp al, 0xD0
+ jb .sofn
+@@:
+ cmp al, 0xEE ; APP14?
+ jz .app14
+; unrecognized marker; let's skip it and hope for the best
+.next_marker:
+ add esi, edx
+ jmp .markers_loop
+.app14:
+; check for special Adobe marker
+ cmp dx, 14
+ jb .next_marker
+ cmp byte [esi+2], 'A'
+ jnz .next_marker
+ cmp dword [esi+3], 'dobe'
+ jnz .next_marker
+ cmp byte [esi+13], 2
+ setz [adobe_ycck]
+ jmp .next_marker
+.dqt:
+; DQT marker found
+; length: 2 bytes for length field + 65 bytes per table
+ sub edx, 2
+ jc .end
+ lodsw
+.dqt_loop:
+ test edx, edx
+ jz .markers_loop
+ sub edx, 1+64
+ jc .end
+ lodsb
+; 8-bit DCT-based process shall not use a 16-bit precision quantization table.
+ test al, 0xF0
+ jnz .end
+ and eax, 3
+ mov [eax+quant_tables_defined], 1
+ shl eax, 8
+ lea edi, [eax+quant_tables]
+ xor ecx, ecx
+@@:
+ xor eax, eax
+ lodsb
+ push eax
+ fild dword [esp]
+ pop eax
+ movzx eax, byte [zigzag+ecx]
+ add eax, eax
+ push eax
+ and eax, 7*4
+ fmul dword [idct_pre_table+eax]
+ pop eax
+ push eax
+ shr eax, 3
+ and eax, 7*4
+ fmul dword [idct_pre_table+eax]
+ pop eax
+ fstp dword [edi+eax]
+ inc ecx
+ cmp ecx, 64
+ jb @b
+ jmp .dqt_loop
+.dri:
+; DRI marker found
+ cmp edx, 4 ; length must be 4
+ jnz .end2
+ movzx eax, word [esi+2]
+ xchg al, ah
+ mov [restart_interval], eax
+ jmp .next_marker
+.dht:
+; DHT marker found
+ sub edx, 2
+ jc .end2
+ lodsw
+.dht_loop:
+ test edx, edx
+ jz .markers_loop
+ sub edx, 17
+ jc .end2
+; next Huffman table; find place for it
+ lodsb
+ mov edi, eax
+ and eax, 0x10
+ and edi, 3
+ shr eax, 2
+ or edi, eax
+ mov [dc_huffman_defined+edi], 1
+; shl edi, 11
+ imul edi, max_hufftable_size
+ add edi, dc_huffman ; edi -> destination table
+; get table size
+ xor eax, eax
+ push 16
+ pop ecx
+@@:
+ add al, [esi]
+ adc ah, 0
+ inc esi
+ loop @b
+ cmp ax, 0x100
+ ja .end2
+ sub edx, eax
+ jc .end2
+; construct Huffman tree
+ push ebx edx
+ ; lea eax, [edi+256*8]
+ ; push eax
+ ; push 16
+ ; mov edx, esi
+; @@:
+ ; cmp byte [edx-1], 0
+ ; jnz @f
+ ; dec edx
+ ; dec dword [esp]
+ ; jmp @b
+; @@:
+ ; sub edx, [esp]
+ ; lea eax, [edi+8]
+ ; push 2
+ ; pop ecx
+; .lenloop:
+ ; mov bl, byte [edx]
+ ; test bl, bl
+ ; jz .len1done
+ ; push eax
+ ; xor eax, eax
+; .len1loop:
+ ; dec ecx
+ ; js .dhterr
+ ; cmp edi, [esp+8]
+ ; jae .dhterr
+ ; lodsb
+ ; stosd
+ ; dec bl
+ ; jnz .len1loop
+ ; pop eax
+; .len1done:
+ ; jecxz .len2done
+ ; push ecx
+; .len2loop:
+ ; cmp eax, [esp+8]
+ ; jb @f
+ ; or eax, -1
+; @@:
+ ; cmp edi, [esp+8]
+ ; jae .dhterr
+ ; stosd
+ ; add eax, 8
+ ; jnb @f
+ ; or eax, -1
+; @@:
+ ; loop .len2loop
+ ; pop ecx
+; .len2done:
+ ; add ecx, ecx
+ ; inc edx
+ ; dec dword [esp]
+ ; jnz .lenloop
+ ; pop eax
+ ; pop eax
+ ; sub eax, edi
+ ; shr eax, 2
+ ; cmp eax, ecx
+ ; ja @f
+ ; mov ecx, eax
+; @@:
+ ; or eax, -1
+ ; rep stosd
+ ; pop edx ebx
+ ; jmp .dht_loop
+; .dhterr:
+ ; ;pop eax eax eax edx ebx
+ ; add esp, 5*4
+ lea eax, [edi+256*2]
+ push eax
+ lea edx, [esi-16]
+ mov ah, 1
+ mov ecx, 128
+.dht_l1:
+ movzx ebx, byte [edx]
+ inc edx
+ test ebx, ebx
+ jz .dht_l3
+.dht_l2:
+ cmp edi, [esp]
+ jae .dhterr1
+ lodsb
+ xchg al, ah
+ push ecx
+ rep stosw
+ pop ecx
+ xchg al, ah
+ dec ebx
+ jnz .dht_l2
+.dht_l3:
+ inc ah
+ shr ecx, 1
+ jnz .dht_l1
+ push edi
+ mov edi, [esp+4]
+ push edi
+ mov eax, 0x00090100
+ mov cl, 8
+.dht_l4:
+ movzx ebx, byte [edx]
+ inc edx
+ test ebx, ebx
+ jz .dht_l6
+.dht_l5:
+ cmp edi, [esp]
+ jb @f
+ mov edi, [esp+4]
+ rol eax, 16
+ cmp edi, [esp+8]
+ jae .dhterr2
+ stosw
+ inc ah
+ mov [esp+4], edi
+ pop edi
+ push edi
+ rol eax, 16
+ add dword [esp], 16*2
+@@:
+ lodsb
+ xchg al, ah
+ push ecx
+ rep stosw
+ pop ecx
+ xchg al, ah
+ dec ebx
+ jnz .dht_l5
+.dht_l6:
+ inc ah
+ shr ecx, 1
+ jnz .dht_l4
+ push edi
+ movzx ebx, byte [edx]
+ add ebx, ebx
+ add bl, [edx+1]
+ adc bh, 0
+ add ebx, ebx
+ add bl, [edx+2]
+ adc bh, 0
+ add ebx, ebx
+ add bl, [edx+3]
+ adc bh, 0
+ add ebx, 15
+ shr ebx, 4
+ mov cl, 8
+ lea ebx, [edi+ebx*2]
+ sub ebx, [esp+12]
+ add ebx, 31
+ shr ebx, 5
+ mov edi, ebx
+ shl edi, 5
+ add edi, [esp+12]
+ xor ebx, 9
+ shl ebx, 16
+ xor eax, ebx
+ push edi
+.dht_l7:
+ movzx ebx, byte [edx]
+ inc edx
+ test ebx, ebx
+ jz .dht_l10
+.dht_l8:
+ cmp edi, [esp]
+ jb .dht_l9
+ mov edi, [esp+4]
+ cmp edi, [esp+8]
+ jb @f
+ mov edi, [esp+12]
+ cmp edi, [esp+16]
+ jae .dhterr3
+ mov al, 9
+ stosb
+ rol eax, 8
+ stosb
+ inc eax
+ ror eax, 8
+ mov [esp+12], edi
+ mov edi, [esp+8]
+ add dword [esp+8], 16*2
+@@:
+ mov al, 9
+ stosb
+ rol eax, 16
+ stosb
+ inc eax
+ ror eax, 16
+ mov [esp+4], edi
+ pop edi
+ push edi
+ add dword [esp], 16*2
+.dht_l9:
+ lodsb
+ xchg al, ah
+ push ecx
+ rep stosw
+ pop ecx
+ xchg al, ah
+ dec ebx
+ jnz .dht_l8
+.dht_l10:
+ inc ah
+ shr ecx, 1
+ jnz .dht_l7
+ push -1
+ pop eax
+ pop ecx
+ sub ecx, edi
+ rep stosb
+ pop edi
+ pop ecx
+ sub ecx, edi
+ rep stosb
+ pop edi
+ pop ecx
+ sub ecx, edi
+ rep stosb
+ pop edx ebx
+ jmp .dht_loop
+.dhterr3:
+ pop eax eax
+.dhterr2:
+ pop eax eax
+.dhterr1:
+ pop eax
+ pop edx ebx
+.end2:
+ jmp .end
+.sofn:
+; SOFn marker found
+ test ebx, ebx
+ jnz .end2 ; only one frame is allowed
+; only SOF0 [baseline sequential], SOF1 [extended sequential], SOF2 [progressive]
+; nobody supports other compression methods
+ cmp al, 0xC2
+ ja .end2
+ setz [progressive]
+; Length must be at least 8
+ sub edx, 8
+ jb .end2
+; Sample precision in JFIF must be 8 bits
+ cmp byte [esi+2], 8
+ jnz .end2
+; Color space in JFIF is either YCbCr (color images, 3 components)
+; or Y (grey images, 1 component)
+ movzx eax, byte [esi+7]
+ cmp al, 1
+ jz @f
+ cmp al, 3
+ jz @f
+; Adobe products sometimes use YCCK color space with 4 components
+ cmp al, 4
+ jnz .end2
+ cmp [adobe_ycck], 0
+ jz .end2
+@@:
+ mov edi, eax ; edi = number of components
+ lea eax, [eax*3]
+ sub edx, eax
+ jnz .end2
+; get width and height
+; width must be nonzero
+; height must be nonzero - nobody supports DNL markers
+ mov ah, [esi+3]
+ mov al, [esi+4] ; eax = height
+ test eax, eax
+ jz .end2
+ xor ecx, ecx
+ mov ch, [esi+5]
+ mov cl, [esi+6] ; ecx = width
+ jecxz .end3
+ push eax ecx
+ imul ecx, eax
+ cmp ecx, 4000000h
+ jb @f
+ pop ecx eax
+.end3:
+ jmp .end2
+@@:
+ imul ecx, edi
+ push ecx
+ add ecx, 44+1
+; for grayscale images, allocate additional memory for palette
+ cmp edi, 1
+ jnz @f
+ add ecx, 256*4-1
+@@:
+ push 68
+ pop eax
+ push 12
+ pop ebx
+ int 0x40
+ mov ebx, eax
+ test eax, eax
+ jnz @f
+ pop ecx
+ mov al, 2
+ jmp .ret
+@@:
+; OS zeroes all allocated memory
+; push edx edi
+; mov edi, eax
+; mov edx, ecx
+; shr ecx, 2
+; xor eax, eax
+; rep stosd
+; mov ecx, edx
+; and ecx, 3
+; rep stosb
+; mov ecx, edx
+; pop edi edx
+ mov [_ebx], ebx
+ pop dword [ebx+32] ; size of pixels area
+ push 44
+ pop eax
+ mov dword [ebx+28], eax ; pointer to RGB data
+; create grayscale palette if needed
+ cmp edi, 1
+ jnz .no_create_palette
+ mov dword [ebx+20], eax
+ mov ecx, 256*4
+ mov dword [ebx+24], ecx
+ add dword [ebx+28], ecx
+ push edi
+ shr ecx, 2
+ xor eax, eax
+ lea edi, [ebx+44]
+@@:
+ stosd
+ add eax, 0x010101
+ loop @b
+ pop edi
+.no_create_palette:
+; other image characteristics
+ pop ecx eax
+ mov dword [ebx], 'RAW ' ; signature
+ mov dword [ebx+4], ecx ; width
+ mov dword [ebx+8], eax ; height
+ mov eax, edi
+ shl eax, 3
+ mov dword [ebx+12], eax ; total pixel size
+ mov byte [ebx+16], 8 ; 8 bits per component
+ mov word [ebx+18], di ; number of components
+ mov [delta_x], eax
+ mov [pixel_size], edi
+ ;mov eax, edi
+ imul eax, ecx
+ mov [delta_y], eax
+ shr eax, 3
+ mov [line_size], eax
+; and dword [ebx+36], 0 ; transparency data pointer = NULL
+; and dword [ebx+40], 0 ; transparency data size
+ add esi, 8
+ mov ecx, edi
+ mov edi, components
+ xor eax, eax
+ xor edx, edx
+.sof_parse_comp:
+ movsb ; db ComponentIdentifier
+ lodsb
+ mov ah, al
+ and al, 0xF
+ jz .end3
+ shr ah, 4
+ jz .end3
+ stosd ; db V, db H, db ?, db ? (will be filled later)
+ cmp dl, al
+ ja @f
+ mov dl, al
+@@:
+ cmp dh, ah
+ ja @f
+ mov dh, ah
+@@:
+ movsb ; db QuantizationTableID
+ loop .sof_parse_comp
+ mov word [max_v], dx
+ movzx eax, dh
+ movzx edx, dl
+ push eax edx
+ shl eax, 3
+ shl edx, 3
+ mov [block_width], eax
+ mov [block_height], edx
+ pop edx eax
+ push eax edx
+ imul eax, [delta_x]
+ mov [block_delta_x], eax
+ imul edx, [delta_y]
+ mov [block_delta_y], edx
+ mov eax, [ebx+4]
+ add eax, [block_width]
+ dec eax
+ xor edx, edx
+ div [block_width]
+ mov [x_num_blocks], eax
+ mov eax, [ebx+8]
+ add eax, [block_height]
+ dec eax
+ xor edx, edx
+ div [block_height]
+ mov [y_num_blocks], eax
+ mov cl, [ebx+18]
+ pop edx
+ mov edi, components
+@@:
+ mov eax, edx
+ div byte [edi+1] ; VMax / V_i = VFactor_i
+ mov byte [edi+3], al ; db VFactor
+ pop eax
+ push eax
+ div byte [edi+2] ; HMax / H_i = HFactor_i
+ mov byte [edi+4], al ; db HFactor
+ add edi, 6
+ loop @b
+ pop eax
+ cmp [progressive], 0
+ jz .sof_noprogressive
+ mov eax, [x_num_blocks]
+ mul [block_width]
+ mul [y_num_blocks]
+ mul [block_height]
+ add eax, eax
+ mov [dct_buffer_size], eax
+ mul [pixel_size]
+ xchg eax, ecx
+ push ebx
+ push 68
+ pop eax
+ push 12
+ pop ebx
+ int 0x40
+ pop ebx
+ test eax, eax
+ jnz @f
+ mov ecx, ebx
+ push 68
+ pop eax
+ push 13
+ pop ebx
+ int 0x40
+ xor ebx, ebx
+ jmp .end
+@@:
+ mov [dct_buffer], eax
+.sof_noprogressive:
+ jmp .markers_loop
+.sos:
+; SOS marker found
+; frame must be already opened
+ test ebx, ebx
+ jz .end3
+ cmp edx, 6
+ jb .end3
+; parse marker
+ movzx eax, byte [esi+2] ; number of components in this scan
+ test eax, eax
+ jz .end3 ; must be nonzero
+ cmp al, [ebx+18]
+ ja .end3 ; must be <= total number of components
+; mov [ns], eax
+ cmp al, 1
+ setz [not_interleaved]
+ lea ecx, [6+eax+eax]
+ cmp edx, ecx
+ jnz .end3
+ mov ecx, eax
+ mov edi, cur_components
+ add esi, 3
+.sos_find_comp:
+ lodsb ; got ComponentID, look for component info
+ push ecx esi
+ mov cl, [ebx+18]
+ mov esi, components
+ and dword [edi+48], 0
+ and dword [edi+52], 0
+@@:
+ cmp [esi], al
+ jz @f
+ inc dword [edi+52]
+ add esi, 6
+ loop @b
+@@:
+ mov eax, [esi+1]
+ mov dl, [esi+5]
+ pop esi ecx
+ jnz .end3 ; bad ComponentID
+ cmp [not_interleaved], 0
+ jz @f
+ mov ax, 0x0101
+@@:
+ stosd ; db V, db H, db VFactor, db HFactor
+ xor eax, eax
+ mov al, byte [edi-1] ; get HFactor
+ mul byte [ebx+18] ; number of components
+ stosd ; HIncrement_i = HFactor_i * sizeof(pixel)
+ mov al, byte [edi-4-2] ; get VFactor
+ mul byte [ebx+18] ; number of components
+ imul eax, [ebx+4] ; image width
+ stosd ; VIncrement_i = VFactor_i * sizeof(row)
+ xchg eax, edx
+ and eax, 3
+ cmp [quant_tables_defined+eax], 0
+ jz .end3
+ shl eax, 8
+ add eax, quant_tables
+ stosd ; dd QuantizationTable
+ lodsb
+ movzx eax, al
+ mov edx, eax
+ shr eax, 4
+ and edx, 3
+ and eax, 3
+ cmp [dc_huffman_defined+eax], 0
+ jnz .dc_table_ok
+ cmp [progressive], 0
+ jz .end3
+ xor eax, eax
+ jmp .dc_table_done
+.dc_table_ok:
+; shl eax, 11
+ imul eax, max_hufftable_size
+ add eax, dc_huffman
+.dc_table_done:
+ cmp [ac_huffman_defined+edx], 0
+ jnz .ac_table_ok
+ cmp [progressive], 0
+ jz .end3
+ xor edx, edx
+ jmp .ac_table_done
+.ac_table_ok:
+; shl edx, 11
+ imul edx, max_hufftable_size
+ add edx, ac_huffman
+.ac_table_done:
+ stosd ; dd DCTable
+ xchg eax, edx
+ stosd ; dd ACTable
+ push ecx
+ mov eax, [ebx+4]
+ movzx ecx, byte [edi-21] ; get HFactor
+ cdq ; edx:eax = width (width<0x10000, so as dword it is unsigned)
+ div ecx
+ stosd ; dd width / HFactor_i
+ stosd
+ xchg eax, ecx
+ inc eax
+ sub eax, edx
+ stosd ; dd HFactor_i+1 - (width % HFactor_i)
+ mov eax, [ebx+8]
+ movzx ecx, byte [edi-34] ; get VFactor
+ cdq
+ div ecx
+ stosd ; dd height / VFactor_i
+ stosd
+ xchg eax, ecx
+ inc eax
+ sub eax, edx
+ stosd ; dd VFactor_i+1 - (height % VFactor_i)
+ pop ecx
+ scasd ; dd DCPrediction
+ cmp dword [edi], 0
+ setnp al
+ ror al, 1
+ mov byte [edi-1], al
+ scasd ; dd ComponentOffset
+ dec ecx
+ jnz .sos_find_comp
+ mov [cur_components_end], edi
+ mov edi, ScanStart
+ movsb
+ cmp byte [esi], 63
+ ja .end3
+ movsb
+ lodsb
+ push eax
+ and al, 0xF
+ stosb
+ pop eax
+ shr al, 4
+ stosb
+; now unpack data
+ call init_limits
+ and [decoded_MCUs], 0
+ mov [cur_rst_marker], 7
+ and [huffman_bits], 0
+ cmp [progressive], 0
+ jz .sos_noprogressive
+; progressive mode - only decode DCT coefficients
+; initialize pointers to coefficients data
+; zero number of EOBs for AC coefficients
+; redefine HIncrement and VIncrement
+ mov edi, cur_components
+.coeff_init:
+ mov eax, [dct_buffer_size]
+ mul dword [edi+52]
+ add eax, [dct_buffer]
+ mov [edi+12], eax
+ and dword [edi+52], 0
+ cmp [ScanStart], 0
+ jz .scan_dc
+ cmp dword [edi+20], 0
+ jz .end3
+ jmp @f
+.scan_dc:
+ cmp dword [edi+16], 0
+ jz .end3
+@@:
+ movzx eax, byte [edi+1]
+ shl eax, 7
+ mov [edi+4], eax
+ mov eax, [edi+28]
+ mov cl, [edi+3]
+ cmp cl, [edi+32]
+ sbb eax, -7-1
+ shr eax, 3
+ shl eax, 7
+ mov [edi+8], eax
+ add edi, 56
+ cmp edi, [cur_components_end]
+ jb .coeff_init
+; unpack coefficients
+; N.B. Speed optimization has sense here.
+ push ebx
+.coeff_decode_loop:
+ mov edx, cur_components
+.coeff_components_loop:
+ mov edi, [edx+12]
+ movzx ecx, byte [edx]
+ push dword [edx+40]
+ push edi
+.coeff_y_loop:
+ push ecx
+ movzx eax, byte [edx+1]
+ push dword [edx+28]
+ push edi
+.coeff_x_loop:
+ cmp dword [edx+40], 0
+ jl @f
+ cmp dword [edx+28], 0
+ jge .realdata
+@@:
+ cmp [not_interleaved], 0
+ jnz .norealdata
+ push eax edi
+ mov edi, dct_coeff
+ call decode_progressive_coeff
+ pop edi eax
+ jmp .norealdata
+.realdata:
+ push eax
+ call decode_progressive_coeff
+ add edi, 64*2
+ pop eax
+.norealdata:
+ sub dword [edx+28], 8
+ sub eax, 1
+ jnz .coeff_x_loop
+ pop edi
+ pop dword [edx+28]
+ add edi, [edx+8]
+ pop ecx
+ sub dword [edx+40], 8
+ sub ecx, 1
+ jnz .coeff_y_loop
+ movzx eax, byte [edx+1]
+ shl eax, 3
+ pop edi
+ add edi, [edx+4]
+ pop dword [edx+40]
+ sub [edx+28], eax
+ mov [edx+12], edi
+ add edx, 56
+ cmp edx, [cur_components_end]
+ jnz .coeff_components_loop
+ call next_MCU
+ jc .norst
+ sub [cur_x], 1
+ jnz .coeff_decode_loop
+ call next_line
+ mov edx, cur_components
+@@:
+ mov eax, [max_x]
+ imul eax, [edx+4]
+ sub [edx+12], eax
+ movzx eax, byte [edx]
+ imul eax, [edx+8]
+ add [edx+12], eax
+ add edx, 56
+ cmp edx, [cur_components_end]
+ jnz @b
+ sub [cur_y], 1
+ jnz .coeff_decode_loop
+ pop ebx
+ jmp .markers_loop
+.norst:
+ pop ebx
+ jmp .end4
+.sos_noprogressive:
+; normal mode - unpack JPEG image
+ mov edi, [ebx+28]
+ add edi, ebx
+ mov [cur_out_ptr], edi
+; N.B. Speed optimization has sense here.
+.decode_loop:
+ call decode_MCU
+ call next_MCU
+ jc .end4
+ sub [cur_x], 1
+ jnz .decode_loop
+ call next_line
+ sub [cur_y], 1
+ jnz .decode_loop
+ jmp .markers_loop
+.end4:
+ jmp .end3
+;---------------------------------------------------------------------
+get_marker:
+; in: esi -> data
+; out: CF=0, al=marker value - ok
+; CF=1 - no marker
+ sub ebp, 1
+ jc .ret
+ lodsb
+if 1
+ cmp al, 0xFF
+ jae @f
+; Some stupid men, which do not read specifications and manuals,
+; sometimes create markers with length field two less than true
+; value (in JPEG length of marker = length of data INCLUDING
+; length field itself). To open such files, allow 2 bytes
+; before next marker.
+ cmp ebp, 2
+ jb .ret
+ lodsb
+ lodsb
+end if
+ cmp al, 0xFF
+ jb .ret
+@@:
+ sub ebp, 1
+ jc .ret
+ lodsb
+ cmp al, 0xFF
+ jz @b
+ clc
+.ret:
+ ret
+;---------------------------------------------------------------------
+align 16
+decode_MCU:
+ mov edx, cur_components
+.components_loop:
+; decode each component
+ push [cur_out_ptr]
+ movzx ecx, byte [edx]
+ push dword [edx+40]
+; we have H_i * V_i blocks of packed data, decode them
+.y_loop_1:
+ push [cur_out_ptr]
+ push ecx
+ movzx eax, byte [edx+1]
+ push dword [edx+28]
+.x_loop_1:
+ push eax
+ call decode_data_unit
+ cmp dword [edx+40], 0
+ jl .nocopyloop
+ cmp dword [edx+28], 0
+ jl .nocopyloop
+; now we have decoded block 8*8 in decoded_data
+; H_i * V_i packed blocks 8*8 make up one block (8*HMax) * (8*VMax)
+; so each pixel in packed block corresponds to HFact * VFact pixels
+ movzx ecx, byte [edx+2]
+ push esi ebp
+ mov edi, [cur_out_ptr]
+ add edi, [edx+52]
+.y_loop_2:
+ push ecx edi
+ cmp ecx, [edx+44]
+ mov ecx, [edx+40]
+ sbb ecx, 8-1
+ sbb eax, eax
+ and ecx, eax
+ add ecx, 8
+ jz .skip_x_loop_2
+ movzx eax, byte [edx+3]
+.x_loop_2:
+ push eax ecx edi
+ cmp eax, [edx+32]
+ mov eax, [edx+28]
+ sbb eax, 8-1
+ sbb ebp, ebp
+ and eax, ebp
+ mov ebp, .copyiter_all
+ mov esi, decoded_data
+ sub ebp, eax
+ sub ebp, eax
+ sub ebp, eax
+ mov eax, [edx+4]
+ sub eax, 1
+.copyloop:
+ push esi edi
+ jmp ebp
+.copyiter_all:
+ movsb
+repeat 7
+ add edi, eax
+ movsb
+end repeat
+ nop
+ nop
+ pop edi esi
+ add edi, [edx+8]
+ add esi, 8
+ sub ecx, 1
+ jnz .copyloop
+ pop edi ecx eax
+ add edi, [pixel_size]
+ sub eax, 1
+ jnz .x_loop_2
+.skip_x_loop_2:
+ pop edi ecx
+ add edi, [line_size]
+ sub ecx, 1
+ jnz .y_loop_2
+ pop ebp esi
+.nocopyloop:
+ mov eax, [delta_x]
+ add [cur_out_ptr], eax
+ pop eax
+ sub dword [edx+28], 8
+ sub eax, 1
+ jnz .x_loop_1
+ pop dword [edx+28]
+ pop ecx
+ pop eax
+ sub dword [edx+40], 8
+ add eax, [delta_y]
+ mov [cur_out_ptr], eax
+ sub ecx, 1
+ jnz .y_loop_1
+ movzx eax, byte [edx+1]
+ pop dword [edx+40]
+ shl eax, 3
+ pop [cur_out_ptr]
+ sub dword [edx+28], eax
+ add edx, 56
+ cmp edx, [cur_components_end]
+ jb .components_loop
+ mov eax, [cur_block_dx]
+ add [cur_out_ptr], eax
+ ret
+
+align 16
+next_MCU:
+ add [decoded_MCUs], 1
+ mov eax, [restart_interval]
+ test eax, eax
+ jz .no_restart
+ cmp [decoded_MCUs], eax
+ jb .no_restart
+ and [decoded_MCUs], 0
+ and [huffman_bits], 0
+ cmp [cur_x], 1
+ jnz @f
+ cmp [cur_y], 1
+ jz .no_restart
+@@:
+; restart marker must be present
+ sub ebp, 2
+ js .error
+ cmp byte [esi], 0xFF
+ jnz .error
+ mov al, [cur_rst_marker]
+ inc eax
+ and al, 7
+ mov [cur_rst_marker], al
+ add al, 0xD0
+ cmp [esi+1], al
+ jnz .error
+ add esi, 2
+; handle restart marker - zero all DC predictions
+ mov edx, cur_components
+@@:
+ and word [edx+48], 0
+ add edx, 56
+ cmp edx, [cur_components_end]
+ jb @b
+.no_restart:
+ clc
+ ret
+.error:
+ stc
+ ret
+
+next_line:
+ mov eax, [max_x]
+ mov [cur_x], eax
+ mul [cur_block_dx]
+ sub eax, [cur_block_dy]
+ sub [cur_out_ptr], eax
+ mov edx, cur_components
+@@:
+ mov eax, [edx+24]
+ mov [edx+28], eax
+ movzx eax, byte [edx]
+ shl eax, 3
+ sub [edx+40], eax
+ add edx, 56
+ cmp edx, [cur_components_end]
+ jb @b
+ ret
+
+init_limits:
+ push [x_num_blocks]
+ pop [max_x]
+ push [y_num_blocks]
+ pop [max_y]
+ push [block_delta_x]
+ pop [cur_block_dx]
+ push [block_delta_y]
+ pop [cur_block_dy]
+ cmp [not_interleaved], 0
+ jz @f
+ mov eax, dword [cur_components+28]
+ movzx ecx, byte [cur_components+3]
+ cmp cl, [cur_components+32]
+ sbb eax, -7-1
+ shr eax, 3
+ mov [max_x], eax
+ mov eax, dword [cur_components+40]
+ movzx edx, byte [cur_components+2]
+ cmp dl, [cur_components+44]
+ sbb eax, -7-1
+ shr eax, 3
+ mov [max_y], eax
+ imul ecx, [delta_x]
+ mov [cur_block_dx], ecx
+ imul edx, [delta_y]
+ mov [cur_block_dy], edx
+@@:
+ push [max_x]
+ pop [cur_x]
+ push [max_y]
+ pop [cur_y]
+ ret
+
+;macro get_bit
+;{
+;local .l1,.l2,.marker
+; add cl, cl
+; jnz .l1
+; sub ebp, 1
+; js decode_data_unit.eof
+; mov cl, [esi]
+; cmp cl, 0xFF
+; jnz .l2
+;.marker:
+; add esi, 1
+; sub ebp, 1
+; js decode_data_unit.eof
+; cmp byte [esi], 0xFF
+; jz .marker
+; cmp byte [esi], 0
+; jnz decode_data_unit.eof
+;.l2:
+; sub esi, -1
+; adc cl, cl
+;.l1:
+;}
+macro get_bit
+{
+local .l1,.l2,.marker
+ sub cl, 1
+ jns .l1
+ sub ebp, 1
+ js .eof
+ mov ch, [esi]
+ cmp ch, 0xFF
+ jnz .l2
+.marker:
+ add esi, 1
+ sub ebp, 1
+ js .eof
+ cmp byte [esi], 0xFF
+ jz .marker
+ cmp byte [esi], 0
+ jnz .eof
+.l2:
+ add esi, 1
+ mov cl, 7
+.l1:
+ add ch, ch
+}
+macro get_bits restore_edx
+{
+local .l1,.l2,.l3,.marker2
+ movzx eax, ch
+ mov dl, cl
+ shl eax, 24
+ neg cl
+ push ebx
+ add cl, 24
+.l1:
+ cmp bl, dl
+ jbe .l2
+ sub bl, dl
+ sub ebp, 1
+ js .eof
+ mov ch, [esi]
+ cmp ch, 0xFF
+ jnz .l3
+.marker2:
+ add esi, 1
+ sub ebp, 1
+ js .eof
+ cmp byte [esi], 0xFF
+ jz .marker2
+ cmp byte [esi], 0
+ jnz .eof
+.l3:
+ movzx edx, ch
+ add esi, 1
+ shl edx, cl
+ sub cl, 8
+ or eax, edx
+ mov dl, 8
+ jmp .l1
+.l2:
+ mov cl, bl
+ sub dl, bl
+ shl ch, cl
+ pop ebx
+ cmp eax, 80000000h
+ rcr eax, 1
+ mov cl, 31
+ sub cl, bl
+ sar eax, cl
+ mov cl, dl
+if restore_edx eq true
+ pop edx
+end if
+ add eax, 80000000h
+ adc eax, 80000000h
+}
+; macro get_huffman_code
+; {
+; local .l1
+ ; xor ebx, ebx
+; .l1:
+ ; get_bit
+ ; adc ebx, ebx
+ ; mov eax, [eax+4*ebx]
+ ; xor ebx, ebx
+ ; cmp eax, -1
+ ; jz .eof
+ ; cmp eax, 0x1000
+ ; jae .l1
+ ; mov ebx, eax
+; }
+macro get_huffman_code
+{
+local .l1,.l2,.l3,.l4,.l5,.l6,.nomarker1,.marker1,.nomarker2,.marker2,.nomarker3,.marker3,.done
+; 1. (First level in Huffman table) Does the current Huffman code fit in 8 bits
+; and have we got enough bits?
+ movzx ebx, ch
+ cmp byte [eax+ebx*2], cl
+ jbe .l1
+; 2a. No; load next byte
+ sub ebp, 1
+ js .eof
+ mov ch, [esi]
+ movzx edx, ch
+ cmp ch, 0xFF
+ jnz .nomarker1
+.marker1:
+ add esi, 1
+ sub ebp, 1
+ js .eof
+ cmp byte [esi], 0xFF
+ jz .marker1
+ cmp byte [esi], 0
+ jnz .eof
+.nomarker1:
+ shr edx, cl
+ add esi, 1
+ or ebx, edx
+; 3a. (First level in Huffman table, >=8 bits known) Does the current Huffman code fit in 8 bits?
+ cmp byte [eax+ebx*2], 8
+ jbe .l2
+ jl .eof
+; 4aa. No; go to next level
+ movzx ebx, byte [eax+ebx*2+1]
+ mov dl, ch
+ shl ebx, 5
+ ror edx, cl
+ lea ebx, [eax+ebx+0x200]
+ shr edx, 24
+ push edx
+ shr edx, 4
+; 5aa. (Second level in Huffman table) Does the current Huffman code fit in 12 bits
+; and have we got enough bits?
+ cmp byte [ebx+edx*2], cl
+ jbe .l3
+; 6aaa. No; have we got 12 bits?
+ cmp cl, 4
+ jae .l4
+; 7aaaa. No; load next byte
+ pop edx
+ sub ebp, 1
+ js .eof
+ mov ch, [esi]
+ cmp ch, 0xFF
+ jnz .nomarker2
+.marker2:
+ add esi, 1
+ sub ebp, 1
+ js .eof
+ cmp byte [esi], 0xFF
+ jz .marker2
+ cmp byte [esi], 0
+ jnz .eof
+.nomarker2:
+ push ecx
+ shr ch, cl
+ add esi, 1
+ or dl, ch
+ pop ecx
+ push edx
+ shr edx, 4
+; 8aaaa. (Second level in Huffman table) Does the current Huffman code fit in 12 bits?
+ cmp byte [ebx+edx*2], 4
+ jbe .l5
+ jl .eof
+; 9aaaaa. No; go to next level
+ movzx ebx, byte [ebx+edx*2+1]
+ pop edx
+ shl ebx, 5
+ and edx, 0xF
+ lea ebx, [eax+ebx+0x200]
+; 10aaaaa. Get current code length and value
+ sub cl, [ebx+edx*2]
+ movzx eax, byte [ebx+edx*2+1]
+ neg cl
+ shl ch, cl
+ neg cl
+ add cl, 8
+ jmp .done
+.l5:
+; 9aaaab. Yes; get current code length and value
+ sub cl, [ebx+edx*2]
+ movzx eax, byte [ebx+edx*2+1]
+ neg cl
+ pop edx
+ shl ch, cl
+ neg cl
+ add cl, 8
+ jmp .done
+.l4:
+; 7aaab. Yes; go to next level
+ movzx ebx, byte [ebx+edx*2+1]
+ pop edx
+ shl ebx, 5
+ and edx, 0xF
+ lea ebx, [eax+ebx+0x200]
+; 8aaab. (Third level in Huffman table) Have we got enough bits?
+ cmp [ebx+edx*2], cl
+ jbe .l6
+; 9aaaba. No; load next byte
+ sub ebp, 1
+ js .eof
+ mov ch, [esi]
+ cmp ch, 0xFF
+ jnz .nomarker3
+.marker3:
+ add esi, 1
+ sub ebp, 1
+ js .eof
+ cmp byte [esi], 0xFF
+ jz .marker3
+ cmp byte [esi], 0
+ jnz .eof
+.nomarker3:
+ push ecx
+ shr ch, cl
+ add esi, 1
+ or dl, ch
+ pop ecx
+; 10aaaba. Get current code length and value
+ sub cl, [ebx+edx*2]
+ movzx eax, byte [ebx+edx*2+1]
+ neg cl
+ shl ch, cl
+ neg cl
+ add cl, 8
+ jmp .done
+.l3:
+; 6aab. Yes; get current code length and value
+ pop eax
+.l6:
+; 9aaabb. Yes; get current code length and value
+ sub cl, [ebx+edx*2]
+ movzx eax, byte [ebx+edx*2+1]
+ xor cl, 7
+ shl ch, cl
+ xor cl, 7
+ add ch, ch
+ jmp .done
+.l2:
+; 3ab. Yes; get current code length and value
+ sub cl, [eax+ebx*2]
+ movzx eax, byte [eax+ebx*2+1]
+ neg cl
+ shl ch, cl
+ neg cl
+ add cl, 8
+ jmp .done
+.l1:
+; 3b. Yes; get current code length and value
+ mov dl, [eax+ebx*2]
+ movzx eax, byte [eax+ebx*2+1]
+ xchg cl, dl
+ sub dl, cl
+ shl ch, cl
+ mov cl, dl
+.done:
+ mov ebx, eax
+}
+; Decode DCT coefficients for one 8*8 block in progressive mode
+; from input stream, given by pointer esi and length ebp
+; N.B. Speed optimization has sense here.
+align 16
+decode_progressive_coeff:
+ mov ecx, [huffman_bits]
+ cmp [ScanStart], 0
+ jnz .ac
+; DC coefficient
+ cmp [ApproxPosHigh], 0
+ jz .dc_first
+; DC coefficient, subsequent passes
+ xor eax, eax
+ get_bit
+ adc eax, eax
+ mov [huffman_bits], ecx
+ mov cl, [ApproxPosLow]
+ shl eax, cl
+ or [edi], ax
+ ret
+.dc_first:
+; DC coefficient, first pass
+ mov eax, [edx+16]
+ push edx
+ get_huffman_code
+ get_bits true
+ add eax, [edx+48]
+ mov [edx+48], ax
+ mov [huffman_bits], ecx
+ mov cl, [ApproxPosLow]
+ shl eax, cl
+ mov [edi], ax
+ ret
+.ac:
+; AC coefficients
+ movzx eax, [ScanStart]
+ cmp al, [ScanEnd]
+ ja .ret
+ cmp dword [edx+52], 0
+ jnz .was_eob
+.acloop:
+ push edx
+ push eax
+ mov eax, [edx+20]
+ get_huffman_code
+ pop eax
+ test ebx, 15
+ jz .band
+ push eax ebx
+ and ebx, 15
+ get_bits false
+ pop ebx
+ xchg eax, [esp]
+ shr ebx, 4
+.zeroloop1:
+ push eax ebx
+ movzx eax, byte [zigzag+eax]
+ xor ebx, ebx
+ cmp word [edi+eax], bx
+ jz .zeroloop2
+ get_bit
+ jnc @f
+ push ecx
+ mov cl, [ApproxPosLow]
+ xor ebx, ebx
+ cmp byte [edi+eax+1], 80h
+ adc ebx, 0
+ add ebx, ebx
+ sub ebx, 1
+ shl ebx, cl
+ pop ecx
+ add [edi+eax], bx
+@@:
+ pop ebx eax
+@@:
+ add eax, 1
+ cmp al, [ScanEnd]
+ ja decode_data_unit.eof
+ jmp .zeroloop1
+.zeroloop2:
+ pop ebx eax
+ sub ebx, 1
+ jns @b
+.nozero1:
+ pop ebx
+ test ebx, ebx
+ jz @f
+ push eax
+ movzx eax, byte [zigzag+eax]
+ push ecx
+ mov cl, [ApproxPosLow]
+ shl ebx, cl
+ pop ecx
+ mov [edi+eax], bx
+ pop eax
+@@:
+ add eax, 1
+ pop edx
+ cmp al, [ScanEnd]
+ jbe .acloop
+ mov [huffman_bits], ecx
+.ret:
+ ret
+.eof:
+ jmp decode_data_unit.eof
+.band:
+ shr ebx, 4
+ cmp ebx, 15
+ jnz .eob
+ push 0
+ jmp .zeroloop1
+.eob:
+ pop edx
+ push eax
+ mov eax, 1
+ test ebx, ebx
+ jz .eob0
+@@:
+ get_bit
+ adc eax, eax
+ sub ebx, 1
+ jnz @b
+.eob0:
+ mov [edx+52], eax
+ pop eax
+.was_eob:
+ sub dword [edx+52], 1
+ cmp al, [ScanEnd]
+ ja .ret2
+.zeroloop3:
+ push eax
+ movzx eax, byte [zigzag+eax]
+ xor ebx, ebx
+ cmp word [edi+eax], bx
+ jz @f
+ get_bit
+ jnc @f
+ push ecx
+ mov cl, [ApproxPosLow]
+ xor ebx, ebx
+ cmp byte [edi+eax+1], 80h
+ adc ebx, 0
+ add ebx, ebx
+ sub ebx, 1
+ shl ebx, cl
+ pop ecx
+ add [edi+eax], bx
+@@:
+ pop eax
+ add eax, 1
+ cmp al, [ScanEnd]
+ jbe .zeroloop3
+.ret2:
+ mov [huffman_bits], ecx
+ ret
+
+handle_progressive:
+ cmp [dct_buffer], 0
+ jnz @f
+ ret
+@@:
+; information for all components
+ mov esi, components
+ xor ebp, ebp
+ movzx ecx, byte [ebx+18]
+.next_component:
+ mov edi, cur_components
+ lodsb ; ComponentID
+ lodsd
+ mov ax, 0x0101
+ stosd ; db V, db H, db VFactor, db HFactor
+ xor eax, eax
+ mov al, byte [edi-1] ; get HFactor
+ mul byte [ebx+18] ; number of components
+ stosd ; HIncrement_i = HFactor_i * sizeof(pixel)
+ mov al, byte [edi-4-2] ; get VFactor
+ mul byte [ebx+18] ; number of components
+ mul dword [ebx+4] ; image width
+ stosd ; VIncrement_i = VFactor_i * sizeof(row)
+ lodsb
+ and eax, 3
+ cmp [quant_tables_defined+eax], 0
+ jz .error
+ shl eax, 8
+ add eax, quant_tables
+ stosd ; dd QuantizationTable
+ stosd ; dd DCTable - ignored
+ mov eax, ebp
+ mul [dct_buffer_size]
+ add eax, [dct_buffer]
+ stosd ; instead of dd ACTable - pointer to current DCT coefficients
+ push ecx
+ mov eax, [ebx+4]
+ movzx ecx, byte [edi-21] ; get HFactor
+; cdq ; edx = 0 as a result of previous mul
+ div ecx
+ stosd ; dd width / HFactor_i
+ stosd
+ xchg eax, ecx
+ inc eax
+ sub eax, edx
+ stosd ; dd HFactor_i+1 - (width % HFactor_i)
+ mov eax, [ebx+8]
+ movzx ecx, byte [edi-34] ; get VFactor
+ cdq
+ div ecx
+ stosd ; dd height / VFactor_i
+ stosd
+ xchg eax, ecx
+ inc eax
+ sub eax, edx
+ stosd ; dd VFactor_i+1 - (height % VFactor_i)
+ pop ecx
+ xor eax, eax
+ test ebp, ebp
+ setnp al
+ ror eax, 1
+ stosd ; dd DCPrediction
+ mov eax, ebp
+ stosd ; dd ComponentOffset
+ inc ebp
+ push ecx
+ mov [cur_components_end], edi
+ lea edx, [edi-56]
+; do IDCT and unpack
+ mov edi, [ebx+28]
+ add edi, ebx
+ mov [cur_out_ptr], edi
+ mov [not_interleaved], 1
+ call init_limits
+.decode_loop:
+ call decode_MCU
+ sub [cur_x], 1
+ jnz .decode_loop
+ call next_line
+ sub [cur_y], 1
+ jnz .decode_loop
+ pop ecx
+ dec ecx
+ jnz .next_component
+; image unpacked, return
+.error:
+ push ebx
+ push 68
+ pop eax
+ push 13
+ pop ebx
+ mov ecx, [dct_buffer]
+ int 0x40
+ pop ebx
+ ret
+
+; Support for YCbCr -> RGB conversion
+; R = Y + 1.402 * (Cr - 128)
+; G = Y - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128)
+; B = Y + 1.772 * (Cb - 128)
+; When converting YCbCr -> RGB, we need to do some multiplications;
+; to be faster, we precalculate the table for all 256 possible values
+; Also we approximate fractions with N/65536, this gives sufficient precision
+initialize_color_table:
+; 1.402 = 1 + 26345/65536, -0.71414 = -46802/65536
+; -0.34414 = -22554/65536, 1.772 = 1 + 50594/65536
+ mov edi, color_table_1
+ mov ecx, 128
+; 1. Cb -> 1.772*Cb
+ xor eax, eax
+ mov dx, 8000h
+.l1:
+ push ecx
+@@:
+ stosd
+ add dx, 50594
+ adc eax, 1
+ loop @b
+ neg dx
+ adc eax, -1
+ neg eax
+ pop ecx
+ jnz .l1
+; 2. Cb -> -0.34414*Cb
+ mov ax, dx
+.l2:
+ push ecx
+@@:
+ stosd
+ sub eax, 22554
+ loop @b
+ neg eax
+ pop ecx
+ cmp ax, dx
+ jnz .l2
+ xor eax, eax
+; 3. Cr -> -0.71414*Cr
+.l3:
+ push ecx
+@@:
+ stosd
+ sub eax, 46802
+ loop @b
+ neg eax
+ pop ecx
+ jnz .l3
+; 4. Cr -> 1.402*Cr
+.l4:
+ push ecx
+@@:
+ stosd
+ add dx, 26345
+ adc eax, 1
+ loop @b
+ neg dx
+ adc eax, -1
+ neg eax
+ pop ecx
+ jnz .l4
+ ret
+
+; this function is called in the end of image loading
+convert_to_rgb:
+; some checks
+ test ebx, ebx ; image exists?
+ jz .ret
+ cmp byte [ebx+18], 3 ; full-color image?
+ jz .ycc2rgb
+ cmp byte [ebx+18], 4
+ jz .ycck2rgb
+.ret:
+ ret
+.ycc2rgb:
+; conversion is needed
+ mov esi, [ebx+4]
+ imul esi, [ebx+8]
+ lea edi, [ebx+44]
+ push ebx
+; N.B. Speed optimization has sense here.
+align 16
+.loop:
+; mov ebx, [edi]
+; mov edx, ebx
+; mov ecx, ebx
+; movzx ebx, bl ; ebx = Y
+; shr edx, 16
+; mov eax, ebx
+; movzx edx, dl ; edx = Cr
+; movzx ecx, ch ; ecx = Cb
+ movzx ebx, byte [edi]
+ movzx ecx, byte [edi+1]
+ mov eax, ebx
+ movzx edx, byte [edi+2]
+; B = Y + color_table_1[Cb]
+ add eax, [color_table_1+ecx*4]
+ mov ebp, [color_table_2+ecx*4]
+ cmp eax, 80000000h
+ sbb ecx, ecx
+ and eax, ecx
+ add ebp, [color_table_3+edx*4]
+ cmp eax, 0x100
+ sbb ecx, ecx
+ not ecx
+ sar ebp, 16
+ or eax, ecx
+ mov [edi], al
+; G = Y + color_table_2[Cb] + color_table_3[Cr]
+ lea eax, [ebx+ebp]
+ cmp eax, 80000000h
+ sbb ecx, ecx
+ and eax, ecx
+ cmp eax, 0x100
+ sbb ecx, ecx
+ not ecx
+ or eax, ecx
+ mov [edi+1], al
+; R = Y + color_table_4[Cr]
+ mov eax, ebx
+ add eax, [color_table_4+edx*4]
+ cmp eax, 80000000h
+ sbb ecx, ecx
+ and eax, ecx
+ cmp eax, 0x100
+ sbb ecx, ecx
+ not ecx
+ or eax, ecx
+ mov [edi+2], al
+ add edi, 3
+ sub esi, 1
+ jnz .loop
+ pop ebx
+ ret
+.ycck2rgb:
+; conversion is needed
+ mov esi, [ebx+4]
+ imul esi, [ebx+8]
+ push ebx
+ push esi
+ lea edi, [ebx+44]
+ mov esi, edi
+; N.B. Speed optimization has sense here.
+align 16
+.kloop:
+; mov ebx, [esi]
+; mov edx, ebx
+; mov ecx, ebx
+; movzx ebx, bl ; ebx = Y
+; shr edx, 16
+; mov eax, ebx
+; movzx edx, dl ; edx = Cr
+; movzx ecx, ch ; ecx = Cb
+ movzx ebx, byte [esi]
+ movzx ecx, byte [esi+1]
+ mov eax, ebx
+ movzx edx, byte [esi+2]
+; B = Y + color_table_1[Cb]
+ add eax, [color_table_1+ecx*4]
+ mov ebp, [color_table_2+ecx*4]
+ cmp eax, 80000000h
+ sbb ecx, ecx
+ and eax, ecx
+ add ebp, [color_table_3+edx*4]
+ cmp eax, 0x100
+ sbb ecx, ecx
+ not ecx
+ sar ebp, 16
+ or eax, ecx
+ xor al, 0xFF
+ mul byte [esi+3]
+ add al, ah
+ adc ah, 0
+ add al, 80h
+ adc ah, 0
+ mov byte [edi], ah
+; G = Y + color_table_2[Cb] + color_table_3[Cr]
+ lea eax, [ebx+ebp]
+ cmp eax, 80000000h
+ sbb ecx, ecx
+ and eax, ecx
+ cmp eax, 0x100
+ sbb ecx, ecx
+ not ecx
+ or eax, ecx
+ xor al, 0xFF
+ mul byte [esi+3]
+ add al, ah
+ adc ah, 0
+ add al, 80h
+ adc ah, 0
+ mov byte [edi+1], ah
+; R = Y + color_table_4[Cr]
+ mov eax, ebx
+ add eax, [color_table_4+edx*4]
+ cmp eax, 80000000h
+ sbb ecx, ecx
+ and eax, ecx
+ cmp eax, 0x100
+ sbb ecx, ecx
+ not ecx
+ or eax, ecx
+ xor al, 0xFF
+ mul byte [esi+3]
+ add al, ah
+ adc ah, 0
+ add al, 80h
+ adc ah, 0
+ mov byte [edi+2], ah
+ add esi, 4
+ add edi, 3
+ sub dword [esp], 1
+ jnz .kloop
+ pop eax
+ pop ebx
+; now correct values in RAW header
+ mov byte [ebx+12], 24
+ mov byte [ebx+18], 3
+ mov ecx, [ebx+32]
+ shr ecx, 2
+ lea ecx, [ecx*3]
+ mov [ebx+22], ecx
+; release some memory - must succeed because we decrease size
+ add ecx, 44+1
+ mov edx, ebx
+ push 68
+ pop eax
+ push 20
+ pop ebx
+ int 0x40
+ mov ebx, eax
+ ret
+
+; Decodes one data unit, that is, 8*8 block,
+; from input stream, given by pointer esi and length ebp
+; N.B. Speed optimization has sense here.
+align 16
+decode_data_unit:
+; edx -> component data
+ cmp [progressive], 0
+ jz @f
+ mov edi, [edx+20]
+ add dword [edx+20], 64*2
+ jmp .coeff_decoded
+@@:
+ mov edi, dct_coeff
+ mov ecx, 64*2/4
+ xor eax, eax
+ rep stosd
+ mov edi, zigzag+1
+ mov ecx, [huffman_bits]
+; read DC coefficient
+ mov eax, [edx+16]
+ push edx
+ get_huffman_code
+ get_bits true
+ add eax, [edx+48]
+ mov [dct_coeff], ax
+ mov [edx+48], ax
+; read AC coefficients
+@@:
+ mov eax, [edx+20]
+ push edx
+ get_huffman_code
+ shr eax, 4
+ and ebx, 15
+ jz .band
+ add edi, eax
+ cmp edi, zigzag+64
+ jae .eof
+ get_bits true
+ movzx ebx, byte [edi]
+ mov [dct_coeff+ebx], ax
+ add edi, 1
+ cmp edi, zigzag+64
+ jb @b
+ jmp .do_idct
+.band:
+ pop edx
+ cmp al, 15
+ jnz .do_idct
+ add edi, 16
+ cmp edi, zigzag+64
+ jb @b
+; jmp .eof
+.do_idct:
+ mov edi, dct_coeff
+ mov [huffman_bits], ecx
+; coefficients loaded, now IDCT
+.coeff_decoded:
+ mov eax, [edx+12]
+ mov ebx, idct_tmp_area
+.idct_loop1:
+ mov cx, word [edi+1*16]
+repeat 6
+ or cx, word [edi+(%+1)*16]
+end repeat
+ jnz .real_transform
+ fild word [edi]
+ fmul dword [eax]
+ fstp dword [ebx]
+ mov ecx, [ebx]
+repeat 7
+ mov [ebx+%*32], ecx
+end repeat
+ jmp .idct_next1
+.real_transform:
+; S0,...,S7 - transformed values, s0,...,s7 - sought-for values
+; S0,...,S7 are dequantized;
+; dequantization table elements were multiplied to [idct_pre_table],
+; so S0,S1,... later denote S0/2\sqrt{2},S1*\cos{\pi/16}/2,...
+; sqrt2 = \sqrt{2}, cos = 2\cos{\pi/8},
+; cos_sum = -2(\cos{\pi/8}+\cos{3\pi/8}), cos_diff = 2(\cos{\pi/8}-\cos{3\pi/8})
+; Now formulas:
+; s0 = ((S0+S4)+(S2+S6)) + ((S1+S7)+(S3+S5))
+; s7 = ((S0+S4)+(S2+S6)) - ((S1+S7)+(S3+S5))
+; val0 = ((cos-1)S1-(cos+cos_sum+1)S3+(cos+cos_sum-1)S5-(cos+1)S7)
+; s1 = ((S0-S4)+((sqrt2-1)S2-(sqrt2+1)S6)) + val0
+; s6 = ((S0-S4)+((sqrt2-1)S2-(sqrt2+1)S6)) - val0
+; val1 = (S1+S7-S3-S5)sqrt2 - val0
+; s2 = ((S0-S4)-((sqrt2-1)S2-(sqrt2+1)S6)) + val1
+; s5 = ((S0-S4)-((sqrt2-1)S2-(sqrt2+1)S6)) - val1
+; val2 = (S1-S7)cos_diff - (S1-S3+S5-S7)cos + val1
+; s3 = ((S0+S4)-(S2+S6)) - val2
+; s4 = ((S0+S4)-(S2+S6)) + val2
+ fild word [edi+3*16]
+ fmul dword [eax+3*32]
+ fild word [edi+5*16]
+ fmul dword [eax+5*32] ; st0=S5,st1=S3
+ fadd st1,st0
+ fadd st0,st0
+ fsub st0,st1 ; st0=S5-S3,st1=S5+S3
+ fild word [edi+1*16]
+ fmul dword [eax+1*32]
+ fild word [edi+7*16]
+ fmul dword [eax+7*32] ; st0=S7,st1=S1
+ fsub st1,st0
+ fadd st0,st0
+ fadd st0,st1 ; st0=S1+S7,st1=S1-S7,st2=S5-S3,st3=S5+S3
+ fadd st3,st0
+ fadd st0,st0
+ fsub st0,st3 ; st0=S1-S3-S5+S7,st1=S1-S7,st2=S5-S3,st3=S1+S3+S5+S7
+ fmul [idct_sqrt2]
+ fld st2
+ fadd st0,st2
+ fmul [idct_cos] ; st0=(S1-S3+S5-S7)cos,st1=(S1-S3-S5+S7)sqrt2,
+ ; st2=S1-S7,st3=S5-S3,st4=S1+S3+S5+S7
+ fxch st2
+ fmul [idct_cos_diff]
+ fsub st0,st2 ; st0=(S1-S7)cos_diff - (S1-S3+S5-S7)cos
+ fxch st3
+ fmul [idct_cos_sum]
+ fadd st0,st2 ; st0=(S5-S3)cos_sum+(S1-S3+S5-S7)cos
+ fsub st0,st4 ; st0=val0
+ fsub st1,st0 ; st0=val0,st1=val1,st2=(S1-S3+S5-S7)cos,
+ ; st3=(S1-S7)cos_diff-(S1-S3+S5-S7)cos,st4=S1+S3+S5+S7
+ fxch st2
+ fstp st0
+ fadd st2,st0 ; st0=val1,st1=val0,st2=val2,st3=S1+S3+S5+S7
+
+ fild word [edi+0*16]
+ fmul dword [eax+0*32]
+ fild word [edi+4*16]
+ fmul dword [eax+4*32] ; st0=S4,st1=S0
+ fsub st1,st0
+ fadd st0,st0
+ fadd st0,st1 ; st0=S0+S4,st1=S0-S4
+ fild word [edi+6*16]
+ fmul dword [eax+6*32]
+ fild word [edi+2*16]
+ fmul dword [eax+2*32] ; st0=S2,st1=S6
+ fadd st1,st0
+ fadd st0,st0
+ fsub st0,st1 ; st0=S2-S6,st1=S2+S6
+ fmul [idct_sqrt2]
+ fsub st0,st1
+ fsub st3,st0
+ fadd st0,st0
+ fadd st0,st3 ; st0=(S0-S4)+((S2-S6)sqrt2-(S2+S6))
+ ; st3=(S0-S4)-((S2-S6)sqrt2-(S2+S6))
+ fxch st1
+ fsub st2,st0
+ fadd st0,st0
+ fadd st0,st2 ; st0=(S0+S4)+(S2+S6),st1=(S0-S4)+((S2-S6)sqrt2-(S2+S6)),
+ ; st2=(S0+S4)-(S2+S6),st3=(S0-S4)-((S2-S6)sqrt2-(S2+S6))
+ ; st4=val1,st5=val0,st6=val2,st7=S1+S3+S5+S7
+ fsubr st7,st0
+ fadd st0,st0
+ fsub st0,st7
+ fstp dword [ebx+0*32]
+ fsubr st4,st0
+ fadd st0,st0
+ fsub st0,st4
+ fstp dword [ebx+1*32]
+ fadd st4,st0
+ fadd st0,st0
+ fsub st0,st4
+ fstp dword [ebx+3*32]
+ fsubr st1,st0
+ fadd st0,st0
+ fsub st0,st1
+ fstp dword [ebx+2*32]
+ fstp dword [ebx+5*32]
+ fstp dword [ebx+6*32]
+ fstp dword [ebx+4*32]
+ fstp dword [ebx+7*32]
+.idct_next1:
+ add ebx, 4
+ add edi, 2
+ add eax, 4
+ cmp ebx, idct_tmp_area+8*4
+ jb .idct_loop1
+ sub ebx, 8*4
+.idct_loop2:
+ fld dword [ebx+3*4]
+ fld dword [ebx+5*4]
+ fadd st1,st0
+ fadd st0,st0
+ fsub st0,st1 ; st0=S5-S3,st1=S5+S3
+ fld dword [ebx+1*4]
+ fld dword [ebx+7*4]
+ fsub st1,st0
+ fadd st0,st0
+ fadd st0,st1 ; st0=S1+S7,st1=S1-S7,st2=S5-S3,st3=S5+S3
+ fadd st3,st0
+ fadd st0,st0
+ fsub st0,st3 ; st0=S1-S3-S5+S7,st1=S1-S7,st2=S5-S3,st3=S1+S3+S5+S7
+ fmul [idct_sqrt2]
+ fld st2
+ fadd st0,st2
+ fmul [idct_cos] ; st0=(S1-S3+S5-S7)cos,st1=(S1-S3-S5+S7)sqrt2,
+ ; st2=S1-S7,st3=S5-S3,st4=S1+S3+S5+S7
+ fxch st2
+ fmul [idct_cos_diff]
+ fsub st0,st2 ; st0=(S1-S7)cos_diff - (S1-S3+S5-S7)cos
+ fxch st3
+ fmul [idct_cos_sum]
+ fadd st0,st2 ; st0=(S5-S3)cos_sum+(S1-S3+S5-S7)cos
+ fsub st0,st4 ; st0=val0
+ fsub st1,st0 ; st0=val0,st1=val1,st2=(S1-S3+S5-S7)cos,
+ ; st3=(S1-S7)cos_diff-(S1-S3+S5-S7)cos,st4=S1+S3+S5+S7
+ fxch st2
+ fstp st0
+ fadd st2,st0 ; st0=val1,st1=val0,st2=val2,st3=S1+S3+S5+S7
+
+ fld dword [ebx+0*4]
+ fld dword [ebx+4*4]
+ fsub st1,st0
+ fadd st0,st0
+ fadd st0,st1 ; st0=S0+S4,st1=S0-S4
+ fld dword [ebx+6*4]
+ fld dword [ebx+2*4]
+ fadd st1,st0
+ fadd st0,st0
+ fsub st0,st1 ; st0=S2-S6,st1=S2+S6
+ fmul [idct_sqrt2]
+ fsub st0,st1
+ fsub st3,st0
+ fadd st0,st0
+ fadd st0,st3 ; st0=(S0-S4)+((S2-S6)sqrt2-(S2+S6))
+ ; st3=(S0-S4)-((S2-S6)sqrt2-(S2+S6))
+ fxch st1
+ fsub st2,st0
+ fadd st0,st0
+ fadd st0,st2 ; st0=(S0+S4)+(S2+S6),st1=(S0-S4)+((S2-S6)sqrt2-(S2+S6)),
+ ; st2=(S0+S4)-(S2+S6),st3=(S0-S4)-((S2-S6)sqrt2-(S2+S6))
+ ; st4=val1,st5=val0,st6=val2,st7=S1+S3+S5+S7
+ fsubr st7,st0
+ fadd st0,st0
+ fsub st0,st7
+ fistp dword [ebx+0*4]
+ fsubr st4,st0
+ fadd st0,st0
+ fsub st0,st4
+ fistp dword [ebx+1*4]
+ fadd st4,st0
+ fadd st0,st0
+ fsub st0,st4
+ fistp dword [ebx+3*4]
+ fsubr st1,st0
+ fadd st0,st0
+ fsub st0,st1
+ fistp dword [ebx+2*4]
+ fistp dword [ebx+5*4]
+ fistp dword [ebx+6*4]
+ fistp dword [ebx+4*4]
+ fistp dword [ebx+7*4]
+
+ add ebx, 32
+ cmp ebx, idct_tmp_area+32*8
+ jb .idct_loop2
+
+ mov ecx, idct_tmp_area
+ mov edi, decoded_data - 1
+.idct_loop3:
+ mov eax, [ecx]
+ add ecx, 4
+ add eax, 80h
+ cmp eax, 80000000h
+ sbb ebx, ebx
+ add edi, 1
+ and eax, ebx
+ cmp eax, 100h
+ sbb ebx, ebx
+ not ebx
+ or eax, ebx
+ sub al, [edx+51]
+ cmp ecx, idct_tmp_area+64*4
+ mov [edi], al
+ jb .idct_loop3
+; done
+ mov ebx, [_ebx]
+ ret
+
+.eof:
+; EOF or incorrect data during scanning
+ mov esp, [_esp]
+ mov ebx, [_ebx]
+ jmp START.end
+;---------------------------------------------------------------------
+check_header:
+ pushad
+ mov eax,dword [esp+36]
+ push eax
+ and dword [eax+8], 0
+ mov esi, [eax]
+ mov ebp, [eax+12]
+ call get_marker
+ jc .err
+ cmp al, 0xD8
+ jnz .err
+ pop eax
+ popad
+ ret 4
+.err:
+ pop eax
+ inc dword [eax+8]
+ popad
+ ret 4
+;---------------------------------------------------------------------
+zigzag:
+; (x,y) -> 2*(x+y*8)
+repeat 8
+ .cur = %
+ if .cur and 1
+ repeat %
+ db 2*((%-1) + (.cur-%)*8)
+ end repeat
+ else
+ repeat %
+ db 2*((.cur-%) + (%-1)*8)
+ end repeat
+ end if
+end repeat
+repeat 7
+ .cur = %
+ if .cur and 1
+ repeat 8-%
+ db 2*((%+.cur-1) + (8-%)*8)
+ end repeat
+ else
+ repeat 8-%
+ db 2*((8-%) + (%+.cur-1)*8)
+ end repeat
+ end if
+end repeat
+
+align 4
+idct_pre_table:
+; c_0 = 1/(2\sqrt{2}), c_i = cos(i*\pi/16)/2
+ dd 0.35355339, 0.49039264, 0.461939766, 0.41573481
+ dd 0.35355339, 0.27778512, 0.19134172, 0.09754516
+idct_sqrt2 dd 1.41421356 ; \sqrt{2}
+idct_cos dd 1.847759065 ; 2\cos{\pi/8}
+idct_cos_sum dd -2.61312593 ; -2(\cos{\pi/8} + \cos{3\pi/8})
+idct_cos_diff dd 1.08239220 ; 2(\cos{\pi/8} - \cos{3\pi/8})
+;---------------------------------------------------------------------
+Associations:
+dd Associations.end - Associations
+db 'JPEG',0
+db 'JPG',0
+db 'JPE',0
+.end:
+db 0
+;---------------------------------------------------------------------
+align 4
+EXPORTS:
+ dd szStart, START
+ dd szVersion, 0x00010002
+ dd szCheck, check_header
+ dd szAssoc, Associations
+ dd 0
+
+szStart db 'START',0
+szVersion db 'version',0
+szCheck db 'Check_Header',0
+szAssoc db 'Associations',0
+
+section '.data' data readable writable align 16
+
+; up to 4 quantization tables
+quant_tables rd 4*64
+quant_tables_defined rb 4
+
+; Huffman tables
+dc_huffman_defined rb 4
+ac_huffman_defined rb 4
+; up to 4 DC Huffman tables
+;dc_huffman rd 4*256*2
+; up to 4 AC Huffman tables
+;ac_huffman rd 4*256*2
+max_hufftable_size = (256 + (9+128)*16)*2
+dc_huffman rb 4*max_hufftable_size
+ac_huffman rb 4*max_hufftable_size
+
+; restart interval
+restart_interval dd ?
+decoded_MCUs dd ?
+
+; base esp,ebx values
+_esp dd ?
+_ebx dd ?
+
+; components information, up to 4 components
+; db ComponentIdentifier, db V, db H, db VFactor, db HFactor, db QuantizationTable
+components rb 4*6
+max_v db ?
+max_h db ?
+cur_rst_marker db ?
+ db ?
+huffman_bits dd ?
+block_width dd ?
+block_height dd ?
+block_delta_x dd ?
+block_delta_y dd ?
+cur_block_dx dd ?
+cur_block_dy dd ?
+x_num_blocks dd ?
+y_num_blocks dd ?
+delta_x dd ?
+delta_y dd ?
+pixel_size dd ?
+line_size dd ?
+cur_x dd ?
+cur_y dd ?
+max_x dd ?
+max_y dd ?
+cur_out_ptr dd ?
+dct_buffer dd ?
+dct_buffer_size dd ?
+;ns dd ?
+; +0: db V, db H, db VFactor, db HFactor, dd HIncrement, dd VIncrement,
+; +12: dd QuantizationTable, dd DCTable, dd ACTable,
+; +24: dd width/HFactor, dd width/HFactor-8k, dd HFactor+1-(width%HFactor),
+; +36: dd height/VFactor, dd height/VFactor-8m, dd VFactor+1-(height%VFactor),
+; +48: dw DCPrediction, db ?, db (0 for Y, 80h for Cb,Cr), dd ComponentOffset
+cur_components rb 4*56
+cur_components_end dd ?
+; progressive JPEG?
+progressive db ?
+; one component in the scan?
+not_interleaved db ?
+; Adobe YCCK file?
+adobe_ycck db ?
+ rb 1
+; parameters for progressive scan
+ScanStart db ?
+ScanEnd db ?
+ApproxPosLow db ?
+ApproxPosHigh db ?
+; Fourier coefficients
+dct_coeff rw 64
+; Temporary space for IDCT
+idct_tmp_area rd 64
+; decoded block 8*8
+decoded_data rb 8*8
+; data for YCbCr -> RGB translation
+color_table_1 rd 256
+color_table_2 rd 256
+color_table_3 rd 256
+color_table_4 rd 256
diff --git a/programs/media/zsea/plugins/png/build.bat b/programs/media/zsea/plugins/png/build.bat
new file mode 100644
index 0000000000..ea8ed4d969
--- /dev/null
+++ b/programs/media/zsea/plugins/png/build.bat
@@ -0,0 +1,3 @@
+@fasm -m 16384 cnv_png.asm cnv_png.obj
+@kpack cnv_png.obj
+@pause
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/png/build.sh b/programs/media/zsea/plugins/png/build.sh
new file mode 100644
index 0000000000..f194035d93
--- /dev/null
+++ b/programs/media/zsea/plugins/png/build.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# This script does for Linux the same as build.bat for DOS,
+# it compiles the current KolibriOS applications
+
+ fasm -m 16384 cnv_png.asm cnv_png.obj
+ kpack cnv_png.obj
+ exit 0
+
+
+
diff --git a/programs/media/zsea/plugins/png/cnv_png.asm b/programs/media/zsea/plugins/png/cnv_png.asm
new file mode 100644
index 0000000000..ba11d366a6
--- /dev/null
+++ b/programs/media/zsea/plugins/png/cnv_png.asm
@@ -0,0 +1,896 @@
+;*****************************************************************************
+; PNG to RAW convert plugin - for zSea image viewer
+; Copyright (c) 2008-2011, Marat Zakiyanov aka Mario79, aka Mario
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;*****************************************************************************
+
+format MS COFF
+
+public EXPORTS
+
+section '.flat' code readable align 16
+
+;include 'macros.inc'
+include '../../../../macros.inc'
+;---------------------------------------------------------------------
+START:
+ pushad
+ mov eax,dword [esp+36]
+ call check_header_1
+ je header_OK
+;---------------------------------------------------------------------
+no_png_file:
+ xor eax,eax
+ mov [raw_area],eax
+ inc eax ; data corrupt eax = 1
+ jmp header_OK.ret
+;---------------------------------------------------------------------
+check_header_1:
+ mov [pointer],eax
+ mov ebx,[eax]
+ mov [image_file],ebx
+ cmp [ebx],dword 0x474E5089 ; check main label p.1
+ jne @f ;no_png_file
+ cmp [ebx+4],dword 0x0A1A0A0D ; check main label p.2
+ ret
+@@:
+ add esp,4
+ jmp no_png_file
+;---------------------------------------------------------------------
+header_OK:
+ mov ebx,[eax+12] ; file size
+ mov [file_size],ebx
+;---------------------------------------------------------------------
+ mov ebx,[eax+16]
+ mov [deflate_unpack],ebx
+;---------------------------------------------------------------------
+ mov ebx,[pointer]
+;---------------------------------------------------------------------
+ xor eax,eax
+; mov [IDAT.pointer],eax
+; mov [IDAT.size],eax
+ mov [deflate_start_offset],eax
+ mov eax,[image_file]
+ mov [next_Chunk],eax
+ call search_IHDR
+ call search_IDAT
+; call search_IEND
+;---------------------------------------------------------------------
+ mov eax,[IHDR.pointer]
+ mov ecx,[eax] ; get width PNG
+ call convert_NBO_to_PC
+ mov [IHDR_data.Width],ecx ; store width PNG
+ mov [Image_Width],ecx
+ mov ecx,[eax+4] ; get height PNG
+ call convert_NBO_to_PC
+ mov [IHDR_data.Height],ecx ; store height PNG
+ mov [Image_Height],ecx
+ mov ecx,[eax+9] ; Color type
+ ; Compression method
+ ; Filter method
+ ; Interlace method
+ mov [IHDR_data.Color_type],ecx
+ xor ecx,ecx
+ mov cl,[eax+8] ; Bit depth
+ mov [IHDR_data.Bit_depth],cl
+;---------------------------------------------------------------------
+ mov al,[eax+9] ; check Color type
+ cmp al,byte 0 ; Each pixel is a grayscale sample.
+ je .resolution
+ cmp al,byte 2 ; Each pixel is an R,G,B triple.
+ je .Bit_depth_2
+ cmp al,byte 3 ; Each pixel is a palette index
+ ; a PLTE chunk must appear.
+ jne .no_PLTE
+ call search_PLTE
+ jmp .resolution
+.no_PLTE:
+ cmp al,byte 4 ; Each pixel is a grayscale sample,
+ ; followed by an alpha sample.
+ je .Bit_depth_4
+ cmp al,byte 6 ; Each pixel is an R,G,B triple,
+ ; followed by an alpha sample.
+ jne no_png_file
+;---------------------------------------------------------------------
+.Bit_depth_6:
+ shl ecx,1
+
+.Bit_depth_4:
+ shl ecx,1
+ jmp .resolution
+
+.Bit_depth_2:
+ lea ecx,[ecx*3]
+
+.resolution:
+;---------------------------------------------------------------------
+ cmp [IHDR_data.Compression_method], byte 0 ; check Compression method
+ jne no_png_file
+
+ cmp [IHDR_data.Filter_method], byte 0 ; check Filtering method
+ jne no_png_file
+
+ cmp [IHDR_data.Interlace_method], byte 0 ; No Interlaced
+ je @f
+ cmp [IHDR_data.Interlace_method], byte 1 ; Interlaced
+ jne no_png_file
+@@:
+;---------------------------------------------------------------------
+ mov [resolution],ecx
+ imul ecx,[IHDR_data.Width]
+ mov edi,ecx
+ shr ecx,3
+ test edi,7
+ jz @f
+ inc ecx
+@@:
+ imul ecx,[IHDR_data.Height]
+ cmp [IHDR_data.Color_type],byte 3
+ jne @f
+ mov eax,[PLTE.size]
+ mov ebx,3
+ xor edx,edx
+ div ebx
+ shl eax,2
+ add ecx,eax ; PLTE table area
+ jmp .RAW_header
+;--------------------------------------
+@@:
+ cmp [IHDR_data.Color_type],byte 0
+ je @f
+ cmp [IHDR_data.Color_type],byte 4
+ jne .RAW_header
+@@:
+ push ecx
+ mov eax,1
+ movzx ecx,byte [IHDR_data.Bit_depth]
+ cmp ecx,16
+ jne @f
+ shr ecx,1
+@@:
+ shl eax,cl
+ shl eax,2
+ pop ecx
+ add ecx,eax
+; mov ebx,[pointer]
+; mov [ebx+20],eax
+;--------------------------------------
+.RAW_header:
+ add ecx,44 ; RAW header
+; mov ebx,[pointer]
+; mov [ebx+24],ecx
+; shl ecx,1
+ mcall 68, 12
+ cmp eax,0
+ jne @f
+ xor eax,eax
+ mov [raw_area],eax ; store pointer of image area
+ mov eax,2 ; not enough memory
+ jmp .ret
+@@:
+ mov [raw_area],eax
+; mov ebx,[pointer]
+; mov [ebx+28],eax
+;---------------------------------------------------------------------
+ mov edi,eax
+ xor eax,eax
+ shr ecx,2
+ cld
+ rep stosd ; clear memory
+;---------------------------------------------------------------------
+; Create RAW header
+;---------------------------------------------------------------------
+ mov eax,[raw_area]
+ mov [eax],dword 'RAW '
+;---------------------------------------------------------------------
+ mov ecx,[IHDR_data.Width] ; width BMP
+ mov [eax+4],ecx ; width RAW
+;---------------------------------------------------------------------
+ mov ecx,[IHDR_data.Height] ; high BMP
+ mov [eax+8],ecx ;high RAW
+;---------------------------------------------------------------------
+ mov ecx,[resolution] ; color resolution BMP
+ mov [eax+12],ecx ;color resolution RAW
+;---------------------------------------------------------------------
+ xor ecx,ecx
+ mov cl,[IHDR_data.Bit_depth]
+ mov [eax+16],cx ;channel color resolution RAW
+;---------------------------------------------------------------------
+ mov ecx,[IHDR_data.Color_type]
+ xor ebx,ebx
+ inc ebx
+ cmp cl,byte 0 ; Each pixel is a grayscale sample.
+ je .1
+ cmp cl,byte 2 ; Each pixel is an R,G,B triple.
+ je .Bit_depth_2_1
+ cmp cl,byte 3 ; Each pixel is a palette index
+ ; a PLTE chunk must appear.
+ je .1
+ cmp cl,byte 4 ; Each pixel is a grayscale sample,
+ ; followed by an alpha sample.
+ je .Bit_depth_4_1
+ cmp cl,byte 6
+ jne no_png_file
+.Bit_depth_6_1:
+ shl ebx,1
+.Bit_depth_4_1:
+ shl ebx,1
+ jmp .1
+.Bit_depth_2_1:
+ lea ebx,[ebx*3]
+.1:
+ mov [eax+18],bx ; channels amount RAW
+;---------------------------------------------------------------------
+ xor edx,edx
+ cmp cl,byte 3 ; Each pixel is a palette index
+ ; a PLTE chunk must appear.
+ je @f
+ cmp cl,0
+ je @f
+ cmp cl,4
+ jne .no_PLTE_1
+@@:
+ add edx,44
+ mov [eax+20],edx ; palette pointer (offset from file start)
+;---------------------------------------------------------------------
+ cmp cl,0
+ je @f
+ cmp cl,4
+ jne .PLTE
+@@:
+ mov ecx,256*4
+ jmp .PLTE_1
+.PLTE:
+ push eax
+ mov eax,[PLTE.size]
+ xor edx,edx
+ mov ebx,3
+ div ebx
+ shl eax,2
+ mov ecx,eax
+ pop eax
+.PLTE_1:
+ mov [eax+24],ecx ; palette area size
+ jmp @f
+.no_PLTE_1:
+ xor ecx,ecx
+@@:
+;---------------------------------------------------------------------
+ add ecx,dword 44
+ mov [eax+28],ecx ; pixels pointer (offset from file start)
+; mov ebx,[pointer]
+; mov [ebx+44],ecx
+;---------------------------------------------------------------------
+ mov ecx, [IHDR_data.Width] ; width BMP
+ imul ecx,[resolution]
+ mov edi,ecx
+ shr ecx,3
+ test edi,7
+ jz @f
+ inc ecx
+@@:
+ imul ecx,[IHDR_data.Height] ; high BMP
+ mov [eax+32],ecx ; pixels area size
+;---------------------------------------------------------------------
+ xor ecx,ecx ; Stub!!!
+ mov [eax+36],ecx ;Transparency pointer (offset from file start)
+ mov [eax+40],ecx ;Transparency area size
+
+;---------------------------------------------------------------------
+; Finish create RAW header
+;---------------------------------------------------------------------
+
+ mov eax,[raw_area]
+ mov edi,[eax+20] ; palette pointer (offset from file start)
+ add edi,eax
+
+ mov esi,[PLTE.pointer]
+ mov eax,[PLTE.size]
+ xor edx,edx
+ mov ebx,3
+ div ebx
+ mov ecx,eax
+ mov eax,[IHDR_data.Color_type]
+ cmp al,byte 0
+ je .grayscale_palette
+ cmp al,byte 4
+ je .grayscale_palette
+ cmp al,byte 3 ; Each pixel is a palette index
+ ; a PLTE chunk must appear.
+ jne .no_palette
+@@:
+ cld
+ lodsd
+ dec esi
+ and eax,0xffffff
+
+ mov bl,al
+ shr eax,8
+ xchg ah,bl
+ shl eax,8
+ mov al,bl
+
+ cld
+ stosd
+ dec ecx
+ jnz @r
+ jmp .no_palette
+;-------------------------------
+.grayscale_palette:
+; cmp [IHDR_data.Bit_depth], dword 1
+; jne @f
+; xor eax,eax
+; cld
+; stosd
+; dec eax
+; and eax,0xffffff
+; cld
+; stosd
+; jmp .no_palette
+@@:
+ mov eax,1
+ mov ecx,[resolution]
+ cmp ecx,8
+ jbe @f
+ mov ecx,8
+@@:
+ shl eax,cl
+ mov ecx,eax
+ mov eax,256
+; mov ebx,[resolution]
+ xor edx,edx
+ div ecx ;ebx
+ mov edx,eax
+ cmp edx,0
+ jne @f
+ inc edx
+@@:
+ xor eax,eax
+; mov eax,0xffffff
+; mov ecx,256
+
+@@:
+ cld
+ stosd
+; inc ah
+ add ah,dl
+; inc al
+ add al,dl
+ shl eax,8
+ mov al,ah
+
+; dec ah
+; dec al
+; shl eax,8
+; mov al,ah
+
+ and eax,0xffffff
+ dec ecx
+ jnz @r
+
+ sub edi,4
+ xor eax,eax
+ dec eax
+ and eax,0xffffff
+ cld
+ stosd
+;-------------------------------
+.no_palette:
+
+;---------------------------------------------------------------------
+ mov ebx,[IDAT.pointer]
+ mov al,[ebx]
+ mov [IDAT_CMF],al ; Compression Method and flags
+ mov ah,al
+ and al,1111b
+ mov [IDAT_],al ; Compression method
+ shr ah,4
+ mov [IDAT_CINFO],ah ; Compression info
+ mov al,[ebx+1]
+ mov [IDAT_FLG],al ; FLaGs
+ mov ah,al
+ and al,11111b
+ mov [IDAT_FCHECK],al
+ mov al,ah
+ and al,100000b
+ shr al,5
+ mov [IDAT_FDICT],al ; Preset dictionary
+ shr ah,6
+ mov [IDAT_FLEVEL],ah ; Compression level
+ mov al,[IDAT_]
+; test al,1000b ; Compression method = 8 ?
+ cmp al,8
+ jnz no_png_file
+ add [IDAT.pointer],2
+ sub [IDAT.size],2
+; xor eax,eax
+; mov ah,[IDAT_FLG]
+; mov al,[IDAT_CMF]
+; imul eax,31
+; shr eax,16
+; cmp [IDAT_FCHECK],al
+; jne no_png_file
+
+;
+; cmp [IDAT_FDICT],1
+; jne .no_IDAT_FDICT
+; mov ecx,[ebx+2]
+; jmp .IDAT_DICT
+;.no_IDAT_FDICT:
+; mov eax,[IDAT.pointer]
+; add eax,[IDAT.size]
+; mov ecx,[eax]
+;.IDAT_DICT:
+; call convert_NBO_to_PC
+; mov [IDAT_DICT],ecx
+; jmp .ret_ok
+
+; jmp no_png_file
+
+; mov ecx,[file_size]
+; mcall 68, 12
+; mov [IDAT_raw_area],eax ; store pointer of image area
+;---------------------------------------------------------------------
+.start_Deflate_unpack:
+ push eax ; *pUnpackedLength
+ ; ,
+ ; push <>
+ push esp ; pUnpackedLength
+ push esi ; -
+ push deflate_callback
+ call [deflate_unpack]
+ pop ecx ; UnpackedLength
+; , eax = , ecx =
+ mov [unpacked_data],eax
+ mov esi,eax
+;---------------------------------------------------------------------
+ mov eax,[raw_area]
+ mov edi,[eax+28] ; pixels pointer (offset from file start)
+ add edi,eax
+; mov ecx,edx
+ sub ecx,[IHDR_data.Height]
+ mov [first_line],byte 1
+ cmp [IHDR_data.Color_type],byte 0
+ je .PLTE_and_grayscale
+ cmp [IHDR_data.Color_type],byte 3
+ je .PLTE_and_grayscale
+ cmp [IHDR_data.Color_type],byte 4
+ je .PLTE_and_grayscale
+;---------------------------------------------------------------------
+; Processing filtering RGB; type 2 and 6, sample 8b
+;---------------------------------------------------------------------
+ mov eax,ecx
+; sub eax,[IHDR_data.Height]
+ xor edx,edx
+ mov ebx,3
+ cmp [IHDR_data.Color_type],byte 6
+ jne @f
+ inc ebx
+@@:
+ cmp [IHDR_data.Bit_depth],byte 16
+ jne @f
+ shl ebx,1
+@@:
+ div ebx
+ mov ecx,eax
+ cmp [IHDR_data.Bit_depth],byte 16
+ je .filter_Bit_depth_16
+; jmp .ret_ok
+;---------------------------------------------------------------------
+ cmp [IHDR_data.Interlace_method], byte 0 ; Interlaced
+ je @f
+ call filtering_RGB_Interlaced
+ jmp .converting_MSB_to_LSB
+@@:
+;---------------------------------------------------------------------
+ push edi
+ call filtering_RGB
+ pop edi
+;---------------------------------------------------------------------
+; converting MSB to LSB
+; 24b = 1B x 3 sample
+; 32b = 1B x 4 sample
+.converting_MSB_to_LSB:
+ call .calculate_all_pixels
+ mov ebx,3
+ cmp [IHDR_data.Color_type],byte 6
+ jne @f
+ inc ebx
+@@:
+ sub edi,ebx
+@@:
+ add edi,ebx
+ mov al,[edi]
+ mov ah,[edi+2]
+ mov [edi+2],al
+ mov [edi],ah
+ dec ecx
+ jnz @r
+ jmp .ret_ok
+;---------------------------------------------------------------------
+.calculate_all_pixels:
+ mov ecx,[Image_Height]
+ imul ecx,[Image_Width]
+ ret
+;---------------------------------------------------------------------
+; Processing filtering RGB; type 2 and 6, sample 16b
+;---------------------------------------------------------------------
+.filter_Bit_depth_16:
+ cmp [IHDR_data.Interlace_method], byte 0 ; Interlaced
+ je @f
+ call filtering_RGB_16_Interlaced
+ jmp .converting_MSB_to_LSB_16
+@@:
+;---------------------------------------------------------------------
+ push edi
+ call filtering_RGB_16
+ pop edi
+;---------------------------------------------------------------------
+; converting MSB to LSB 48 or 64b
+; 48b = 2B x 3 sample
+; 64b = 2B x 4 sample
+.converting_MSB_to_LSB_16:
+ call .calculate_all_pixels
+ mov ebx,3
+ cmp [IHDR_data.Color_type],byte 6
+ jne @f
+ inc ebx
+@@:
+ shl ebx,1
+
+ sub edi,ebx
+@@:
+ add edi,ebx
+
+ mov ax,[edi]
+ xchg al,ah
+ shl eax,16
+ mov ax,[edi+4]
+ xchg al,ah
+ mov [edi],ax
+ shr eax,16
+ mov [edi+4],ax
+
+ mov ax,[edi+2]
+ xchg al,ah
+ mov [edi+2],ax
+
+; mov ax,[edi+6]
+; xchg al,ah
+; mov [edi+6],al
+
+ dec ecx
+ jnz @r
+ jmp .ret_ok
+;---------------------------------------------------------------------
+; Processing filtering Grayscale and RGB; type 2, 3 and 4, sample 8b
+;---------------------------------------------------------------------
+.PLTE_and_grayscale:
+ cmp [IHDR_data.Color_type],byte 4
+ jne @f
+ shr ecx,1
+@@:
+ cmp [IHDR_data.Bit_depth],byte 16
+ jne @f
+ shr ecx,1
+ jmp .filter_grayscale_Bit_depth_16_1
+@@:
+;---------------------------------------------------------------------
+ cmp [IHDR_data.Interlace_method], byte 0 ; Interlaced
+ je @f
+ call filtering_grayscale_Interlaced
+ jmp .continue_1
+@@:
+;---------------------------------------------------------------------
+ push edi
+ call filtering_grayscale
+ pop edi
+;---------------------------------------------------------------------
+.continue_1:
+ cmp [IHDR_data.Color_type],byte 4
+ jne .ret_ok
+;-------------------------------
+; 8b or less
+ mov esi,edi
+ call .calculate_all_pixels
+.convert_transp_to_notransp:
+ cld
+ lodsw
+ stosb
+ dec ecx
+ jnz .convert_transp_to_notransp
+
+ jmp .ret_ok
+;---------------------------------------------------------------------
+; Processing filtering Grayscale and RGB; type 2, 3 and 4, sample 16b
+;---------------------------------------------------------------------
+.filter_grayscale_Bit_depth_16_1:
+ cmp [IHDR_data.Interlace_method], byte 0 ; Interlaced
+ je @f
+ call filtering_grayscale_16_Interlaced
+ jmp .continue_2
+@@:
+;---------------------------------------------------------------------
+ push edi
+ call filtering_grayscale_16
+ pop edi
+;---------------------------------------------------------------------
+.continue_2:
+ cmp [IHDR_data.Color_type],byte 4
+ jne .ret_ok
+;-------------------------------
+; 16b
+ mov esi,edi
+ call .calculate_all_pixels
+.convert_transp_to_notransp_1:
+ cld
+ lodsd
+ stosw
+ dec ecx
+ jnz .convert_transp_to_notransp_1
+;---------------------------------------------------------------------
+.ret_ok:
+ mov ecx,[unpacked_data]
+ mcall 68, 13,
+ xor eax,eax
+;---------------------------------------------------------------------
+.ret:
+ mov ebx,[pointer]
+ mov [ebx+8],eax ; store return code
+ mov eax,[raw_area]
+ mov [ebx+4],eax ; store RAW pointer
+ popad
+ ret 4
+;---------------------------------------------------------------------
+include 'filter.inc'
+include 'proced.inc'
+include 'fl_call.inc'
+include 'interlac.inc'
+;---------------------------------------------------------------------
+Check_Header:
+ pushad
+ mov eax,dword [esp+36]
+ call check_header_1
+ jne no_png_file
+ popad
+ ret 4
+;---------------------------------------------------------------------
+Associations:
+ dd Associations.end - Associations
+ db 'PNG',0
+.end:
+ db 0
+;---------------------------------------------------------------------
+align 4
+EXPORTS:
+ dd szStart, START
+ dd szVersion, 0x00010002
+ dd szCheck, Check_Header
+ dd szAssoc, Associations
+ dd 0
+
+szStart db 'START',0
+szVersion db 'version',0
+szCheck db 'Check_Header',0
+szAssoc db 'Associations',0
+
+;*****************************************************************************
+; Chunks names
+;*****************************************************************************
+; Critical chunks
+IHDR_name: db 'IHDR' ; Image header
+PLTE_name: db 'PLTE' ; Palette
+IDAT_name: db 'IDAT' ; Image data
+IEND_name: db 'IEND' ; Image trailer
+
+; Ancillary chunks
+;tRNS_name: db 'tRNS' ; Transparency
+
+;; Color space information
+;gAMA_name: db 'gAMA' ; Image gamma
+;cHRM_name: db 'cHRM' ; Primary chromaticities
+;sRGB_name: db 'sRGB' ; Standard RGB color space
+;iCCP_name: db 'iCCP' ; Embedded ICC profile
+
+;; Textual information
+;tEXt_name: db 'tEXt' ; Textual data
+;zTXt_name: db 'zTXt' ; Compressed textual data
+;iTXt_name: db 'iTXt' ; International textual data
+
+;; Miscellaneous information
+;bKGD_name: db 'bKGD' ; Background color
+;pHYs_name: db 'pHYs' ; Physical pixel dimensions
+;sBIT_name: db 'sBIT' ; Significant bits
+;sPLT_name: db 'sPLT' ; Suggested palette
+;hIST_name: db 'hIST' ; Palette histogram
+;tIME_name: db 'tIME' ; Imagelast-modification time
+;*****************************************************************************
+calculate_Interlaced_counters:
+.1: dd calculate_Interlaced_1
+.2: dd calculate_Interlaced_2
+.3: dd calculate_Interlaced_3
+.4: dd calculate_Interlaced_4
+.5: dd calculate_Interlaced_5
+.6: dd calculate_Interlaced_6
+.7: dd calculate_Interlaced_7
+
+deflate_start_offset dd 0
+
+pointer dd 0
+image_file dd 0
+file_size dd 0
+raw_area dd 0
+resolution dd 0
+
+Chunk_pointer dd 0
+next_Chunk dd 0
+
+deflate_unpack dd 0
+
+unpacked_data dd 0
+;IDAT_raw_area dd 0
+;IDAT_raw_counter dd 0
+
+Interlaced_area dd 0
+
+Starting_Row: dd 0
+Starting_Col: dd 0
+Row_Increment: dd 0
+Col_Increment: dd 0
+
+Interlaced_step dd 0
+
+
+counter_IDAT_Chunk dd 0
+
+;CRC32 dd 0
+;CRC32table: rd 256
+;Adler32 dd 0
+
+Image_Width dd 0
+Image_Height dd 0
+
+IHDR_data:
+.Width dd 0 ;+0
+.Height dd 0 ;+4
+.Bit_depth: db 0 ;+8
+.Color_type: db 0 ;+9
+.Compression_method: db 0 ;+10
+.Filter_method: db 0 ;+11
+.Interlace_method: db 0 ;+12
+
+IDAT_CMF db 0 ; Compression Method and flags
+ IDAT_ db 0 ; Compression method
+ IDAT_CINFO db 0 ; Compression info
+IDAT_FLG db 0 ; FLaGs
+ IDAT_FCHECK db 0 ;
+ IDAT_FDICT db 0 ; Preset dictionary
+ IDAT_FLEVEL db 0 ; Compression level
+ ; "deflate" method (CM = 8) sets these flags:
+ ; 0 - compressor used fastest algorithm
+ ; 1 - compressor used fast algorithm
+ ; 2 - compressor used default algorithm
+ ; 3 - compressor used maximum compression, slowest algorithm
+IDAT_DICT dd 0 ; dictionary identifier = Adler-32 checksum
+BFINAL db 0 ; set 1 only if this is the last block of the data set
+BTYPE db 0 ; specifies how the data are compressed:
+ ; 00 - no compression
+ ; 01 - compressed with fixed Huffman codes
+ ; 10 - compressed with dynamic Huffman codes
+ ; 11 - reserved (error)
+
+line_filter_type dd 0 ; 0 None
+ ; 1 Sub
+ ; 2 Up
+ ; 3 Averag
+ ; 4 Paeth
+first_line db 0
+first_pixel db 0
+
+previous_pixel_value:
+ rb 8
+
+Paeth_filter:
+.a: dw 0
+.b: dw 0
+.c: dw 0
+.p dd 0
+.pa dd 0
+.pb dd 0
+.pc dd 0
+;*****************************************************************************
+; Chunks pointer
+;*****************************************************************************
+IHDR:
+.pointer dd 0
+.size dd 0
+
+PLTE:
+.pointer dd 0
+.size dd 0
+
+IDAT:
+.pointer dd 0
+.size dd 0
+
+IEND:
+.pointer dd 0
+.size dd 0
+
+;tRNS:
+;.pointer dd 0
+;.size dd 0
+
+;gAMA:
+;.pointer dd 0
+;.size dd 0
+
+;cHRM:
+;.pointer dd 0
+;.size dd 0
+
+;sRGB:
+;.pointer dd 0
+;.size dd 0
+
+;iCCP:
+;.pointer dd 0
+;.size dd 0
+
+;tEXt:
+;.pointer dd 0
+;.size dd 0
+
+;zTXt:
+;.pointer dd 0
+;.size dd 0
+
+;iTXt:
+;.pointer dd 0
+;.size dd 0
+
+;bKGD:
+;.pointer dd 0
+;.size dd 0
+
+;pHYs:
+;.pointer dd 0
+;.size dd 0
+
+;sBIT:
+;.pointer dd 0
+;.size dd 0
+
+;sPLT:
+;.pointer dd 0
+;.size dd 0
+
+;hIST:
+;.pointer dd 0
+;.size dd 0
+
+;tIME:
+;.pointer dd 0
+;.size dd 0
diff --git a/programs/media/zsea/plugins/png/filter.inc b/programs/media/zsea/plugins/png/filter.inc
new file mode 100644
index 0000000000..a7e1662fae
--- /dev/null
+++ b/programs/media/zsea/plugins/png/filter.inc
@@ -0,0 +1,472 @@
+;*****************************************************************************
+; PNG to RAW convert plugin - for zSea image viewer
+; Copyright (c) 2008, 2009, Marat Zakiyanov aka Mario79, aka Mario
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;---------------------------------------------------------------------
+filtering:
+ push eax ecx edx
+ mov ebp,[line_filter_type]
+ cmp ebp,0
+ je .end
+ cmp ebp,1
+ je .Sub
+ cmp ebp,2
+ je .Up
+ cmp ebp,3
+ je .Averag
+ cmp ebp,4
+ je .Paeth
+ jmp .end
+;---------------------------------------------------------------------
+.Sub:
+ cmp [IHDR_data.Bit_depth],byte 16
+ jne @f
+ mov eax,ebx
+ shr eax,16
+ add bl,al
+ add bh,ah
+ jmp .end
+@@:
+ add bl,bh
+ jmp .end
+;---------------------------------------------------------------------
+.Up:
+ cmp [first_line],byte 0
+ jne .end
+ mov eax,[IHDR_data.Width]
+ cmp [IHDR_data.Color_type],byte 0
+ je .Up_Color_type_0_and_3
+ cmp [IHDR_data.Color_type],byte 3
+ je .Up_Color_type_0_and_3
+ cmp [IHDR_data.Color_type],byte 4
+ je @f
+ lea eax,[eax*3]
+@@:
+ cmp [IHDR_data.Color_type],byte 4
+ je .Up_Alpfa
+ cmp [IHDR_data.Color_type],byte 6
+ jne @f
+.Up_Alpfa:
+ add eax,[IHDR_data.Width]
+
+@@:
+.Up_8:
+ cmp [IHDR_data.Bit_depth],byte 16
+ je .Up_16
+ mov ebp,edi
+ sub ebp,eax
+ mov bh,[ebp]
+ add bl,bh
+ jmp .end
+
+.Up_Color_type_0_and_3:
+ cmp [IHDR_data.Bit_depth],byte 16
+ je .Up_16
+ call .Bit_depth_less_8
+ jmp .Up_8
+
+.Bit_depth_less_8:
+; imul eax,[resolution]
+ cmp [resolution],8
+ jne @f
+ ret
+@@:
+ cmp [resolution],4
+ jne @f
+ shl eax,2
+ jmp .continue_Bit_depth_less_8
+@@:
+ cmp [resolution],2
+ jne .continue_Bit_depth_less_8
+ shl eax,1
+.continue_Bit_depth_less_8:
+ push ebx
+ mov ebx,eax
+ shr eax,3
+ test ebx,7
+ jz @f
+ inc eax
+@@:
+ pop ebx
+ ret
+
+.Up_16:
+ shl eax,1
+ mov ebp,edi
+ sub ebp,eax
+ mov ax,[ebp]
+ add bl,al
+ add bh,ah
+ jmp .end
+;---------------------------------------------------------------------
+.Averag:
+ cmp [first_line],byte 0
+ je @f
+ xor eax,eax
+ cmp [IHDR_data.Bit_depth],byte 16
+ je .Averag_2
+ jmp .Averag_1
+@@:
+ mov eax,[IHDR_data.Width]
+ cmp [IHDR_data.Color_type],byte 0
+ je .Averag_Color_type_0_and_3 ;@f
+ cmp [IHDR_data.Color_type],byte 3
+ je .Averag_Color_type_0_and_3 ;@f
+ cmp [IHDR_data.Color_type],byte 4
+ je @f
+ lea eax,[eax*3]
+@@:
+ cmp [IHDR_data.Color_type],byte 4
+ je .Averag_Alpfa
+ cmp [IHDR_data.Color_type],byte 6
+ jne @f
+.Averag_Alpfa:
+ add eax,[IHDR_data.Width]
+
+@@:
+.Averag_8:
+ cmp [IHDR_data.Bit_depth],byte 16
+ je .Averag_16
+ mov ebp,edi
+ sub ebp,eax
+ xor eax,eax
+ mov al,[ebp]
+.Averag_1:
+ movzx ebp,bh
+ add eax,ebp
+ shr eax,1
+ add bl,al
+ jmp .end
+
+.Averag_Color_type_0_and_3:
+ cmp [IHDR_data.Bit_depth],byte 16
+ je .Averag_16
+ call .Bit_depth_less_8
+ jmp .Averag_8
+
+.Averag_16:
+ shl eax,1
+ mov ebp,edi
+ sub ebp,eax
+ xor eax,eax
+ mov ax,[ebp]
+.Averag_2:
+ mov ebp,ebx
+ shr ebp,16
+ mov ecx,ebp
+ and ecx,0xff
+ mov edx,eax
+ and edx,0xff
+ add ecx,edx
+ shr ecx,1
+ add bl,cl
+ shr ebp,8
+ shr eax,8
+ add eax,ebp
+ shr eax,1
+ add bh,al
+ jmp .end
+;---------------------------------------------------------------------
+.Paeth:
+ cmp [first_line],byte 0
+ je @f
+ xor eax,eax
+ cmp [IHDR_data.Bit_depth],byte 16
+ je .Paeth_16_1
+ jmp .Paeth_1
+@@:
+ mov eax,[IHDR_data.Width]
+ cmp [IHDR_data.Color_type],byte 0
+ je .Paeth_Color_type_0_and_3 ;@f
+ cmp [IHDR_data.Color_type],byte 3
+ je .Paeth_Color_type_0_and_3 ;@f
+ cmp [IHDR_data.Color_type],byte 4
+ je @f
+ lea eax,[eax*3]
+@@:
+ cmp [IHDR_data.Color_type],byte 4
+ je .Paeth_Alpfa
+ cmp [IHDR_data.Color_type],byte 6
+ jne @f
+.Paeth_Alpfa:
+ add eax,[IHDR_data.Width]
+
+@@:
+ cmp [IHDR_data.Bit_depth],byte 16
+ je .Paeth_16
+.Paeth_8:
+ mov ebp,edi
+ sub ebp,eax
+ xor eax,eax
+ mov al,[ebp]
+.Paeth_1:
+ mov [Paeth_filter.b],al
+
+ cmp [first_line],byte 0
+ jne @f
+ cmp [first_pixel],0
+ jne @f
+ mov ah,[ebp-1]
+ cmp [IHDR_data.Color_type],byte 0
+ je @f
+ cmp [IHDR_data.Color_type],byte 3
+ je @f
+ mov ah,[ebp-2]
+ cmp [IHDR_data.Color_type],byte 4
+ je @f
+ mov ah,[ebp-3]
+ cmp [IHDR_data.Color_type],byte 2
+ je @f
+ mov ah,[ebp-4]
+@@:
+ mov [Paeth_filter.c],ah
+ mov [Paeth_filter.a],bh
+
+ xor eax,eax
+ mov al,[Paeth_filter.a]
+ mov ebp,eax
+ mov al,[Paeth_filter.b]
+ add ebp,eax
+ mov al,[Paeth_filter.c]
+ sub ebp,eax
+ mov [Paeth_filter.p],ebp
+;----------------------------------------
+ mov al,[Paeth_filter.a]
+ sub ebp,eax
+ test ebp,0x80000000
+ jz @f
+ neg ebp
+@@:
+ mov [Paeth_filter.pa],ebp
+
+ mov ebp,[Paeth_filter.p]
+ mov al,[Paeth_filter.b]
+ sub ebp,eax
+ test ebp,0x80000000
+ jz @f
+ neg ebp
+@@:
+ mov [Paeth_filter.pb],ebp
+
+ mov ebp,[Paeth_filter.p]
+ mov al,[Paeth_filter.c]
+ sub ebp,eax
+ test ebp,0x80000000
+ jz @f
+ neg ebp
+@@:
+ mov [Paeth_filter.pc],ebp
+
+ mov eax,[Paeth_filter.pa]
+ mov ebp,[Paeth_filter.pb]
+ cmp eax,ebp
+ ja .no_return_a
+ cmp eax,[Paeth_filter.pc]
+ ja .no_return_a
+ add bl,[Paeth_filter.a]
+ jmp .end
+.no_return_a:
+ cmp ebp,[Paeth_filter.pc]
+ ja .no_return_b
+ add bl,[Paeth_filter.b]
+ jmp .end
+.no_return_b:
+ add bl,[Paeth_filter.c]
+.end:
+ pop edx ecx eax
+ ret
+;----------------------------------------
+.Paeth_Color_type_0_and_3:
+ cmp [IHDR_data.Bit_depth],byte 16
+ je .Paeth_16
+ call .Bit_depth_less_8
+ jmp .Paeth_8
+;----------------------------------------
+.Paeth_16:
+ shl eax,1
+ mov ebp,edi
+ sub ebp,eax
+ xor eax,eax
+ mov ax,[ebp]
+.Paeth_16_1:
+ mov [Paeth_filter.b],ax
+ xor eax,eax
+ cmp [first_line],byte 0
+ jne @f
+ cmp [first_pixel],0
+ jne @f
+ mov ax,[ebp-2]
+ cmp [IHDR_data.Color_type],byte 0
+ je @f
+ mov ax,[ebp-4]
+ cmp [IHDR_data.Color_type],byte 4
+ je @f
+ mov ax,[ebp-6]
+ cmp [IHDR_data.Color_type],byte 2
+ je @f
+ mov ax,[ebp-8]
+@@:
+ mov [Paeth_filter.c],ax
+ mov eax,ebx
+ shr eax,16
+ mov [Paeth_filter.a],ax
+;----------------------------------------
+ xor eax,eax
+ mov ax,[Paeth_filter.a]
+ shr ax,8
+ mov bp,ax
+ mov ax,[Paeth_filter.b]
+ shr ax,8
+ add bp,ax
+ mov ax,[Paeth_filter.c]
+ shr ax,8
+ sub bp,ax
+ shl ebp,16
+
+ xor eax,eax
+ mov al,[Paeth_filter.a]
+ mov bp,ax
+ mov al,[Paeth_filter.b]
+ add bp,ax
+ mov al,[Paeth_filter.c]
+ sub bp,ax
+
+ mov [Paeth_filter.p],ebp
+;----------------------------------------
+ xor eax,eax
+ mov ax,[Paeth_filter.a]
+ mov ecx,ebp
+ mov dx,ax
+ shr ecx,16
+ shr dx,8
+ sub cx,dx
+ test cx,0x8000
+ jz @f
+ neg cx
+@@:
+ shl ecx,16
+
+ and ebp,0xffff
+ and eax,0xff
+ sub bp,ax
+ test bp,0x8000
+ jz @f
+ neg bp
+@@:
+ add ebp,ecx
+ mov [Paeth_filter.pa],ebp
+;----------------------------------------
+ xor eax,eax
+ mov ebp,[Paeth_filter.p]
+ mov ax,[Paeth_filter.b]
+ mov ecx,ebp
+ mov dx,ax
+ shr ecx,16
+ shr dx,8
+ sub cx,dx
+ test cx,0x8000
+ jz @f
+ neg cx
+@@:
+ shl ecx,16
+
+ and ebp,0xffff
+ and eax,0xff
+ sub bp,ax
+ test bp,0x8000
+ jz @f
+ neg bp
+@@:
+ add ebp,ecx
+ mov [Paeth_filter.pb],ebp
+;----------------------------------------
+ xor eax,eax
+ mov ebp,[Paeth_filter.p]
+ mov ax,[Paeth_filter.c]
+ mov ecx,ebp
+ mov dx,ax
+ shr ecx,16
+ shr dx,8
+ sub cx,dx
+ test cx,0x8000
+ jz @f
+ neg cx
+@@:
+ shl ecx,16
+
+ and ebp,0xffff
+ and eax,0xff
+ sub bp,ax
+ test bp,0x8000
+ jz @f
+ neg bp
+@@:
+ add ebp,ecx
+ mov [Paeth_filter.pc],ebp
+;----------------------------------------
+ mov eax,[Paeth_filter.pa]
+ mov ebp,[Paeth_filter.pb]
+ mov ecx,[Paeth_filter.pc]
+ shr eax,16
+ shr ebp,16
+ shr ecx,16
+ cmp ax,bp
+ ja .no_return_a_1
+ cmp ax,cx
+ ja .no_return_a_1
+ mov ax,[Paeth_filter.a]
+ add bh,ah
+ jmp .end_1
+.no_return_a_1:
+ cmp bp,cx
+ ja .no_return_b_1
+ mov ax,[Paeth_filter.b]
+ add bh,ah
+ jmp .end_1
+.no_return_b_1:
+ mov ax,[Paeth_filter.c]
+ add bh,ah
+.end_1:
+;----------------------------------------
+ mov eax,[Paeth_filter.pa]
+ mov ebp,[Paeth_filter.pb]
+ mov ecx,[Paeth_filter.pc]
+ cmp ax,bp
+ ja .no_return_a_2
+ cmp ax,cx
+ ja .no_return_a_2
+ add bl,[Paeth_filter.a]
+ jmp .end_2
+.no_return_a_2:
+ cmp bp,cx
+ ja .no_return_b_2
+ add bl,[Paeth_filter.b]
+ jmp .end_2
+.no_return_b_2:
+ add bl,[Paeth_filter.c]
+.end_2:
+ pop edx ecx eax
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/png/fl_call.inc b/programs/media/zsea/plugins/png/fl_call.inc
new file mode 100644
index 0000000000..2d7f890198
--- /dev/null
+++ b/programs/media/zsea/plugins/png/fl_call.inc
@@ -0,0 +1,225 @@
+;*****************************************************************************
+; PNG to RAW convert plugin - for zSea image viewer
+; Copyright (c) 2008, 2009, Marat Zakiyanov aka Mario79, aka Mario
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;---------------------------------------------------------------------
+filtering_RGB:
+ mov ecx,[IHDR_data.Height]
+ test ecx,ecx
+ jz .filter_end
+.filter:
+ mov edx,[IHDR_data.Width]
+ test edx,edx
+ jz .filter_end
+ xor eax,eax
+ mov [previous_pixel_value],eax
+ mov [first_pixel],byte 1
+ mov al,[esi]
+ mov [line_filter_type],eax
+ inc esi
+
+.filter_x:
+
+ mov bh,[previous_pixel_value]
+ call filtering_sample_8
+ mov [previous_pixel_value],bl
+
+ mov bh,[previous_pixel_value+1]
+ call filtering_sample_8
+ mov [previous_pixel_value+1],bl
+
+ mov bh,[previous_pixel_value+2]
+ call filtering_sample_8
+ mov [previous_pixel_value+2],bl
+
+ cmp [IHDR_data.Color_type],byte 6
+ jne @f
+
+ mov bh,[previous_pixel_value+3]
+ call filtering_sample_8
+ mov [previous_pixel_value+3],bl
+@@:
+ mov [first_pixel],byte 0
+ dec edx
+ jnz .filter_x
+ mov [first_line],byte 0
+ dec ecx
+ jnz .filter
+.filter_end:
+ ret
+;-------------------------------
+filtering_sample_8:
+ cld
+ lodsb
+ mov bl,al
+ call filtering
+ mov al,bl
+ cld
+ stosb
+ ret
+;---------------------------------------------------------------------
+filtering_RGB_16:
+ mov ecx,[IHDR_data.Height]
+ test ecx,ecx
+ jz .filter_end_16
+.filter_16:
+ mov edx,[IHDR_data.Width]
+ test edx,edx
+ jz .filter_end_16
+ xor eax,eax
+ mov [previous_pixel_value],eax
+ mov [previous_pixel_value+4],eax
+ mov [first_pixel],byte 1
+ mov al,[esi]
+ mov [line_filter_type],eax
+ inc esi
+.filter_x_16:
+ mov bx,[previous_pixel_value]
+ call filtering_sample_16
+ mov [previous_pixel_value],bx
+
+ mov bx,[previous_pixel_value+2]
+ call filtering_sample_16
+ mov [previous_pixel_value+2],bx
+
+ mov bx,[previous_pixel_value+4]
+ call filtering_sample_16
+ mov [previous_pixel_value+4],bx
+
+ cmp [IHDR_data.Color_type],byte 6
+ jne @f
+
+ mov bx,[previous_pixel_value+6]
+ call filtering_sample_16
+ mov [previous_pixel_value+6],bx
+@@:
+ mov [first_pixel],byte 0
+ dec edx
+ jnz .filter_x_16
+ mov [first_line],byte 0
+ dec ecx
+ jnz .filter_16
+.filter_end_16:
+ ret
+;-------------------------------
+filtering_sample_16:
+ shl ebx,16
+ cld
+ lodsw
+ mov bx,ax
+ call filtering
+ mov ax,bx
+ cld
+ stosw
+ ret
+;---------------------------------------------------------------------
+filtering_grayscale:
+ mov ecx,[IHDR_data.Height]
+ test ecx,ecx
+ jz .filter_end_grayscale
+
+ mov edx,[IHDR_data.Width]
+ test edx,edx
+ jz .filter_end_grayscale
+ cmp [IHDR_data.Color_type],byte 4
+ je @f
+ imul edx,[resolution]
+ mov eax,edx
+ shr edx,3
+ test eax,7
+ jz @f
+ inc edx
+@@:
+
+.filter_grayscale:
+ push edx
+ xor eax,eax
+ mov [previous_pixel_value],eax
+ mov [first_pixel],byte 1
+ mov al,[esi]
+ mov [line_filter_type],eax
+ inc esi
+
+.filter_x_grayscale:
+
+ mov bh,[previous_pixel_value]
+ call filtering_sample_8
+ mov [previous_pixel_value],bl
+
+ cmp [IHDR_data.Color_type],byte 4
+ jne @f
+
+ mov bh,[previous_pixel_value+1]
+ call filtering_sample_8
+ mov [previous_pixel_value+1],bl
+@@:
+ mov [first_pixel],byte 0
+ dec edx
+ jnz .filter_x_grayscale
+ pop edx
+
+ mov [first_line],byte 0
+ dec ecx
+ jnz .filter_grayscale
+.filter_end_grayscale:
+ ret
+;---------------------------------------------------------------------
+filtering_grayscale_16:
+ mov ecx,[IHDR_data.Height]
+ test ecx,ecx
+ jz .filter_end_grayscale_16
+
+.filter_grayscale_Bit_depth_16:
+
+ mov edx,[IHDR_data.Width]
+ test edx,edx
+ jz .filter_end_grayscale_16
+ xor eax,eax
+ mov [previous_pixel_value],eax
+ mov [first_pixel],byte 1
+ mov al,[esi]
+ mov [line_filter_type],eax
+ inc esi
+.filter_x_grayscale_16:
+ mov bx,[previous_pixel_value]
+ call filtering_sample_16
+ mov [previous_pixel_value],bx
+
+ cmp [IHDR_data.Color_type],byte 4
+ jne @f
+ mov bx,[previous_pixel_value+2]
+ call filtering_sample_16
+ mov [previous_pixel_value+2],bx
+
+@@:
+ mov [first_pixel],byte 0
+ dec edx
+ jnz .filter_x_grayscale_16
+ mov [first_line],byte 0
+ dec ecx
+ jnz .filter_grayscale_Bit_depth_16
+.filter_end_grayscale_16:
+ ret
+;---------------------------------------------------------------------
diff --git a/programs/media/zsea/plugins/png/interlac.inc b/programs/media/zsea/plugins/png/interlac.inc
new file mode 100644
index 0000000000..75db60b056
--- /dev/null
+++ b/programs/media/zsea/plugins/png/interlac.inc
@@ -0,0 +1,1089 @@
+;*****************************************************************************
+; PNG to RAW convert plugin - for zSea image viewer
+; Copyright (c) 2008, 2009, Marat Zakiyanov aka Mario79, aka Mario
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;---------------------------------------------------------------------
+filtering_RGB_Interlaced:
+ mov edx,dword filtering_RGB
+ mov ebp,dword move_Interlaced_RGB
+ jmp filtering_All
+;---------------------------------------------------------------------
+filtering_RGB_16_Interlaced:
+ mov edx,dword filtering_RGB_16
+ mov ebp,dword move_Interlaced_RGB
+ jmp filtering_All
+;---------------------------------------------------------------------
+filtering_grayscale_Interlaced:
+ mov edx,dword filtering_grayscale
+ mov ebp,dword move_Interlaced_grayscale
+ jmp filtering_All
+;---------------------------------------------------------------------
+filtering_grayscale_16_Interlaced:
+ mov edx,dword filtering_grayscale_16
+ mov ebp,dword move_Interlaced_grayscale
+ jmp filtering_All
+;---------------------------------------------------------------------
+pass dd 0
+filtering_All:
+ push edi
+
+ mov ecx,[resolution]
+ imul ecx,[IHDR_data.Width]
+ mov eax,ecx
+ shr ecx,3
+ test eax,7
+ jz @f
+ inc ecx
+@@:
+ mov eax,[IHDR_data.Height]
+ shr eax,1
+ inc eax
+ imul ecx,eax
+ mcall 68, 12
+ mov [Interlaced_area],eax
+; jmp .3
+ mov eax,dword calculate_Interlaced_counters
+ mov ecx,7
+@@:
+ mov [pass],ecx
+ mov [Interlaced_step],eax
+ push ecx
+ push eax edx edi ebp eax
+ call dword [eax] ;calculate_Interlaced_1
+; cmp [pass],1
+; jbe .2
+ call edx
+;.2:
+ pop eax ebp edi
+ push ebp
+; cmp [pass],1
+; jbe .1
+ call ebp
+;.1:
+ pop ebp edx eax
+ add eax,4
+ pop ecx
+ dec ecx
+ jnz @r
+;.3:
+ mov ecx,[Interlaced_area]
+ mcall 68, 13
+
+ pop edi
+ ret
+;---------------------------------------------------------------------
+move_Interlaced_RGB:
+ push edi esi
+ mov esi,[Interlaced_area]
+
+ mov ecx,[IHDR_data.Height]
+ test ecx,ecx
+ jz .end
+
+ mov edx,[IHDR_data.Width]
+ test edx,edx
+ jz .end
+
+ mov ebx,[Image_Width]
+ imul ebx,[resolution]
+ shr ebx,3
+
+ mov eax,[Starting_Col]
+ imul eax,[resolution]
+ shr eax,3
+ add edi,eax
+
+ mov eax,[Starting_Row]
+ imul eax,ebx
+ add edi,eax
+
+ imul ebx,[Row_Increment]
+
+ mov ebp,[resolution]
+ imul ebp,[Col_Increment]
+ shr ebp,3
+
+.filter:
+ mov edx,[IHDR_data.Width]
+ push edi
+
+.filter_x:
+ cmp [IHDR_data.Bit_depth],byte 8
+ jne @f
+ call .Interlaced_RGB_8
+ jmp .1
+@@:
+ call .Interlaced_RGB_16
+.1:
+ dec edx
+ jnz .filter_x
+
+ pop edi
+
+ add edi,ebx
+ dec ecx
+ jnz .filter
+.end:
+ pop esi edi
+ ret
+;-------------------------------------------
+.Interlaced_RGB_8:
+ cld
+ lodsw
+ mov [edi],ax
+ lodsb
+ mov [edi+2],al
+ cmp [IHDR_data.Color_type],byte 6
+ jne @f
+ lodsb
+ mov [edi+3],al
+@@:
+ add edi,ebp
+ ret
+;-------------------------------------------
+.Interlaced_RGB_16:
+ cld
+ lodsd
+ mov [edi],eax
+ lodsw
+ mov [edi+4],ax
+ cmp [IHDR_data.Color_type],byte 6
+ jne @f
+ lodsw
+ mov [edi+6],al
+@@:
+ add edi,ebp
+ ret
+;---------------------------------------------------------------------
+move_Interlaced_grayscale:
+; cmp [eax],dword calculate_Interlaced_1
+; jne @f
+; ret
+;@@:
+; cmp [eax],dword calculate_Interlaced_2
+; jne @f
+; ret
+;@@:
+; cmp [eax],dword calculate_Interlaced_3
+; jne @f
+; ret
+;@@:
+; cmp [eax],dword calculate_Interlaced_4
+; jne @f
+; ret
+;@@:
+; cmp [eax],dword calculate_Interlaced_5
+; jne @f
+; ret
+;@@:
+; cmp [eax],dword calculate_Interlaced_6
+; jne @f
+; ret
+;@@:
+; cmp [eax],dword calculate_Interlaced_7
+; jne @f
+; ret
+;@@:
+
+ push edi esi
+ mov esi,[Interlaced_area]
+
+ mov ecx,[IHDR_data.Height]
+ test ecx,ecx
+ jz .end
+
+ mov edx,[IHDR_data.Width]
+ test edx,edx
+ jz .end
+
+ mov ebx,[Image_Width]
+ imul ebx,[resolution]
+ mov eax,ebx
+ shr ebx,3
+ test eax,7
+ jz @f
+ inc ebx
+@@:
+; ebx = Width in bytes, need correct for resolution less 4b
+
+ mov eax,[Starting_Col]
+ imul eax,[resolution]
+; mov ebp,eax
+ shr eax,3
+; test ebp,7
+; jz @f
+; inc eax
+;@@:
+; eax = Starting Colummn in bytes
+ add edi,eax
+
+ mov eax,[Starting_Row]
+ imul eax,ebx
+; eax = Starting Row in bytes, no need correct!
+ add edi,eax
+
+ imul ebx,[Row_Increment]
+; ebx = Row Increment in bytes, no need correct!
+
+ mov eax,[IHDR_data.Width]
+ imul eax,[resolution]
+ mov ebp,eax
+ shr eax,3
+ test ebp,7
+ jz @f
+ inc eax
+@@:
+; eax = Width in bytes for Interlaced,
+; need correct for resolution less 4b
+
+ mov ebp,[resolution]
+ imul ebp,[Col_Increment]
+; mov eax,ebp
+ shr ebp,3
+; test eax,7
+; jz @f
+; inc ebp
+;@@:
+; ebp = Column Increment in bytes
+
+.filter_grayscale:
+ mov edx,[IHDR_data.Width]
+ cmp [resolution],8
+ jae .filter_grayscale_1
+
+.resolution_4:
+ cmp [resolution],4
+ jne .resolution_2
+ test edx,1
+ jnz @f
+ inc edx
+@@:
+ shr edx,1
+ jmp .filter_grayscale_1
+
+.resolution_2:
+ cmp [resolution],2
+ jne .resolution_1
+ test edx,3
+ jnz @f
+ add edx,4
+@@:
+ shr edx,2
+ jmp .filter_grayscale_1
+
+.resolution_1:
+ push eax
+ mov eax,edx
+ shr edx,3
+ test eax,7
+ jz @f
+ inc edx
+@@:
+ pop eax
+.filter_grayscale_1:
+ push eax edi esi
+
+.filter_x_grayscale:
+ cmp [IHDR_data.Bit_depth],byte 16
+ jne @f
+ call .Interlaced_grayscale_16
+ jmp .1
+@@:
+ cmp [IHDR_data.Bit_depth],byte 8
+ jne @f
+ call .Interlaced_grayscale_8
+ jmp .1
+@@:
+ cmp [IHDR_data.Bit_depth],byte 4
+ jne @f
+ call .Interlaced_grayscale_4
+ jmp .1
+@@:
+ cmp [IHDR_data.Bit_depth],byte 2
+ jne @f
+ call .Interlaced_grayscale_2
+ jmp .1
+@@:
+ call .Interlaced_grayscale_1
+ jmp .1
+.1:
+
+ dec edx
+ jnz .filter_x_grayscale
+ pop esi edi eax
+ add esi,eax
+
+ add edi,ebx
+ dec ecx
+ jnz .filter_grayscale
+.end:
+ pop esi edi
+ ret
+;-----------------------------------
+.Interlaced_grayscale_1:
+ mov eax,[Interlaced_step]
+ cmp eax,calculate_Interlaced_counters.1
+ je .step_1
+ cmp eax,calculate_Interlaced_counters.2
+ je .step_2
+ cmp eax,calculate_Interlaced_counters.3
+ je .step_3
+ cmp eax,calculate_Interlaced_counters.4
+ je .step_4
+ cmp eax,calculate_Interlaced_counters.5
+ je .step_5
+ cmp eax,calculate_Interlaced_counters.6
+ je .step_6
+ cld
+ movsb
+ ret
+;--------------------
+.step_6:
+ push ebx
+ cld
+ lodsb
+ mov ah,al
+
+ call @f
+
+ shl ah,4
+ mov al,ah
+
+ call @f
+
+ pop ebx
+ ret
+;--------------------
+@@:
+ shr al,1
+ and al,64
+
+ mov bl,ah
+ shr bl,2
+ and bl,16
+ add al,bl
+
+ mov bl,ah
+ shr bl,3
+ and bl,4
+ add al,bl
+
+ mov bl,ah
+ shr bl,4
+ and bl,1
+ add al,bl
+
+ add al,[edi]
+ stosb
+ ret
+;--------------------
+.step_5:
+ push ebx
+ cld
+ lodsb
+
+ mov ah,al
+
+ call @f
+
+ shl ah,4
+ mov al,ah
+
+ call @f
+
+ pop ebx
+ ret
+;--------------------
+@@:
+ and al,128
+
+ mov bl,ah
+ shr bl,1
+ and bl,32
+ add al,bl
+
+ mov bl,ah
+ shr bl,2
+ and bl,8
+ add al,bl
+
+ mov bl,ah
+ shr bl,3
+ and bl,2
+ add al,bl
+
+ add al,[edi]
+ stosb
+ ret
+;--------------------
+.step_4:
+ push ebx
+ cld
+ lodsb
+
+ mov ah,al
+ shr al,2
+ and al,32
+ mov bl,ah
+ shr bl,5
+ call @f
+
+ mov al,ah
+ and al,32
+ mov bl,ah
+ shr bl,3
+ call @f
+
+ mov al,ah
+ shl al,2
+ and al,32
+ mov bl,ah
+ shr bl,1
+ call @f
+
+ mov al,ah
+ shl al,4
+ and al,32
+ mov bl,ah
+ shl bl,1
+ call @f
+ pop ebx
+ ret
+;--------------------
+@@:
+ and bl,2
+ add al,bl
+ add al,[edi]
+ stosb
+ ret
+;--------------------
+.step_3:
+ push ebx
+ cld
+ lodsb
+
+ mov ah,al
+ and al,128
+ mov bl,ah
+ shr bl,3
+ call @f
+
+ mov al,ah
+ shl al,2
+ and al,128
+ mov bl,ah
+ shr bl,1
+ call @f
+
+ mov al,ah
+ shl al,4
+ and al,128
+ mov bl,ah
+ shl bl,1
+ call @f
+
+ mov al,ah
+ shl al,6
+ and al,128
+ mov bl,ah
+ shl bl,3
+ call @f
+ pop ebx
+ ret
+;--------------------
+@@:
+ and bl,8
+ add al,bl
+ add al,[edi]
+ stosb
+ ret
+;--------------------
+.step_2:
+ cld
+ lodsb
+
+ mov ah,al
+ shr al,4
+ and al,8
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ shr al,3
+ and al,8
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ shr al,2
+ and al,8
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ shr al,1
+ and al,8
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ and al,8
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ shl al,1
+ and al,8
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ shl al,2
+ and al,8
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ shl al,3
+ and al,8
+ add al,[edi]
+ stosb
+
+ ret
+;--------------------
+.step_1:
+ cld
+ lodsb
+ mov ah,al
+ and al,128
+ stosb
+ mov al,ah
+ shl al,1
+ and al,128
+ stosb
+ mov al,ah
+ shl al,2
+ and al,128
+ stosb
+ mov al,ah
+ shl al,3
+ and al,128
+ stosb
+ mov al,ah
+ shl al,4
+ and al,128
+ stosb
+ mov al,ah
+ shl al,5
+ and al,128
+ stosb
+ mov al,ah
+ shl al,6
+ and al,128
+ stosb
+ mov al,ah
+ shl al,7
+ and al,128
+ stosb
+ ret
+;-----------------------------------
+.Interlaced_grayscale_2:
+ mov eax,[Interlaced_step]
+ cmp eax,calculate_Interlaced_counters.1
+ je .step_1_1
+ cmp eax,calculate_Interlaced_counters.2
+ je .step_2_1
+ cmp eax,calculate_Interlaced_counters.3
+ je .step_3_1
+ cmp eax,calculate_Interlaced_counters.4
+ je .step_4_1
+ cmp eax,calculate_Interlaced_counters.5
+ je .step_5_1
+ cmp eax,calculate_Interlaced_counters.6
+ je .step_6_1
+ cld
+ movsb
+ ret
+
+.step_6_1:
+ push ebx
+ cld
+ lodsb
+ mov ah,al
+
+ shr al,2
+ and al,48
+ mov bl,ah
+ shr bl,4
+ and bl,3
+ add al,bl
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ shl al,2
+ and al,48
+ mov bl,ah
+ and bl,3
+ add al,bl
+ add al,[edi]
+ stosb
+ pop ebx
+ ret
+
+.step_5_1:
+ push ebx
+ cld
+ lodsb
+ mov ah,al
+
+ and al,192
+ mov bl,ah
+ shr bl,2
+ and bl,12
+ add al,bl
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ shl al,4
+ and al,192
+ mov bl,ah
+ shl bl,2
+ and bl,12
+ add al,bl
+ add al,[edi]
+ stosb
+ pop ebx
+ ret
+
+.step_4_1:
+ cld
+ lodsb
+ mov ah,al
+
+ shr al,4
+ and al,12
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ shr al,2
+ and al,12
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ and al,12
+ add al,[edi]
+ stosb
+
+ mov al,ah
+ shl al,2
+ and al,12
+ add al,[edi]
+ stosb
+
+ ret
+
+.step_3_1:
+ cld
+ lodsb
+ mov ah,al
+
+ and al,192
+ stosb
+
+ mov al,ah
+ shl al,2
+ and al,192
+ stosb
+
+ mov al,ah
+ shl al,4
+ and al,192
+ stosb
+
+ mov al,ah
+ shl al,6
+ and al,192
+ stosb
+
+ ret
+
+.step_2_1:
+ cld
+ lodsb
+ mov ah,al
+
+ and al,192
+ stosb
+ inc edi
+
+ mov al,ah
+ shl al,2
+ and al,192
+ stosb
+ inc edi
+
+ mov al,ah
+ shl al,4
+ and al,192
+ stosb
+ inc edi
+
+ mov al,ah
+ shl al,6
+ and al,192
+ stosb
+ inc edi
+
+ ret
+
+.step_1_1:
+ cld
+ lodsb
+
+ mov ah,al
+ and al,192
+ stosb
+ inc edi
+
+ mov al,ah
+ shl al,2
+ and al,192
+ stosb
+ inc edi
+
+ mov al,ah
+ shl al,4
+ and al,192
+ stosb
+ inc edi
+
+ mov al,ah
+ shl al,6
+ and al,192
+ stosb
+ inc edi
+
+ ret
+;-----------------------------------
+.Interlaced_grayscale_4:
+ mov al,[esi]
+ mov ah,[edi]
+ test ebp,ebp
+ jnz @f
+ call .even_2
+ jmp .2
+@@:
+ test [Starting_Col],byte 1
+ jz @f
+ call .even_1
+ jmp .2
+@@:
+ call .odd_1
+.2:
+ add al,ah
+ mov [edi],al
+ add edi,ebp
+
+ mov al,[esi]
+ mov ah,[edi]
+ test ebp,ebp
+ jnz @f
+ call .odd_1
+ jmp .3
+@@:
+ test [Starting_Col],byte 1
+ jz @f
+ call .even_2
+ jmp .3
+@@:
+ call .odd_2
+.3:
+ add al,ah
+ mov [edi],al
+ add edi,ebp
+
+ inc esi
+ test ebp,ebp
+ jnz @f
+ inc edi
+@@:
+ ret
+;---------------------
+.even_1:
+ shr al,4
+ and ah,11110000b
+ ret
+;---------------------
+.even_2:
+ and al,1111b
+ and ah,11110000b
+ ret
+;---------------------
+.odd_1:
+ and al,11110000b
+ and ah,1111b
+ ret
+;---------------------
+.odd_2:
+ shl al,4
+ and ah,1111b
+ ret
+;-----------------------------------
+.Interlaced_grayscale_8:
+ cld
+ lodsb
+ mov [edi],al
+ cmp [IHDR_data.Color_type],byte 4
+ jne @f
+ cld
+ lodsb
+ mov [edi+1],al
+@@:
+ add edi,ebp
+ ret
+;-----------------------------------
+.Interlaced_grayscale_16:
+ cld
+ lodsw
+ mov [edi],ax
+ cmp [IHDR_data.Color_type],byte 4
+ jne @f
+ cld
+ lodsw
+ mov [edi+2],ax
+@@:
+ add edi,ebp
+ ret
+;---------------------------------------------------------------------
+calculatte_Interlaced_data_1:
+ mov [first_line],byte 1
+ mov edi,[Interlaced_area]
+ mov eax,[Image_Width]
+ mov ebx,dword Starting_Row
+ ret
+;---------------------------------------------------------------------
+calculate_Interlaced_1:
+ call calculatte_Interlaced_data_1
+ mov [ebx+0],dword 0 ;Starting_Row
+ mov [ebx+4],dword 0 ;Starting_Col
+ mov [ebx+8],dword 8 ;Row_Increment
+ mov [ebx+12],dword 8 ;Col_Increment
+ mov ebx,eax
+ shr eax,3
+ test ebx,7
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Width],eax
+
+ mov eax,[Image_Height]
+ mov ebx,eax
+ shr eax,3
+ test ebx,7
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Height],eax
+ ret
+;---------------------------------------------------------------------
+calculate_Interlaced_2:
+ call calculatte_Interlaced_data_1
+ mov [ebx+0],dword 0 ;Starting_Row
+ mov [ebx+4],dword 4 ;Starting_Col
+ mov [ebx+8],dword 8 ;Row_Increment
+ mov [ebx+12],dword 8 ;Col_Increment
+ cmp eax,4
+ ja @f
+ mov eax,4
+@@:
+ sub eax,4
+ mov ebx,eax
+ shr eax,3
+ test ebx,7
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Width],eax
+
+ mov eax,[Image_Height]
+ mov ebx,eax
+ shr eax,3
+ test ebx,7
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Height],eax
+ ret
+;---------------------------------------------------------------------
+calculate_Interlaced_3:
+ call calculatte_Interlaced_data_1
+ mov [ebx+0],dword 4 ;Starting_Row
+ mov [ebx+4],dword 0 ;Starting_Col
+ mov [ebx+8],dword 8 ;Row_Increment
+ mov [ebx+12],dword 4 ;Col_Increment
+ mov ebx,eax
+ shr eax,2
+ test ebx,3
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Width],eax
+
+ mov eax,[Image_Height]
+ cmp eax,4
+ ja @f
+ mov eax,4
+@@:
+ sub eax,4
+ mov ebx,eax
+ shr eax,3
+ test ebx,7
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Height],eax
+ ret
+;---------------------------------------------------------------------
+calculate_Interlaced_4:
+ call calculatte_Interlaced_data_1
+ mov [ebx+0],dword 0 ;Starting_Row
+ mov [ebx+4],dword 2 ;Starting_Col
+ mov [ebx+8],dword 4 ;Row_Increment
+ mov [ebx+12],dword 4 ;Col_Increment
+ cmp eax,2
+ ja @f
+ mov eax,2
+@@:
+ sub eax,2
+ mov ebx,eax
+ shr eax,2
+ test ebx,3
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Width],eax
+
+ mov eax,[Image_Height]
+ mov ebx,eax
+ shr eax,2
+ test ebx,3
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Height],eax
+ ret
+;---------------------------------------------------------------------
+calculate_Interlaced_5:
+ call calculatte_Interlaced_data_1
+ mov [ebx+0],dword 2 ;Starting_Row
+ mov [ebx+4],dword 0 ;Starting_Col
+ mov [ebx+8],dword 4 ;Row_Increment
+ mov [ebx+12],dword 2 ;Col_Increment
+ mov ebx,eax
+ shr eax,1
+ test ebx,1
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Width],eax
+
+ mov eax,[Image_Height]
+ cmp eax,2
+ ja @f
+ mov eax,2
+@@:
+ sub eax,2
+ mov ebx,eax
+ shr eax,2
+ test ebx,3
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Height],eax
+ ret
+;---------------------------------------------------------------------
+calculate_Interlaced_6:
+ call calculatte_Interlaced_data_1
+ mov [ebx+0],dword 0 ;Starting_Row
+ mov [ebx+4],dword 1 ;Starting_Col
+ mov [ebx+8],dword 2 ;Row_Increment
+ mov [ebx+12],dword 2 ;Col_Increment
+ cmp eax,1
+ ja @f
+ mov eax,1
+@@:
+ dec eax
+ mov ebx,eax
+ shr eax,1
+ test ebx,1
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Width],eax
+
+ mov eax,[Image_Height]
+ mov ebx,eax
+ shr eax,1
+ test ebx,1
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Height],eax
+ ret
+;---------------------------------------------------------------------
+calculate_Interlaced_7:
+ call calculatte_Interlaced_data_1
+ mov [ebx+0],dword 1 ;Starting_Row
+ mov [ebx+4],dword 0 ;Starting_Col
+ mov [ebx+8],dword 2 ;Row_Increment
+ mov [ebx+12],dword 1 ;Col_Increment
+
+ mov [IHDR_data.Width],eax
+; mov ebx,[raw_area]
+; mov [ebx+4],eax
+
+ mov eax,[Image_Height]
+ cmp eax,1
+ ja @f
+ mov eax,1
+@@:
+ dec eax
+ mov ebx,eax
+ shr eax,1
+ test ebx,1
+ jz @f
+ inc eax
+@@:
+ mov [IHDR_data.Height],eax
+
+; mov ebx,[raw_area]
+; mov eax,[Image_Height]
+; mov [ebx+8],eax
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/png/proced.inc b/programs/media/zsea/plugins/png/proced.inc
new file mode 100644
index 0000000000..a971a90521
--- /dev/null
+++ b/programs/media/zsea/plugins/png/proced.inc
@@ -0,0 +1,159 @@
+;*****************************************************************************
+; PNG to RAW convert plugin - for zSea image viewer
+; Copyright (c) 2008, 2009, Marat Zakiyanov aka Mario79, aka Mario
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;---------------------------------------------------------------------
+deflate_callback:
+ cmp [deflate_start_offset],1
+ je @f
+ mov [deflate_start_offset],1
+ jmp .1
+@@:
+ mov eax,[IDAT.pointer]
+ add eax,[IDAT.size]
+ mov ebx,[image_file]
+ add ebx,[file_size]
+ sub ebx,32
+ cmp ebx,eax
+ jbe @f
+ mov [next_Chunk],eax
+ call search_IDAT
+ jmp .1
+@@:
+ xor eax,eax
+ mov [IDAT.size],eax
+ mov [IDAT.pointer],eax
+.1:
+ mov ecx, [esp+8]
+ mov eax,[IDAT.size]
+ mov [ecx], eax ;length
+ mov eax,[IDAT.pointer] ; buffer
+ ret 8
+;---------------------------------------------------------------------
+search_IHDR:
+ mov [Chunk_pointer],IHDR_name
+ call get_Chunk_data_pointer
+ mov eax,[Chunk_pointer]
+ cmp eax,0
+ je .no_png_file
+ mov [IHDR.pointer],eax
+ mov ecx,[eax-8]
+ call convert_NBO_to_PC
+ mov [IHDR.size],ecx
+ ret
+.no_png_file:
+ add esp,4
+ jmp no_png_file
+;---------------------------------------------------------------------
+search_PLTE:
+ push eax ecx
+ mov [Chunk_pointer],PLTE_name
+ call get_Chunk_data_pointer
+ mov eax,[Chunk_pointer]
+ cmp eax,0
+ je .no_png_file
+ mov [PLTE.pointer],eax
+ mov ecx,[eax-8]
+ call convert_NBO_to_PC
+ mov [PLTE.size],ecx
+ pop ecx eax
+ ret
+.no_png_file:
+ add esp,12
+ jmp no_png_file
+;---------------------------------------------------------------------
+search_IDAT:
+ mov [Chunk_pointer],IDAT_name
+ call get_Chunk_data_pointer
+ mov eax,[Chunk_pointer]
+ cmp eax,0
+ je .no_IDAT_next
+ mov [IDAT.pointer],eax
+ mov ecx,[eax-8]
+ call convert_NBO_to_PC
+ mov [IDAT.size],ecx
+ xor eax,eax
+ ret
+.no_IDAT_next:
+; add esp,4
+; jmp no_png_file
+ mov eax,1
+ ret
+;---------------------------------------------------------------------
+search_IEND:
+ mov [Chunk_pointer],IEND_name
+ call get_Chunk_data_pointer
+ mov eax,[Chunk_pointer]
+ cmp eax,0
+ je .no_png_file
+ mov [IEND.pointer],eax
+ mov ecx,[eax-8]
+ call convert_NBO_to_PC
+ mov [IEND.size],ecx
+ ret
+.no_png_file:
+ add esp,4
+ jmp no_png_file
+;---------------------------------------------------------------------
+convert_NBO_to_PC: ;network byte order value to PC value
+ push eax
+ mov al,ch
+ mov ah,cl
+ shl eax,16
+ shr ecx,16
+ mov al,ch
+ mov ah,cl
+ mov ecx,eax
+ pop eax
+ ret
+;---------------------------------------------------------------------
+get_Chunk_data_pointer:
+ pushad
+ mov ebp,4
+; mov edi,[image_file]
+ mov edi,[next_Chunk]
+ mov edx,[image_file] ;edi
+ add edx,[file_size]
+ dec edi
+.search_Chunk:
+ cmp edx,edi
+ jbe .end
+ mov esi,[Chunk_pointer]
+ mov ecx,ebp
+ inc edi
+ mov ebx,edi
+ cld
+ rep cmpsb
+ mov edi,ebx
+ jne .search_Chunk
+ add edi,ebp
+ mov [Chunk_pointer],edi
+ popad
+ ret
+.end:
+ mov [Chunk_pointer],0
+ popad
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/rotate/build.bat b/programs/media/zsea/plugins/rotate/build.bat
new file mode 100644
index 0000000000..dc7eeb397c
--- /dev/null
+++ b/programs/media/zsea/plugins/rotate/build.bat
@@ -0,0 +1,3 @@
+@fasm -m 16384 rotate.asm rotate.obj
+@kpack rotate.obj
+@pause
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/rotate/build.sh b/programs/media/zsea/plugins/rotate/build.sh
new file mode 100644
index 0000000000..2843977bb5
--- /dev/null
+++ b/programs/media/zsea/plugins/rotate/build.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# This script does for Linux the same as build.bat for DOS,
+# it compiles the current KolibriOS applications
+
+ fasm -m 16384 rotate.asm rotate.obj
+ kpack rotate.obj
+ exit 0
+
+
+
diff --git a/programs/media/zsea/plugins/rotate/rotate.asm b/programs/media/zsea/plugins/rotate/rotate.asm
new file mode 100644
index 0000000000..343d98f531
--- /dev/null
+++ b/programs/media/zsea/plugins/rotate/rotate.asm
@@ -0,0 +1,301 @@
+;*****************************************************************************
+; Rotate RAW image plugin - for zSea image viewer
+; Copyright (c) 2009 - 2011, Marat Zakiyanov aka Mario79, aka Mario
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;*****************************************************************************
+; Rotate 32b, 24b, 16b, 8b
+
+format MS COFF
+
+public EXPORTS
+
+section '.flat' code readable align 16
+
+;include 'macros.inc'
+include '../../../../macros.inc'
+;---------------------------------------------------------------------
+START:
+ pushad
+ mov [pointer],eax
+; ebx - direction
+; 1 - clockwise, 2 - counter clockwise
+; 3 - Left&Right, 4 - Up&Down
+ mov [direction],ebx
+ mov eax,[eax+4]
+ mov [image_file],eax
+
+ mov esi,[eax+28]
+ add esi,eax
+; mov ecx,[eax+32]
+; xor ebx,ebx
+; mov [raw_area],ebx
+ mov ebx,[eax+12]
+ cmp ebx,32
+ jne @f
+ mov ebp,dword START.32
+ jmp .1
+@@:
+ cmp ebx,24
+ jne @f
+ mov ebp,dword START.24
+ jmp .1
+@@:
+ cmp ebx,16
+ jne @f
+ mov ebp,dword START.16
+ jmp .1
+@@:
+ cmp ebx,15
+ jne @f
+ inc ebx
+ mov ebp,dword START.16
+ jmp .1
+@@:
+ cmp ebx,8
+ jne @f
+ mov ebp,dword START.8
+@@:
+.1:
+ shr ebx,3
+ mov [bytes_to_pixel],ebx
+ mov ebx,[eax+4]
+ imul ebx,[bytes_to_pixel]
+ mov [size_x],ebx
+ mov ebx,[eax+8]
+ imul ebx,[bytes_to_pixel]
+ mov [size_y],ebx
+
+ call .get_memory
+
+ cmp [direction],1
+ jne @f
+ call .clockwise
+ jmp .end
+@@:
+ cmp [direction],2
+ jne @f
+ call .counter_clockwise
+ jmp .end
+@@:
+ cmp [direction],3
+ jne @f
+ call .Left_Right
+ jmp .end
+@@:
+ cmp [direction],4
+ jne .exit
+ call .Up_Down
+.end:
+ xchg esi,edi
+ mov ecx,[image_file]
+ mov eax,[ecx+4]
+ imul eax,[bytes_to_pixel]
+ imul eax,[ecx+8]
+
+ mov ecx,eax
+ cld
+ rep movsb
+
+ mov ecx,[raw_area]
+ mcall 68,13
+;---------------------------------------------------------------------
+.ret_ok:
+ cmp [direction],1
+ jne @f
+ call .XY_data_exchange
+ jmp .exit
+@@:
+ cmp [direction],2
+ jne .exit
+ call .XY_data_exchange
+.exit:
+ popad
+ ret
+;---------------------------------------------------------------------
+.XY_data_exchange:
+ mov ecx,[image_file]
+ mov eax,[ecx+4]
+ mov ebx,[ecx+8]
+ mov [ecx+8],eax
+ mov [ecx+4],ebx
+ ret
+;---------------------------------------------------------------------
+.clockwise:
+ push edi esi
+
+ add edi,[size_y]
+ sub edi,[bytes_to_pixel]
+.y:
+ push edi
+ push ebx
+.x:
+ call ebp
+ add edi,[size_y]
+ dec ebx
+ jnz .x
+
+ pop ebx
+ pop edi
+
+ sub edi,[bytes_to_pixel]
+ dec ecx
+ jnz .y
+
+ pop esi edi
+ ret
+;---------------------------------------------------------------------
+.counter_clockwise:
+ push edi esi
+
+ mov eax,[eax+4]
+ dec eax
+ imul eax,[size_y]
+ add edi,eax
+.y1:
+ push edi
+ push ebx
+.x1:
+ call ebp
+ sub edi,[size_y]
+ dec ebx
+ jnz .x1
+
+ pop ebx
+ pop edi
+
+ add edi,[bytes_to_pixel]
+ dec ecx
+ jnz .y1
+
+ pop esi edi
+ ret
+;---------------------------------------------------------------------
+.Left_Right:
+ push edi esi
+ add edi,[size_x]
+.y2:
+ push edi
+ push ebx
+.x2:
+ sub edi,[bytes_to_pixel]
+ call ebp
+ dec ebx
+ jnz .x2
+
+ pop ebx
+ pop edi
+
+ add edi,[size_x]
+ dec ecx
+ jnz .y2
+
+ pop esi edi
+ ret
+;---------------------------------------------------------------------
+.Up_Down:
+ push edi esi
+
+ mov eax,[eax+8]
+ dec eax
+ imul eax,[size_x]
+ add edi,eax
+.y3:
+ push edi
+ push ebx
+.x3:
+ call ebp
+ add edi,[bytes_to_pixel]
+ dec ebx
+ jnz .x3
+
+ pop ebx
+ pop edi
+
+ sub edi,[size_x]
+ dec ecx
+ jnz .y3
+
+ pop esi edi
+ ret
+;---------------------------------------------------------------------
+.32:
+ cld
+ lodsd
+ mov [edi],eax
+
+ ret
+;---------------------------------------------------------------------
+.24:
+ cld
+ lodsw
+ mov [edi],ax
+ lodsb
+ mov [edi+2],al
+ ret
+;---------------------------------------------------------------------
+.16:
+ cld
+ lodsw
+ mov [edi],ax
+ ret
+;---------------------------------------------------------------------
+.8:
+ cld
+ lodsb
+ mov [edi],al
+ ret
+;---------------------------------------------------------------------
+.get_memory:
+ mov ecx,[eax+4]
+ imul ecx,[eax+8]
+ imul ecx,[bytes_to_pixel]
+ push eax
+ mcall 68,12
+ mov [raw_area],eax
+ mov edi,eax
+ pop eax
+ mov ebx,[eax+4]
+ mov ecx,[eax+8]
+ ret
+;---------------------------------------------------------------------
+align 16
+EXPORTS:
+ dd szStart, START
+ dd szVersion, 0x00010001
+ dd 0
+
+szStart db 'START',0
+szVersion db 'version',0
+
+pointer dd 0
+image_file dd 0
+direction dd 0
+size_x dd 0
+size_y dd 0
+bytes_to_pixel dd 0
+;delta dd 0
+;resolution dd 0
+;compression dd 0
+raw_area dd 0
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/scaling/b_filter.inc b/programs/media/zsea/plugins/scaling/b_filter.inc
new file mode 100644
index 0000000000..c0ead5e112
--- /dev/null
+++ b/programs/media/zsea/plugins/scaling/b_filter.inc
@@ -0,0 +1,1001 @@
+;---------------------------------------------------------------------
+align 4
+.check_filtering_24:
+ cmp [filtering],0
+ je .24_1
+
+ mov ebx,[temp_y1]
+ inc ebx
+ cmp ebx,[y]
+ jae .last_y_24 ;.24_1
+
+ mov ebx,[temp_x1]
+ push eax
+ mov eax,[x]
+ dec eax
+ lea eax,[eax*3]
+ cmp ebx,eax
+ pop eax
+ jae .last_x_24 ;.24_1
+
+; mov ebx,[esp+4]
+;; test ebx,ebx
+;; jz .24_1
+; inc ebx
+; cmp bx,[new_size.y1]
+; jae .last_y ;.24_1
+
+; mov ebx,[esp]
+;; test ebx,ebx
+;; jz .24_1
+; inc ebx
+; cmp bx,[new_size.x1]
+; jae .last_x ;.24_1
+
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[ecx+3]
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ add ecx,[size_x]
+ mov eax,[ecx]
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[ecx+3]
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+.24_1:
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_y_24:
+ mov ebx,[temp_x1]
+ push eax
+ mov eax,[x]
+ dec eax
+ lea eax,[eax*3]
+ cmp ebx,eax
+ pop eax
+ jae .last_x_y_24 ;.24_1
+
+ mov ebx,[esp+4]
+; test ebx,ebx
+; jz .24_1
+ inc ebx
+ cmp bx,[new_size.x1]
+ jae .last_x_y_24 ;.24_1
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[ecx+3]
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ mov eax,[background_color]
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+;---------------------------------------
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_x_24:
+ mov ebx,[temp_y1]
+ inc ebx
+ cmp ebx,[y]
+ jae .last_x_y_24 ;.24_1
+
+ mov ebx,[esp+8]
+; test ebx,ebx
+; jz .24_1
+ inc ebx
+ cmp bx,[new_size.y1]
+ jae .last_x_y_24 ;.24_1
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ add ecx,[size_x]
+ mov eax,[ecx]
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_x_y_24:
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ mov eax,[background_color]
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+ ret
+;---------------------------------------------------------------------
+align 4
+.copy_RGB_to_RGB1:
+ mov eax,[B_sample]
+ mov [B_sample_1],eax
+ mov eax,[G_sample]
+ mov [G_sample_1],eax
+ mov eax,[R_sample]
+ mov [R_sample_1],eax
+ ret
+;---------------------------------------
+align 4
+.mix_RGB:
+ xor ebx,ebx
+ mov bl,al
+ imul ebx,edx
+ add [B_sample],ebx
+ shr eax,8
+ xor ebx,ebx
+ mov bl,al
+ imul ebx,edx
+ add [G_sample],ebx
+ shr eax,8
+ xor ebx,ebx
+ mov bl,al
+ imul ebx,edx
+ add [R_sample],ebx
+ ret
+;---------------------------------------
+align 4
+.mix_RGB_16:
+ xor ebx,ebx
+ mov bl,al
+ and bl,0x1F
+ imul ebx,edx
+ add [B_sample],ebx
+ shr eax,5
+ xor ebx,ebx
+ mov bl,al
+ cmp [resolution],16
+ jne @f
+ and bl,0x3F
+ shr eax,6
+ jmp .mix_RGB_16_G_sample
+align 4
+@@:
+ and bl,0x1F
+ shr eax,5
+align 4
+.mix_RGB_16_G_sample:
+ imul ebx,edx
+ add [G_sample],ebx
+ xor ebx,ebx
+ mov bl,al
+ and bl,0x1F
+ imul ebx,edx
+ add [R_sample],ebx
+ ret
+;---------------------------------------
+align 4
+.clear_RGB:
+ xor ebx,ebx
+ mov [B_sample],ebx
+ mov [G_sample],ebx
+ mov [R_sample],ebx
+ ret
+;---------------------------------------
+align 4
+.RGB_to_EAX:
+ mov eax,[R_sample]
+ shr eax,7
+ and eax,0xff
+ shl eax,8
+ mov ebx,[G_sample]
+ shr ebx,7
+ mov al,bl
+ shl eax,8
+ mov ebx,[B_sample]
+ shr ebx,7
+ mov al,bl
+ ret
+;---------------------------------------
+align 4
+.RGB_to_EAX_16:
+ mov eax,[R_sample]
+ shr eax,7
+ and eax,0x1F
+ mov ebx,[G_sample]
+ shr ebx,7
+ cmp [resolution],16
+ jne @f
+ shl eax,6
+ and ebx,0x3F
+ jmp .RGB_to_EAX_16_G_sample
+align 4
+@@:
+ shl eax,5
+ and ebx,0x1F
+align 4
+.RGB_to_EAX_16_G_sample:
+ add eax,ebx
+ shl eax,5
+ mov ebx,[B_sample]
+ shr ebx,7
+ and ebx,0x1F
+ add eax,ebx
+ ret
+;---------------------------------------
+align 4
+.RGB_to_EAX1:
+ mov eax,[R_sample_1]
+ shr eax,7
+ and eax,0xff
+ shl eax,8
+ mov ebx,[G_sample_1]
+ shr ebx,7
+ mov al,bl
+ shl eax,8
+ mov ebx,[B_sample_1]
+ shr ebx,7
+ mov al,bl
+ ret
+;---------------------------------------
+align 4
+.RGB_to_EAX1_16:
+ mov eax,[R_sample_1]
+ shr eax,7
+ and eax,0x1F
+ mov ebx,[G_sample_1]
+ shr ebx,7
+ cmp [resolution],16
+ jne @f
+ shl eax,6
+ and ebx,0x3F
+ jmp .RGB_to_EAX1_16_G_sample
+align 4
+@@:
+ shl eax,5
+ and ebx,0x1F
+align 4
+.RGB_to_EAX1_16_G_sample:
+ add eax,ebx
+ shl eax,5
+ mov ebx,[B_sample_1]
+ shr ebx,7
+ and ebx,0x1F
+ add eax,ebx
+ ret
+;---------------------------------------------------------------------
+align 4
+.check_filtering_32:
+ cmp [filtering],0
+ je .32_1
+
+ mov ebx,[temp_y1]
+ inc ebx
+ cmp ebx,[y]
+ jae .last_y_32 ;.24_1
+
+ mov ebx,[temp_x1]
+ push eax
+ mov eax,[x]
+ dec eax
+ shl eax,2
+ cmp ebx,eax
+ pop eax
+ jae .last_x_32 ;.24_1
+
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[ecx+4]
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ add ecx,[size_x]
+ mov eax,[ecx]
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[ecx+4]
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+.32_1:
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_y_32:
+ mov ebx,[temp_x1]
+ push eax
+ mov eax,[x]
+ dec eax
+ shl eax,2
+ cmp ebx,eax
+ pop eax
+ jae .last_x_y_32 ;.32_1
+
+ mov ebx,[esp+4]
+; test ebx,ebx
+; jz .24_1
+ inc ebx
+ cmp bx,[new_size.x1]
+ jae .last_x_y_32 ;.32_1
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[ecx+4]
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ mov eax,[background_color]
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_x_32:
+ mov ebx,[temp_y1]
+ inc ebx
+ cmp ebx,[y]
+ jae .last_x_y_32 ;.32_1
+
+ mov ebx,[esp+8]
+; test ebx,ebx
+; jz .24_1
+ inc ebx
+ cmp bx,[new_size.y1]
+ jae .last_x_y_32 ;.32_1
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ add ecx,[size_x]
+ mov eax,[ecx]
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_x_y_32:
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ mov eax,[background_color]
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+ ret
+;---------------------------------------------------------------------
+align 4
+.check_filtering_16:
+ cmp [filtering],0
+ je .16_1
+
+ mov ebx,[temp_y1]
+ inc ebx
+ cmp ebx,[y]
+ jae .last_y_16 ;.24_1
+
+ mov ebx,[temp_x1]
+ push eax
+ mov eax,[x]
+ dec eax
+ shl eax,1
+ cmp ebx,eax
+ pop eax
+ jae .last_x_16 ;.24_1
+
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB_16
+
+ mov edx,[next_pixel_x]
+ xor eax,eax
+ mov ax,[ecx+2]
+ call .mix_RGB_16
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ add ecx,[size_x]
+ xor eax,eax
+ mov ax,[ecx]
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB_16
+
+ mov edx,[next_pixel_x]
+ xor eax,eax
+ mov ax,[ecx+2]
+ call .mix_RGB_16
+
+ call .RGB_to_EAX_16
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB_16
+;----------------------------
+ call .RGB_to_EAX1_16
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB_16
+ call .RGB_to_EAX_16
+.16_1:
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_y_16:
+ mov ebx,[temp_x1]
+ push eax
+ mov eax,[x]
+ dec eax
+ shl eax,1
+ cmp ebx,eax
+ pop eax
+ jae .last_x_y_16 ;.16_1
+
+ mov ebx,[esp+4]
+; test ebx,ebx
+; jz .24_1
+ inc ebx
+ cmp bx,[new_size.x1]
+ jae .last_x_y_16 ;.16_1
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB_16
+
+ mov edx,[next_pixel_x]
+ xor eax,eax
+ mov ax,[ecx+2]
+ call .mix_RGB_16
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ mov eax,[background_color]
+ and eax,0xffff
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB_16
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ and eax,0xffff
+ call .mix_RGB_16
+
+ call .RGB_to_EAX_16
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB_16
+;----------------------------
+ call .RGB_to_EAX1_16
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB_16
+ call .RGB_to_EAX_16
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_x_16:
+ mov ebx,[temp_y1]
+ inc ebx
+ cmp ebx,[y]
+ jae .last_x_y_16 ;.16_1
+
+ mov ebx,[esp+8]
+; test ebx,ebx
+; jz .24_1
+ inc ebx
+ cmp bx,[new_size.y1]
+ jae .last_x_y_16 ;.16_1
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB_16
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ and eax,0xffff
+ call .mix_RGB_16
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ add ecx,[size_x]
+ xor eax,eax
+ mov ax,[ecx]
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB_16
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ and eax,0xffff
+ call .mix_RGB_16
+
+ call .RGB_to_EAX_16
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB_16
+;----------------------------
+ call .RGB_to_EAX1_16
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB_16
+ call .RGB_to_EAX_16
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_x_y_16:
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB_16
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ and eax,0xffff
+ call .mix_RGB_16
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ mov eax,[background_color]
+ and eax,0xffff
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB_16
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ and eax,0xffff
+ call .mix_RGB_16
+
+ call .RGB_to_EAX_16
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB_16
+;----------------------------
+ call .RGB_to_EAX1_16
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB_16
+ call .RGB_to_EAX_16
+ ret
+;---------------------------------------------------------------------
+align 4
+.get_palette:
+ shl eax,2
+ add eax,[palette]
+ mov eax,[eax]
+ ret
+;---------------------------------------------------------------------
+align 4
+.check_filtering_8:
+ xor eax,eax
+ mov al,[ecx]
+ call .get_palette
+
+ mov ebx,[temp_y1]
+ inc ebx
+ cmp ebx,[y]
+ jae .last_y_8
+
+ mov ebx,[temp_x1]
+ push eax
+ mov eax,[x]
+ dec eax
+ cmp ebx,eax
+ pop eax
+ jae .last_x_8
+
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ xor eax,eax
+ mov al,[ecx+1]
+ call .get_palette
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ add ecx,[size_x]
+ xor eax,eax
+ mov al,[ecx]
+ call .get_palette
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ xor eax,eax
+ mov al,[ecx+1]
+ call .get_palette
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+.8_1:
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_y_8:
+ mov ebx,[temp_x1]
+ push eax
+ mov eax,[x]
+ dec eax
+ cmp ebx,eax
+ pop eax
+ jae .last_x_y_8 ;.8_1
+
+ mov ebx,[esp+4]
+; test ebx,ebx
+; jz .24_1
+ inc ebx
+ cmp bx,[new_size.x1]
+ jae .last_x_y_8 ;.8_1
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ xor eax,eax
+ mov al,[ecx+1]
+ call .get_palette
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ mov eax,[background_color]
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+;---------------------------------------
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_x_8:
+ mov ebx,[temp_y1]
+ inc ebx
+ cmp ebx,[y]
+ jae .last_x_y_8 ;.8_1
+
+ mov ebx,[esp+8]
+; test ebx,ebx
+; jz .24_1
+ inc ebx
+ cmp bx,[new_size.y1]
+ jae .last_x_y_8 ;.8_1
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ add ecx,[size_x]
+ xor eax,eax
+ mov al,[ecx]
+ call .get_palette
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+ ret
+;---------------------------------------------------------------------
+align 4
+.last_x_y_8:
+;----------------------------
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+ call .mix_RGB
+;----------------------------
+ call .copy_RGB_to_RGB1
+;----------------------------
+ mov eax,[background_color]
+
+ call .clear_RGB
+ mov edx,128 ;100
+ sub edx,[next_pixel_x]
+ call .mix_RGB
+
+ mov edx,[next_pixel_x]
+ mov eax,[background_color]
+
+ call .mix_RGB
+
+ call .RGB_to_EAX
+
+ call .clear_RGB
+ mov edx,[next_pixel_y]
+ call .mix_RGB
+;----------------------------
+ call .RGB_to_EAX1
+;----------------------------
+ mov edx,128 ;100
+ sub edx,[next_pixel_y]
+ call .mix_RGB
+ call .RGB_to_EAX
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/scaling/build.bat b/programs/media/zsea/plugins/scaling/build.bat
new file mode 100644
index 0000000000..b4f4d02bc8
--- /dev/null
+++ b/programs/media/zsea/plugins/scaling/build.bat
@@ -0,0 +1,3 @@
+@fasm -m 16384 scaling.asm scaling.obj
+@kpack scaling.obj
+@pause
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/scaling/build.sh b/programs/media/zsea/plugins/scaling/build.sh
new file mode 100644
index 0000000000..c72e3e6e5c
--- /dev/null
+++ b/programs/media/zsea/plugins/scaling/build.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# This script does for Linux the same as build.bat for DOS,
+# it compiles the current KolibriOS applications
+
+ fasm -m 16384 scaling.asm scaling.obj
+ kpack scaling.obj
+ exit 0
+
+
+
diff --git a/programs/media/zsea/plugins/scaling/macros.inc b/programs/media/zsea/plugins/scaling/macros.inc
new file mode 100644
index 0000000000..6df8eca325
--- /dev/null
+++ b/programs/media/zsea/plugins/scaling/macros.inc
@@ -0,0 +1,269 @@
+; new application structure
+macro meos_app_start
+ {
+ use32
+ org 0x0
+
+ db 'MENUET01'
+ dd 0x01
+ dd __start
+ dd __end
+ dd __memory
+ dd __stack
+
+ if used __params & ~defined __params
+ dd __params
+ else
+ dd 0x0
+ end if
+
+ dd 0x0
+ }
+MEOS_APP_START fix meos_app_start
+
+macro code
+ {
+ __start:
+ }
+CODE fix code
+
+macro data
+ {
+ __data:
+ }
+DATA fix data
+
+macro udata
+ {
+ if used __params & ~defined __params
+ __params:
+ db 0
+ __end:
+ rb 255
+ else
+ __end:
+ end if
+ __udata:
+ }
+UDATA fix udata
+
+macro meos_app_end
+ {
+ align 32
+ rb 2048
+ __stack:
+ __memory:
+ }
+MEOS_APP_END fix meos_app_end
+
+
+; macro for defining multiline text data
+struc mstr [sstring]
+ {
+ forward
+ local ssize
+ virtual at 0
+ db sstring
+ ssize = $
+ end virtual
+ dd ssize
+ db sstring
+ common
+ dd -1
+ }
+
+
+; strings
+macro sz name,[data] { ; from MFAR [mike.dld]
+ common
+ if used name
+ label name
+ end if
+ forward
+ if used name
+ db data
+ end if
+ common
+ if used name
+ .size = $-name
+ end if
+}
+
+macro lsz name,[lng,data] { ; from MFAR [mike.dld]
+ common
+ if used name
+ label name
+ end if
+ forward
+ if (used name)&(lang eq lng)
+ db data
+ end if
+ common
+ if used name
+ .size = $-name
+ end if
+}
+
+
+
+; easy system call macro
+macro mpack dest, hsrc, lsrc
+{
+ if (hsrc eqtype 0) & (lsrc eqtype 0)
+ mov dest, (hsrc) shl 16 + lsrc
+ else
+ if (hsrc eqtype 0) & (~lsrc eqtype 0)
+ mov dest, (hsrc) shl 16
+ add dest, lsrc
+ else
+ mov dest, hsrc
+ shl dest, 16
+ add dest, lsrc
+ end if
+ end if
+}
+
+macro __mov reg,a,b { ; mike.dld
+ if (~a eq)&(~b eq)
+ mpack reg,a,b
+ else if (~a eq)&(b eq)
+ mov reg,a
+ end if
+}
+
+macro mcall a,b,c,d,e,f { ; mike.dld
+ __mov eax,a
+ __mov ebx,b
+ __mov ecx,c
+ __mov edx,d
+ __mov esi,e
+ __mov edi,f
+ int 0x40
+}
+
+
+
+; optimize the code for size
+__regs fix
+
+macro add arg1,arg2
+ {
+ if (arg2 eqtype 0)
+ if (arg2) = 1
+ inc arg1
+ else
+ add arg1,arg2
+ end if
+ else
+ add arg1,arg2
+ end if
+ }
+
+macro sub arg1,arg2
+ {
+ if (arg2 eqtype 0)
+ if (arg2) = 1
+ dec arg1
+ else
+ sub arg1,arg2
+ end if
+ else
+ sub arg1,arg2
+ end if
+ }
+
+macro mov arg1,arg2
+ {
+ if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
+ if (arg2) = 0
+ xor arg1,arg1
+ else if (arg2) = 1
+ xor arg1,arg1
+ inc arg1
+ else if (arg2) = -1
+ or arg1,-1
+ else if (arg2) > -128 & (arg2) < 128
+ push arg2
+ pop arg1
+ else
+ mov arg1,arg2
+ end if
+ else
+ mov arg1,arg2
+ end if
+ }
+
+
+macro struct name
+ {
+ virtual at 0
+ name name
+ sizeof.#name = $ - name
+ end virtual
+ }
+
+; structures used in MeOS
+struc process_information
+ {
+ .cpu_usage dd ? ; +0
+ .window_stack_position dw ? ; +4
+ .window_stack_value dw ? ; +6
+ .not_used1 dw ? ; +8
+ .process_name rb 12 ; +10
+ .memory_start dd ? ; +22
+ .used_memory dd ? ; +26
+ .PID dd ? ; +30
+ .x_start dd ? ; +34
+ .y_start dd ? ; +38
+ .x_size dd ? ; +42
+ .y_size dd ? ; +46
+ .slot_state dw ? ; +50
+ dw ? ; +52 - reserved
+ .client_left dd ? ; +54
+ .client_top dd ? ; +58
+ .client_width dd ? ; +62
+ .client_height dd ? ; +66
+ .wnd_state db ? ; +70
+ rb (1024-71)
+ }
+;struct process_information
+
+struc system_colors
+ {
+ .frame dd ?
+ .grab dd ?
+ .grab_button dd ?
+ .grab_button_text dd ?
+ .grab_text dd ?
+ .work dd ?
+ .work_button dd ?
+ .work_button_text dd ?
+ .work_text dd ?
+ .work_graph dd ?
+ }
+;struct system_colors
+
+
+; constants
+
+; events
+EV_IDLE = 0
+EV_TIMER = 0
+EV_REDRAW = 1
+EV_KEY = 2
+EV_BUTTON = 3
+EV_EXIT = 4
+EV_BACKGROUND = 5
+EV_MOUSE = 6
+EV_IPC = 7
+EV_STACK = 8
+
+; event mask bits for function 40
+EVM_REDRAW = 1b
+EVM_KEY = 10b
+EVM_BUTTON = 100b
+EVM_EXIT = 1000b
+EVM_BACKGROUND = 10000b
+EVM_MOUSE = 100000b
+EVM_IPC = 1000000b
+EVM_STACK = 10000000b
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/scaling/scaling.asm b/programs/media/zsea/plugins/scaling/scaling.asm
new file mode 100644
index 0000000000..4ee7d44840
--- /dev/null
+++ b/programs/media/zsea/plugins/scaling/scaling.asm
@@ -0,0 +1,481 @@
+;*****************************************************************************
+; Scaling RAW image plugin - for zSea image viewer
+; Copyright (c) 2009 - 2011, Marat Zakiyanov aka Mario79, aka Mario
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;*****************************************************************************
+; Scaling 32b, 24b, 16b, 8b
+
+format MS COFF
+
+public EXPORTS
+
+section '.flat' code readable align 16
+
+include 'macros.inc'
+include '../../../../macros.inc'
+;---------------------------------------------------------------------
+START:
+ pushad
+ mov [pointer],eax
+ test bx,bx
+ jnz @f
+ inc bx
+@@:
+ ror ebx,16
+ test bx,bx
+ jnz @f
+ inc bx
+@@:
+ rol ebx,16
+ mov [new_size],ebx
+ mov [start_coordinates],ecx
+ mov [scaling_mode],edx
+ mov [filtering],esi
+ mov [background_color],edi
+ mov eax,[eax+4]
+ mov [image_file],eax
+
+ mov esi,[eax+28]
+ add esi,eax
+
+ mov ebx,[eax+20]
+ add ebx,eax
+ mov [palette],ebx
+
+ mov ebx,[eax+12]
+ mov [resolution],ebx
+ cmp ebx,32
+ jne @f
+ mov ebp,dword START.32
+ jmp .1
+@@:
+ cmp ebx,24
+ jne @f
+ mov ebp,dword START.24
+ jmp .1
+@@:
+ cmp ebx,16
+ jne @f
+ mov ebp,dword START.16
+ jmp .1
+@@:
+ cmp ebx,15
+ jne @f
+ inc ebx
+ mov ebp,dword START.16
+ jmp .1
+@@:
+ cmp ebx,8
+ jne @f
+ mov ebp,dword START.8
+@@:
+.1:
+ shr ebx,3
+ mov [bytes_to_pixel],ebx
+
+ mov ebx,[eax+8]
+ mov [y],ebx
+ mov ebx,[eax+4]
+ mov [x],ebx
+ imul ebx,[bytes_to_pixel]
+ mov [size_x],ebx
+
+ mov eax,100
+ shl eax,12
+ mov ebx,[scaling_mode]
+ test ebx,ebx
+ jnz @f
+ inc ebx
+@@:
+ xor edx,edx
+ div ebx
+ mov [scaling_delta],eax
+
+ call .get_memory
+ cmp [scaling_mode],0
+ jne @f
+ call .scaling
+ jmp .ret_ok
+@@:
+ call .scaling_2
+
+;---------------------------------------------------------------------
+.ret_ok:
+ mcall 68,13,[area_for_x]
+ mov ebx,[pointer]
+ mov eax,[raw_area]
+ mov [ebx+20],eax ; store RAW pointer
+; movzx eax,word [new_size.x1]
+; mov [ebx+24],esi ;eax
+; movzx eax,word [new_size.y1]
+; mov [ebx+28],eax
+; mov eax,[size_x]
+; mov [ebx+32],eax
+; mov eax,[bytes_to_pixel]
+; mov [ebx+36],eax
+; mov eax,[x]
+; mov [ebx+40],eax
+; mov eax,[y]
+; mov [ebx+44],eax
+.exit:
+ popad
+ ret
+;---------------------------------------------------------------------
+align 4
+.scaling:
+ xor ecx,ecx
+.y:
+ xor ebx,ebx
+;-------------------------
+.x:
+ call ebp
+ inc ebx
+ cmp bx,[new_size.x1]
+ jb .x
+;-------------------------
+ inc ecx
+ cmp cx,[new_size.y1]
+ jb .y
+ ret
+;---------------------------------------------------------------------
+align 4
+.scaling_2:
+ xor eax,eax
+ mov ax,[start_coordinates.y]
+ imul eax,[size_x]
+ add esi,eax
+ xor eax,eax
+ mov ax,[start_coordinates.x]
+ imul eax,[bytes_to_pixel]
+ add esi,eax
+
+ xor eax,eax
+ dec eax
+ mov [temp_y],eax
+
+ xor ecx,ecx
+align 4
+.y_2:
+ xor ebx,ebx
+;-------------------------
+align 4
+.x_2:
+ call ebp
+ inc ebx
+ cmp bx,[new_size.x1]
+ jb .x_2
+;-------------------------
+ inc ecx
+ cmp cx,[new_size.y1]
+ jb .y_2
+ ret
+;---------------------------------------------------------------------
+align 4
+.32:
+ push ecx ebx
+ call .calculate_pixel
+ mov eax,[ecx]
+ call .check_filtering_32
+ pop ebx ecx
+ cld
+ stosd
+ ret
+;---------------------------------------------------------------------
+align 4
+.24:
+ push ecx ebx
+ call .calculate_pixel
+ mov eax,[ecx]
+ call .check_filtering_24
+ cld
+ stosw
+ shr eax,16
+ pop ebx ecx
+ cld
+ stosb
+ ret
+;---------------------------------------------------------------------
+align 4
+.16:
+ push ecx ebx
+ call .calculate_pixel
+ xor eax,eax
+ mov ax,[ecx]
+ call .check_filtering_16
+ pop ebx ecx
+ cld
+ stosw
+ ret
+;---------------------------------------------------------------------
+align 4
+.8:
+ push ecx ebx
+ call .calculate_pixel
+ cmp [filtering],0
+ jne @f
+ mov al,[ecx]
+ pop ebx ecx
+ cld
+ stosb
+ ret
+@@:
+ call .check_filtering_8
+ cld
+ stosw
+ shr eax,16
+ pop ebx ecx
+ cld
+ stosb
+ ret
+
+;---------------------------------------------------------------------
+align 4
+.calculate_pixel:
+ test ecx,ecx
+ jz .offset_x
+;.offset_y:
+ mov eax,ecx
+
+ mov ecx,[temp_y]
+ cmp eax,ecx
+ jne .new_y
+ mov eax,[temp_y_offset]
+ mov ecx,eax
+ jmp .offset_x
+;--------------------------------
+align 4
+.new_y:
+ mov [temp_y],eax
+
+ mov ebx,[scaling_mode]
+ test ebx,ebx
+ jz @f
+ imul eax,[scaling_delta]
+;--------------------------------
+ push ebx
+ mov ebx,eax
+ shr eax,12
+ and ebx,0xFFF
+ shl ebx,7 ;multiply 128
+ shr ebx,12
+ mov [next_pixel_y],ebx
+ pop ebx
+;--------------------------------
+ jmp .ex_1
+align 4
+@@:
+;--------------------------------
+ imul eax,dword [y]
+ mov bx,word [new_size.y1]
+;--------------------------------
+align 4
+.y_div:
+ test ebx,ebx
+ jnz @f
+ inc ebx
+align 4
+@@:
+ xor edx,edx
+ div ebx
+;--------------------------------
+ push eax
+ mov eax,edx
+ shl eax,7 ;multiply 128
+ xor edx,edx
+ div ebx
+ mov [next_pixel_y],eax
+ pop eax
+;--------------------------------
+align 4
+.ex_1:
+ mov [temp_y1],eax
+ imul eax,[size_x]
+
+ mov [temp_y_offset],eax
+ mov ecx,eax
+align 4
+.offset_x:
+ test ebx,ebx
+ jz .finish
+ mov eax,[esp+4] ;ebx
+
+ mov edx,[esp+8]
+ test edx,edx
+ jz .continue
+ shl eax,3
+ add eax,[area_for_x]
+ mov edx,[eax+4]
+ mov [next_pixel_x],edx
+ mov eax,[eax]
+ jmp .ex_3
+;--------------------------------
+align 4
+.continue:
+ mov ebx,[scaling_mode]
+ test ebx,ebx
+ jz @f
+ imul eax,[scaling_delta]
+;--------------------------------
+ mov ebx,eax
+ shr eax,12
+ and ebx,0xFFF
+ shl ebx,7 ;multiply 128
+ shr ebx,12
+ mov [next_pixel_x],ebx
+;--------------------------------
+ jmp .ex_2
+;--------------------------------
+align 4
+@@:
+ imul eax,dword [x]
+ mov bx,word [new_size.x1]
+;--------------------------------
+align 4
+.x_div:
+ test ebx,ebx
+ jnz @f
+ inc ebx
+align 4
+@@:
+ xor edx,edx
+ div ebx
+;--------------------------------
+ push eax
+ mov eax,edx
+ shl eax,7 ;multiply 128
+ xor edx,edx
+ div ebx
+ mov [next_pixel_x],eax
+ pop eax
+;--------------------------------
+align 4
+.ex_2:
+ mov edx,[bytes_to_pixel]
+ mov ebx,eax
+ xor eax,eax
+align 4
+@@:
+ add eax,ebx
+ dec edx
+ jnz @r
+
+ mov ebx,[esp+4]
+ shl ebx,3
+ add ebx,[area_for_x]
+ mov [ebx],eax
+ mov edx,[next_pixel_x]
+ mov [ebx+4],edx
+align 4
+.ex_3:
+ mov [temp_x1],eax
+ add ecx,eax
+align 4
+.finish:
+ add ecx,esi
+ ret
+;---------------------------------------------------------------------
+align 4
+.get_memory:
+
+ xor ecx,ecx
+ mov cx,[new_size.x1]
+ shl ecx,3
+ mcall 68,12
+ mov [area_for_x],eax
+
+ xor ecx,ecx
+ mov ebx,[new_size]
+ mov cx,bx
+ shr ebx,16
+ imul ecx,ebx ;[eax+8]
+ mov eax,[bytes_to_pixel]
+ cmp eax,1
+ jne @f
+ mov eax,3
+@@:
+ imul ecx,eax
+ mcall 68,12
+ mov [raw_area],eax
+ mov edi,eax
+ ret
+;---------------------------------------------------------------------
+include 'b_filter.inc'
+;---------------------------------------------------------------------
+align 4
+EXPORTS:
+ dd szStart, START
+ dd szVersion, 0x00010001
+ dd 0
+
+szStart db 'START',0
+szVersion db 'version',0
+
+align 4
+pointer dd 0
+image_file dd 0
+new_size:
+.y1: dw 0
+.x1: dw 0
+
+x: dd 0
+y: dd 0
+
+size_x dd 0
+bytes_to_pixel dd 0
+
+start_coordinates:
+.y dw 0
+.x dw 0
+
+scaling_mode dd 0
+raw_area dd 0
+scaling_delta dd 0
+
+area_for_x dd 0
+
+temp_y dd 0
+temp_y_offset dd 0
+
+resolution dd 0
+
+filtering dd 0
+
+next_pixel_y dd 0
+next_pixel_x dd 0
+
+temp_y1 dd 0
+temp_x1 dd 0
+
+B_sample dd 0
+G_sample dd 0
+R_sample dd 0
+
+B_sample_1 dd 0
+G_sample_1 dd 0
+R_sample_1 dd 0
+
+palette dd 0
+
+background_color dd 0
\ No newline at end of file
diff --git a/programs/media/zsea/plugins/scaling/scaling.obj b/programs/media/zsea/plugins/scaling/scaling.obj
new file mode 100644
index 0000000000..ad6f329394
Binary files /dev/null and b/programs/media/zsea/plugins/scaling/scaling.obj differ
diff --git a/programs/media/zsea/w_about.inc b/programs/media/zsea/w_about.inc
new file mode 100644
index 0000000000..d3a06b22be
--- /dev/null
+++ b/programs/media/zsea/w_about.inc
@@ -0,0 +1,128 @@
+;---------------------------------------------------------------------
+ kabout:
+ test dword [status],4
+ jnz still
+ or dword [status],4
+
+ call get_memory_for_tread_stack
+ mov [thread_stack_3],eax
+ mcall 51,1,thread3 ;,thread_stack_3
+ jmp still
+;---------------------------------------------------------------------
+thread3: ; start of bgrd thread
+ mcall 9, procinfo_threads, -1
+ mov eax,[ebx+30]
+ mov [PID3],eax
+ mcall 40, 0x7
+.red:
+ call .draw_window
+
+.still:
+
+ mov eax,10 ; wait here for event
+ mcall
+
+ cmp eax,1 ; redraw request ?
+ je .red
+ cmp eax,2 ; key in buffer ?
+ je .close ;.key
+ cmp eax,3 ; button in buffer ?
+ je .button
+
+ jmp .still
+
+; .key:
+; mcall
+; cmp ah,27
+; je .close
+; jmp .still
+
+
+.button: ; button
+ mov eax,17 ; get id
+ mcall
+
+ cmp ah,1 ; button id=1 ?
+ je .close
+ cmp ah,2
+ jne .still ;noclose3
+.close:
+; btr dword [status],3
+; bts dword [status],2
+ xor dword [status],4
+ xor eax,eax
+ mov [PID3],eax
+ mcall 68,13,[thread_stack_3]
+ mov eax,-1 ; close this program
+ mcall
+; .noclose:
+; jmp still3
+
+
+
+
+; *********************************************
+; ******* WINDOW DEFINITIONS AND DRAW ********
+; *********************************************
+
+
+.draw_window:
+
+
+ mov eax,12 ; function 12:tell os about windowdraw
+ mov ebx,1 ; 1, start of draw
+ mcall
+
+ ; DRAW WINDOW
+ xor eax,eax ; function 0 : define and draw window
+ mov ebx,100*65536+300 ; [x start] *65536 + [x size]
+ mov ecx,100*65536+240 ; [y start] *65536 + [y size]
+ mov edx,0x03eeeeee ; color of work area RRGGBB,8->color gl
+ mcall
+
+ mov ebx,120*65536+40
+ mov ecx,210*65536+20
+ mov edx,2
+ mov esi,0xdddddd
+ mcall 8
+
+ pusha
+ mcall 4,<20,30>,0x80000000,Authors_text.1
+ mcall ,<30,45>, ,Authors_text.2
+
+ mcall ,<30,60>, ,Authors_text.3
+ mcall ,<60,70>, ,Authors_text.4
+ mcall ,<60,80>, ,Authors_text.5
+ mcall ,<60,90>, ,Authors_text.6
+ mcall ,<60,100>, ,Authors_text.7
+
+ mcall ,<30,115>, ,Authors_text.8
+ mcall ,<60,125>, ,Authors_text.9
+ mcall ,<60,135>, ,Authors_text.10
+
+ mcall ,<30,150>, ,Authors_text.11
+ mcall ,<60,160>, ,Authors_text.12
+
+ mcall ,<30,175>, ,Authors_text.13
+ mcall ,<60,185>, ,Authors_text.14
+ popa
+
+ add ebx,15 shl 16
+ shr ecx,16
+ mov bx,cx
+ add ebx,6
+
+ mov ecx,0
+ mov edx, ok_btn
+ mov esi, ok_btn.size ;2
+ mcall 4
+
+ ; WINDOW LABEL
+ mcall 71,1, labelt3
+; mcall 47,0x80000,[PID3],<200, 5>,0xffffff
+ mov eax,12 ; function 12:tell os about windowdraw
+ mov ebx,2 ; 2, end of draw
+ mcall
+
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/w_error.inc b/programs/media/zsea/w_error.inc
new file mode 100644
index 0000000000..04bf78eddd
--- /dev/null
+++ b/programs/media/zsea/w_error.inc
@@ -0,0 +1,92 @@
+error_window:
+ test dword [status],32
+ jnz still
+ or dword [status],32
+ mcall 9, procinfo, -1
+ mov eax,[ebx+46]
+ test eax,eax
+ jnz @f
+ mov eax,100
+ mov [error_window_y+2],ax
+ mov [error_window_x+2],ax
+ jmp .end
+@@:
+ shr eax,1
+ add eax,[ebx+38]
+ sub eax,50
+ mov [error_window_y+2],ax
+ mov eax,[ebx+42]
+ shr eax,1
+ add eax,[ebx+34]
+ sub eax,150
+ mov [error_window_x+2],ax
+.end:
+ call get_memory_for_tread_stack
+ mov [thread_stack_6],eax
+ mcall 51,1,thread6 ;,thread_stack_6
+ ret
+;---------------------------------------------------------------------
+thread6:
+ mcall 9, procinfo_threads, -1
+ mov eax,[ebx+30]
+ mov [PID6],eax
+ mcall 40, 0x7
+ mov [error_pointer],string
+.red:
+ call .draw_error_window
+.still:
+ mcall 10
+ cmp eax,1
+ je .red
+ cmp eax,2 ; key in buffer ?
+ je .key
+ cmp eax,3
+ je .button
+ jmp .still
+.key: ; key
+.button:
+ xor dword [status],32
+ xor eax,eax
+ mov [PID6],eax
+
+ mcall 68,13,[thread_stack_6]
+ mcall -1
+ jmp .still
+;---------------------------------------------------------------------
+.draw_error_window:
+ mcall 12, 1
+ mcall 0,[error_window_x] ,[error_window_y], 0x03ff0000
+ mcall 71,1, errortext
+ mcall 4,<10,30>,0x80ffffff,[error_pointer]
+ cmp [return_code],0
+ je .continue
+ cmp [return_code],1
+ jne @f
+ mcall 4,<10,50>,0x90ffffff,error_not_supported_file
+ jmp .end
+@@:
+ cmp [return_code],2
+ jne @f
+ mcall 4,<10,50>,0x90ffffff,error_not_enough_memory
+ jmp .end
+@@:
+ mcall 4,<10,50>,0x90ffffff,error_unknown
+ jmp .end
+.continue:
+ mcall 4,<10,50>,0x90ffffff,error_type
+ mcall 47,0x800a0000,[error_fs],<140,50>,0x10ffffff
+ mov edx,[error_fs]
+ cmp edx,0
+ jb .end
+ cmp edx,11
+ ja .end
+ shl edx,2
+ add edx,error_fs_text_pointers
+ mov edx,[edx]
+ mcall 4,<10,70>,0x90ffffff,
+; mcall 47,0x800a0000,[error_locate],<140,5>,0x10ffffff
+.end:
+; mcall 47,0x80000,[PID6],<200, 5>,0xffffff
+ mcall 12, 2
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/win_bcgr.inc b/programs/media/zsea/win_bcgr.inc
new file mode 100644
index 0000000000..48e8217f0b
--- /dev/null
+++ b/programs/media/zsea/win_bcgr.inc
@@ -0,0 +1,143 @@
+;---------------------------------------------------------------------
+k_background:
+ test dword [status],8
+ jnz still
+ or dword [status],8
+
+ call get_memory_for_tread_stack
+ mov [thread_stack_4],eax
+ mcall 51,1,thread4 ;, thread_stack_4
+ jmp still
+;---------------------------------------------------------------------
+thread4: ; start of bgrd thread
+ mcall 9, procinfo_threads, -1
+ mov eax,[ebx+30]
+ mov [PID4],eax
+ mcall 40, 0x27
+.red:
+ call .draw_window
+
+.still:
+
+ mov eax,10 ; wait here for event
+ mcall
+
+ cmp eax,1 ; redraw request ?
+ je .red
+ cmp eax,2 ; key in buffer ?
+ je .key
+ cmp eax,3 ; button in buffer ?
+ je .button
+ cmp eax,6 ; mouse in buffer ?
+ je .mouse
+ jmp .still
+
+.mouse:
+ push dword option_boxes_bcgr
+ call [option_box_mouse]
+
+ cmp [option_group1],op1
+ jne @f
+ mov [bgrmode],dword 1
+ jmp .still
+@@:
+ mov [bgrmode],dword 2
+ jmp .still
+
+.key:
+ mcall
+ cmp ah,27
+ je .close
+ cmp ah,13
+ je .kok
+ cmp ah,178 ;up
+ jne .nofup
+ cmp dword [bgrmode],1
+ je .fdn
+.fup:
+ dec dword [bgrmode]
+ jmp .flagcont
+.nofup:
+ cmp ah,177 ;down
+ jne .still
+ cmp dword [bgrmode],2
+ je .fup
+.fdn:
+ inc dword [bgrmode]
+.flagcont:
+ cmp [bgrmode],dword 1
+ jne @f
+ mov [option_group1],op1
+ call .draw_opt_boxes
+ jmp .still
+@@:
+ mov [option_group1],op2
+ call .draw_opt_boxes
+ jmp .still
+
+
+.button: ; button
+ mov eax,17 ; get id
+ mcall
+
+ cmp ah,1 ; button id=1 ?
+ jne .noclose
+.close:
+ xor dword [status],8
+ xor eax,eax
+ mov [PID4],eax
+
+ mcall 68,13,[thread_stack_4]
+ mov eax,-1 ; close this program
+ mcall
+.noclose:
+.kok:
+ call background
+ jmp .close
+
+; *********************************************
+; ******* WINDOW DEFINITIONS AND DRAW ********
+; *********************************************
+
+
+.draw_window:
+ mcall 12,1
+ ; DRAW WINDOW
+ xor eax,eax ; function 0 : define and draw window
+ mov ebx,100*65536+200 ; [x start] *65536 + [x size]
+ mov ecx,100*65536+100 ; [y start] *65536 + [y size]
+ mov edx,0x03909090 ; color of work area RRGGBB,8->color gl
+ mcall
+
+ mov eax,8
+ mov ebx,70*65536+40
+ mov ecx,70*65536+20
+ mov edx,4
+ mov esi,0xdddddd
+ mcall
+
+ ; WINDOW LABEL
+ mcall 71,1, labelt4
+
+ mov eax,4 ; function 4 : write text to window
+ mov ebx,46*65536+28 ; [x start] *65536 + [y start]
+ mov ecx,0xffffff
+ mov edx, bgrdtext
+ mov esi, bgrdtext.size
+ mcall
+ add ebx,40*65536+48
+ mov edx, ok_btn
+ mov esi, ok_btn.size ;2
+ mov ecx,0
+ mcall
+
+ call .draw_opt_boxes
+; mcall 47,0x80000,[PID4],<200, 5>,0xffffff
+ mcall 12,2
+
+ ret
+;---------------------------------------------------------------------
+.draw_opt_boxes:
+ push dword option_boxes_bcgr
+ call [option_box_draw]
+ ret
\ No newline at end of file
diff --git a/programs/media/zsea/win_file.inc b/programs/media/zsea/win_file.inc
new file mode 100644
index 0000000000..2f00c5aca4
--- /dev/null
+++ b/programs/media/zsea/win_file.inc
@@ -0,0 +1,195 @@
+;---------------------------------------------------------------------
+kfile:
+ test dword [status],1
+ jnz still
+ or dword [status],1
+
+ call load_directory.copy_dir_path
+
+; call get_filter_data
+
+
+ cmp [OpenDialog_path],dword 'NoKe'
+ je @f
+ mov [OpenDialog_data.start_path],dword OpenDialog_path
+ jmp .start_OpenDialog
+@@:
+ mov ebx,open_dialog_name
+ mov esi,path
+ mov edi,library_path
+ call copy_file_path
+
+.start_OpenDialog:
+
+;start_OpenDialog OpenDialog_data
+ push dword OpenDialog_data
+ call [OpenDialog_Start]
+
+ call clear_control_key_flag
+
+ cmp [OpenDialog_data.status],2
+ je thread1_start
+ cmp [OpenDialog_data.status],1
+ jne @f
+ xor dword [status],1
+ jmp kopen_1
+@@:
+ xor dword [status],1
+ jmp still
+
+thread1_start:
+
+ call get_memory_for_tread_stack
+ mov [thread_stack],eax
+ mcall 51,1,thread1 ;, thread_stack
+ jmp still
+;---------------------------------------------------------------------
+get_filter_data:
+ mov edi,Filter+4
+ xor eax,eax
+ mov ecx,10
+ cld
+@@:
+ mov esi,10
+ sub esi,ecx
+ lea esi,[esi+esi*2] ; x 3
+ shl esi,3 ; x 8
+ add esi,dword Convert_plugin_0.Assoc
+ mov esi,[esi]
+ add esi,4
+
+ test esi,esi
+ jz @f
+ call .start
+ dec ecx
+ jnz @r
+@@:
+ mov [edi],byte 0
+ mov eax,Filter
+ sub edi,eax
+ mov [eax],edi
+
+ ret
+.start:
+@@:
+ lodsb
+ stosb
+ test eax,eax
+ jnz @r
+ cmp [esi],ah
+ jne @r
+ ret
+;---------------------------------------------------------------------
+thread1: ; start of thread1
+ mcall 9, procinfo_threads, -1
+ mov eax,[ebx+30]
+ mov [PID1],eax
+ mcall 40, 0x27
+
+ or ecx,-1 ; get information about me
+ call getappinfo
+
+ mov esi,string
+@@:
+ cld
+ lodsb
+ test al,al
+ jne @r
+ sub esi,string
+ mov eax,esi
+ dec eax
+ mov edi, edit1
+ mov [edi+48], eax ;ed_size
+ mov [edi+52], eax ;ed_pos
+.red:
+ call .draw_window
+
+.still:
+
+ mcall 10 ; wait here for event
+
+ cmp eax,1 ; redraw request ?
+ je .red
+ cmp eax,2 ; key in buffer ?
+ je .key
+ cmp eax,3 ; button in buffer ?
+ je .button
+
+ push dword name_editboxes
+ call [edit_box_mouse]
+; mouse_edit_box name_editboxes
+; mouse_menubar menu_data_2
+ jmp .still
+
+.key: ; key
+ mcall 2
+ cmp ah,13
+ je .close_with_open_file
+ cmp ah,27
+ je .close
+
+ push dword name_editboxes
+ call [edit_box_key]
+; key_edit_box name_editboxes
+ jmp .still
+
+.close_with_open_file:
+ mov [open_file_flag],byte 1
+ jmp .close
+
+.button: ; button
+ mov eax,17 ; get id
+ mcall
+
+ cmp ah,1 ; button id=1 ?
+ jne .still
+.close:
+; bts dword [status],2
+; btr dword [status],0
+ xor dword [status],1
+ xor eax,eax
+ mov [PID1],eax
+ mcall 68,13,[thread_stack]
+ mov eax,-1 ; close this program
+ mcall
+
+ jmp .still
+
+; *********************************************
+; ******* WINDOW DEFINITIONS AND DRAW ********
+; *********************************************
+
+
+.draw_window:
+
+
+ mov eax,12 ; function 12:tell os about windowdraw
+ mov ebx,1 ; 1, start of draw
+ mcall
+
+ ; DRAW WINDOW
+ xor eax,eax ; function 0 : define and draw window
+ mov ebx,100*65536+300 ; [x start] *65536 + [x size]
+ mov ecx,100*65536+80 ; [y start] *65536 + [y size]
+ mov edx,0x03eeeeee ; color of work area RRGGBB,8->color gl
+ mcall
+
+ ; WINDOW LABEL
+
+ mcall 71,1, labelt1
+
+ push dword name_editboxes
+ call [edit_box_draw]
+; draw_edit_box name_editboxes
+; mcall 47,0x80000,[PID1],<200, 5>,0xffffff
+; mcall 71,1, proverka
+; mcall 47,0x80001,0,<300, 5>,0xffffff
+; draw_menu_bar menu_data_2
+ mov eax,12 ; function 12:tell os about windowdraw
+ mov ebx,2 ; 2, end of draw
+ mcall
+
+ ret
+
+
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/win_info.inc b/programs/media/zsea/win_info.inc
new file mode 100644
index 0000000000..f177950c4c
--- /dev/null
+++ b/programs/media/zsea/win_info.inc
@@ -0,0 +1,269 @@
+;---------------------------------------------------------------------
+ kinfo:
+ test dword [status],2
+ jnz still
+ or dword [status],2
+
+ call get_memory_for_tread_stack
+ mov [thread_stack_2],eax
+ mcall 51,1,thread2 ;, thread_stack_2
+ jmp still
+;---------------------------------------------------------------------
+thread2: ; start of info thread
+ mcall 9, procinfo_threads, -1
+ mov eax,[ebx+30]
+ mov [PID2],eax
+ mcall 40, 0x7
+ call load_directory.copy_dir_path
+.red:
+ call .draw_window
+
+.still:
+
+ mov eax,10 ; wait here for event
+ mcall
+
+ cmp eax,1 ; redraw request ?
+ je .red
+ cmp eax,2 ; key in buffer ?
+ je .close
+ cmp eax,3 ; button in buffer ?
+ je .button
+
+ jmp .still
+
+.button: ; button
+ mov eax,17 ; get id
+ mcall
+
+ cmp ah,1 ; button id=1 ?
+ jne .still ;.noclose
+.close:
+; btr dword [status],1
+; bts dword [status],2
+ xor dword [status],2
+ xor eax,eax
+ mov [PID2],eax
+ mcall 68,13,[thread_stack_2]
+ mov eax,-1 ; close this program
+ mcall
+;.noclose:
+; jmp .still
+
+
+
+
+; *********************************************
+; ******* WINDOW DEFINITIONS AND DRAW ********
+; *********************************************
+
+
+.draw_window:
+
+
+ mov eax,12 ; function 12:tell os about windowdraw
+ mov ebx,1 ; 1, start of draw
+ mcall
+
+ ; DRAW WINDOW
+ xor eax,eax ; function 0 : define and draw window
+ mov ebx,100*65536+330 ; [x start] *65536 + [x size]
+ mov ecx,100*65536+120 ;290 ; [y start] *65536 + [y size]
+ mov edx,0x03eeeeee ; color of work area RRGGBB,8->color gl
+ mcall
+
+ ; WINDOW LABEL
+ mcall 71,1, labelt2
+
+; mov ecx,0x80000000 ; font 1 & color ( 0xF0RRGGBB )
+; mov ebx,120*65536+30
+; mov edx,file_name ;string
+; mov esi,1 ;43
+ mcall 4,<120,30>,0x80000000,file_name
+ mov edx,fitext
+ mov esi,14
+ mov ebx,10*65536+30
+ mov ecx,0x10000000
+@@:
+ mcall
+ add ebx,10
+ add edx,esi
+ cmp ebx,10*65536+80
+ jbe @r
+ mov eax,47
+ mov edx,120*65536+40
+ mov esi,ecx
+ mov ecx, [img_size]
+ mov ebx,0x800a0000
+ mcall
+ add edx,10
+ mov ecx,[img_width_2]
+ mcall
+ add edx,10
+ mov ecx,[img_high_2]
+ mcall
+ add edx,10
+ mov ecx,[img_resolution_2]
+ mcall
+ add edx,10
+ mov ecx,[Total_Repeat_N]
+ mcall
+
+; add edx,10
+; mov ecx,[communication_area]
+; mov ecx,[ecx+4096]
+; mcall
+
+; add edx,10
+; mov ecx,[communication_area]
+; mov ecx,[ecx+4096+4]
+; mcall
+
+; add edx,10+10
+; mov ecx,[zoom_auto_factor]
+; mcall
+
+; add edx,10+10
+; mov ecx,[scroll_bar_data_vertical.max_area] ;[img_resolution]
+; mcall
+; add edx,10
+; mov ecx,[scroll_bar_data_vertical.cur_area] ;[return_code]
+; mcall
+; add edx,10
+; mov ecx,[scroll_bar_data_vertical.position]
+; mcall
+; add edx,10
+; xor ecx,ecx
+; mov cx,[scroll_bar_data_vertical.size_y]
+; mcall
+
+; add edx,10+10
+; mcall 47,0x80000,[OpenDialog_Init]
+
+; add edx,10+10
+; mcall 47,0x80000,[OpenDialog_Start]
+
+; add edx,10+10
+; mcall 47,0x80000,[OpenDialog_data.com_area]
+
+; add edx,10+10
+; mcall 47,0x80000,I_END
+
+; add edx,10+10
+; mov ecx,[scroll_bar_data_horizontal.max_area] ;[img_resolution]
+; mcall
+; add edx,10
+; mov ecx,[scroll_bar_data_horizontal.cur_area] ;[return_code]
+; mcall
+; add edx,10
+; mov ecx,[scroll_bar_data_horizontal.position]
+; mcall
+; add edx,10
+; xor ecx,ecx
+; mov cx,[scroll_bar_data_horizontal.size_x]
+; mcall
+
+; add edx,10
+; mov ecx,[raw_pointer] ;[deflate_unpack]
+; mcall
+
+; add edx,10+10
+; mov ebp,test1 ;raw_pointer_2
+; mov ecx,[ebp]
+; mcall
+
+; add edx,10+10
+; mov ebp,size_before_open_dir ;lib_init ;test1 ;raw_pointer_2
+; mov ecx,[ebp]
+; mcall
+; add edx,10
+; add ebp,4
+; mov ecx,[ebp]
+; mcall
+; add edx,10
+; add ebp,4
+; mov ecx,[ebp]
+; mcall
+; add edx,10
+; add ebp,4
+; mov ecx,[ebp]
+; mcall
+; add edx,10
+; add ebp,4
+; mov ecx,[ebp]
+; mcall
+; add edx,10
+; add ebp,4
+; mov ecx,[ebp]
+; mcall
+; add edx,10
+; add ebp,4
+; mov ecx,[ebp]
+; mcall
+; add edx,10
+; add ebp,4
+; mov ecx,[ebp]
+; mcall
+; add edx,10
+; add ebp,4
+; mov ecx,[ebp]
+; mcall
+; add edx,10
+; add ebp,4
+; mov ecx,[ebp]
+; mcall
+
+; add edx,10
+; add ebp,4
+; mov ecx,[version_lib_ini]
+;; mov ecx,[ecx]
+; mcall
+
+; add edx,10
+; movzx ecx,word [image_draw_size.x]
+; mcall
+; add edx,10
+; movzx ecx,word [image_draw_size.y]
+; mcall
+; add edx,10+10
+; movzx ecx,word [wa_width]
+; mcall
+; add edx,10
+; movzx ecx,word [wa_high]
+; mcall
+; add edx,10
+; movzx ecx,word [wa_width_1]
+; mcall
+; add edx,10
+; movzx ecx,word [wa_width_2]
+; mcall
+; add edx,10
+; movzx ecx,word [wa_high_1]
+; mcall
+; add edx,10
+; movzx ecx,word [wa_high_2]
+; mcall
+
+; add edx,10+10
+; mov ecx,[window_width]
+; mcall
+; add edx,10
+; mov ecx,[window_high]
+; mcall
+
+; add edx,10
+; xor ecx,ecx
+; mov cl,[Disposal_Method]
+; mcall
+
+; add edx,10
+; mov ecx,[soi]
+; mcall
+; mcall 47,0x80000,[PID2],<200, 5>,0xffffff
+; mcall 47,0x800a0000,[error_locate],<140,5>,0x10ffffff
+ mov eax,12 ; function 12:tell os about windowdraw
+ mov ebx,2 ; 2, end of draw
+ mcall
+
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/win_opti.inc b/programs/media/zsea/win_opti.inc
new file mode 100644
index 0000000000..0bf601a21f
--- /dev/null
+++ b/programs/media/zsea/win_opti.inc
@@ -0,0 +1,386 @@
+;---------------------------------------------------------------------
+k_option:
+ test dword [status],64
+ jnz still
+ or dword [status],64
+
+ call get_memory_for_tread_stack
+ mov [thread_stack_7],eax
+ mcall 51,1,thread7 ;,thread_stack_7
+ jmp still
+;---------------------------------------------------------------------
+get_memory_for_tread_stack:
+ mcall 68,12,4096
+ mov edx,eax
+ add edx,4096
+ ret
+;---------------------------------------------------------------------
+thread7: ; start of bgrd thread
+ mcall 9, procinfo_threads, -1
+ mov eax,[ebx+30]
+ mov [PID7],eax
+ mcall 40, 0x27
+ mov eax,[slide_show_delay]
+ mov [slide_show_delay_old],eax
+ mov eax,[arrows_offset]
+ mov [arrows_offset_old],eax
+ mov eax,[check1+32]
+ mov [show_file_name_old],eax
+ mov eax,[check2+32]
+ mov [filtering_flag_old],eax
+ xor eax,eax
+ mov [option_pointer],eax
+ call .set_pointers
+.red:
+ call .draw_window
+
+.still:
+
+ mov eax,10 ; wait here for event
+ mcall
+
+ cmp eax,1 ; redraw request ?
+ je .red
+ cmp eax,2 ; key in buffer ?
+ je .key
+ cmp eax,3 ; button in buffer ?
+ je .button
+ cmp eax,6 ; mouse in buffer ?
+ je .mouse
+ jmp .still
+
+.mouse:
+ mov ebx,[check1+32]
+ and ebx,10b
+ push dword check1
+ call [check_box_mouse]
+ mov eax,[check1+32]
+ and eax,10b
+ cmp ebx,eax
+ je @f ;.still
+ mov [option_pointer],2
+ call .set_pointers
+ call .draw_all_options_values
+ jmp .still
+@@:
+ mov ebx,[check2+32]
+ and ebx,10b
+ push dword check2
+ call [check_box_mouse]
+ mov eax,[check2+32]
+ and eax,10b
+ cmp ebx,eax
+ je .still
+ mov [option_pointer],3
+ call .set_pointers
+ call .draw_all_options_values
+ jmp .still
+;---------------------------------------------------------------------
+.key:
+ mcall
+ cmp ah,27
+ je .close
+ cmp ah,13
+ je .kok
+ cmp ah,32
+ je .select_space
+ cmp ah,56 ;plus
+ je .select_plus ;.plus_slide_show_delay
+ cmp ah,43 ;plus
+ je .select_plus ;.plus_slide_show_delay
+ cmp ah,61 ;plus
+ je .select_plus ;.plus_slide_show_delay
+ cmp ah,54 ;minus
+ je .select_minus ;.minus_slide_show_delay
+ cmp ah,45 ;minus
+ je .select_minus ;.minus_slide_show_delay
+ cmp ah,95 ;minus
+ je .select_minus ;.minus_slide_show_delay
+ cmp ah,178 ;up arrow
+ je .up_arrow
+ cmp ah,177 ;down arrow
+ je .down_arrow
+ jmp .still
+;---------------------------------------------------------------------
+.button: ; button
+ mov eax,17 ; get id
+ mcall
+
+ cmp ah,5
+ je .minus_arrows_offset
+
+ cmp ah,4
+ je .plus_arrows_offset
+
+ cmp ah,3
+ je .minus_slide_show_delay
+
+ cmp ah,2
+ je .plus_slide_show_delay
+
+ cmp ah,1 ; button id=1 ?
+ jne .noclose
+.close:
+ mov eax,[slide_show_delay_old]
+ mov [slide_show_delay],eax
+ mov eax,[arrows_offset_old]
+ mov [arrows_offset],eax
+ mov eax,[show_file_name_old]
+ mov [check1+32],eax
+ mov eax,[filtering_flag_old]
+ mov [check2+32],eax
+ jmp .close_all
+.close_1:
+ mov eax,[check2+32]
+ test eax,10b
+ jz @f
+ mov [filtering_flag],1
+ jmp .redraw_flag
+@@:
+ mov [filtering_flag],0
+.redraw_flag:
+ mov [redraw_flag],byte 1
+.close_all:
+ xor dword [status],64
+ xor eax,eax
+ mov [PID7],eax
+
+ mcall 68,13,[thread_stack_7]
+
+ mov eax,-1 ; close this program
+ mcall
+.noclose:
+
+.kok:
+
+ jmp .close_1
+;---------------------------------------------------------------------
+.select_plus:
+ jmp [plus_pointer]
+;---------------------------------------------------------------------
+.select_minus:
+ jmp [minus_pointer]
+;---------------------------------------------------------------------
+.select_space:
+ jmp [space_pointer]
+;---------------------------------------------------------------------
+.plus_slide_show_delay:
+ cmp [option_pointer],0
+ je @f
+ mov [option_pointer],0
+ call .draw_all_options_values
+@@:
+ cmp [slide_show_delay],99990
+ je .still
+ add [slide_show_delay],10
+ call .draw_slide_show_delay
+ jmp .still
+;---------------------------------------------------------------------
+.minus_slide_show_delay:
+ cmp [option_pointer],0
+ je @f
+ mov [option_pointer],0
+ call .draw_all_options_values
+@@:
+ cmp [slide_show_delay],0
+ je .still
+ sub [slide_show_delay],10
+ call .draw_slide_show_delay
+ jmp .still
+;---------------------------------------------------------------------
+.plus_arrows_offset:
+ cmp [option_pointer],1
+ je @f
+ mov [option_pointer],1
+ call .draw_all_options_values
+@@:
+ cmp [arrows_offset],100
+ je .still
+ inc [arrows_offset]
+ call .draw_arrows_offset
+ call calculate_arrows_offset
+ jmp .still
+;---------------------------------------------------------------------
+.minus_arrows_offset:
+ cmp [option_pointer],1
+ je @f
+ mov [option_pointer],1
+ call .draw_all_options_values
+@@:
+ cmp [arrows_offset],1
+ je .still
+ dec [arrows_offset]
+ call .draw_arrows_offset
+ call calculate_arrows_offset
+ jmp .still
+;---------------------------------------------------------------------
+.space_check1:
+ test [check1+32],dword 10b
+ jnz @f
+ or [check1+32],dword 10b
+ jmp .space_check1_1
+@@:
+ xor [check1+32],dword 10b
+.space_check1_1:
+ call .draw_all_options_values
+ jmp .still
+;---------------------------------------------------------------------
+.space_check2:
+ test [check2+32],dword 10b
+ jnz @f
+ or [check2+32],dword 10b
+ jmp .space_check2_1
+@@:
+ xor [check2+32],dword 10b
+.space_check2_1:
+ call .draw_all_options_values
+ jmp .still
+;---------------------------------------------------------------------
+.down_arrow:
+ cmp [option_pointer],3
+ je .still
+ inc [option_pointer]
+.draw_all_points:
+ call .set_pointers
+ call .draw_all_options_values
+ jmp .still
+;---------------------------------------------------------------------
+.up_arrow:
+ cmp [option_pointer],0
+ je .still
+ dec [option_pointer]
+ jmp .draw_all_points
+;---------------------------------------------------------------------
+.set_pointers:
+ cmp [option_pointer],0
+ jne @f
+ mov [plus_pointer],thread7.plus_slide_show_delay
+ mov [minus_pointer],thread7.minus_slide_show_delay
+ mov [space_pointer],thread7.still
+ ret
+@@:
+ cmp [option_pointer],1
+ jne @f
+ mov [plus_pointer],thread7.plus_arrows_offset
+ mov [minus_pointer],thread7.minus_arrows_offset
+ mov [space_pointer],thread7.still
+ ret
+@@:
+ cmp [option_pointer],2
+ jne @f
+ mov [plus_pointer],thread7.still
+ mov [minus_pointer],thread7.still
+ mov [space_pointer],thread7.space_check1
+ ret
+@@:
+ mov [plus_pointer],thread7.still
+ mov [minus_pointer],thread7.still
+ mov [space_pointer],thread7.space_check2
+ ret
+;---------------------------------------------------------------------
+.draw_all_options_values:
+ call .draw_slide_show_delay
+ call .draw_arrows_offset
+ call .draw_check1
+ call .draw_check2
+ ret
+;---------------------------------------------------------------------
+; *********************************************
+; ******* WINDOW DEFINITIONS AND DRAW ********
+; *********************************************
+
+
+.draw_window:
+ mcall 12,1
+ ; DRAW WINDOW
+ xor eax,eax ; function 0 : define and draw window
+ mov ebx,100*65536+300 ; [x start] *65536 + [x size]
+ mov ecx,100*65536+120 ; [y start] *65536 + [y size]
+ mov edx,0x03909090 ; color of work area RRGGBB,8->color gl
+ mcall
+
+ mcall 8,<15,10>,<50,11>,2,0xdddddd
+ inc edx
+ mcall ,<77,10>
+;---------------------------------
+ inc edx
+ mcall ,<15,10>,<90,11>
+ inc edx
+ mcall ,<77,10>
+;---------------------------------
+ inc edx
+ mcall ,<250,40>,<50,20>
+;---------------------------------
+
+; mcall 13,<50,45>,<25,12>,0xffffff
+; mov ecx,[ch_flag_en]
+; mcall 47,0x800a0000,,<72,27>,0x10000000; 0x40000000,0xffffff
+ ; WINDOW LABEL
+ mcall 71,1, optiontext
+
+; mov eax,4 ; function 4 : write text to window
+; mov ebx,46*65536+28 ; [x start] *65536 + [y start]
+; mov ecx,0xffffff
+; mov edx, sorttext
+; mov esi, sorttext.size
+; mcall
+; mov ebx,135*65536+57
+; mov edx, ok_btn
+; mov esi, ok_btn.size ;2
+ mcall 4,<10,35>,0x80ffffff,slide_show_delay_title
+ mcall ,<17,53>,0x90000000,slide_show_delay_text
+ mcall ,<10,75>,0x80ffffff,arrows_offset_title
+ mcall ,<17,93>,0x90000000,slide_show_delay_text
+ mcall ,<265,57>, ,ok_btn
+
+ call .draw_all_options_values
+
+; mcall 47,0x80000,[PID5],<200, 5>,0xffffff
+ mcall 12,2
+
+ ret
+;---------------------------------------------------------------------
+;.draw_opt_boxes:
+; draw_option_boxes option_boxes_sort,option_boxes_sort_end
+; ret
+;---------------------------------------------------------------------
+.draw_slide_show_delay:
+ mov edx,0xffffff
+ cmp [option_pointer],0
+ jne @f
+ mov edx,0xffff80
+@@:
+ mcall 13,<29,45>,<50,12>,
+ mcall 47,0x800a0000,[slide_show_delay],<32,52>,0x10000000; 0x40000000,0xffffff
+ ret
+;---------------------------------------------------------------------
+.draw_arrows_offset:
+ mov edx,0xffffff
+ cmp [option_pointer],1
+ jne @f
+ mov edx,0xffff80
+@@:
+ mcall 13,<29,45>,<90,12>,
+ mcall 47,0x800a0000,[arrows_offset],<32,92>,0x10000000; 0x40000000,0xffffff
+ ret
+;---------------------------------------------------------------------
+.draw_check1:
+ mov [check1+12],dword 0xffffff
+ cmp [option_pointer],2
+ jne @f
+ mov [check1+12],dword 0xffff80
+@@:
+ push dword check1
+ call [check_box_draw]
+ ret
+;---------------------------------------------------------------------
+.draw_check2:
+ mov [check2+12],dword 0xffffff
+ cmp [option_pointer],3
+ jne @f
+ mov [check2+12],dword 0xffff80
+@@:
+ push dword check2
+ call [check_box_draw]
+ ret
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/win_sort.inc b/programs/media/zsea/win_sort.inc
new file mode 100644
index 0000000000..54ff5896b1
--- /dev/null
+++ b/programs/media/zsea/win_sort.inc
@@ -0,0 +1,206 @@
+;---------------------------------------------------------------------
+k_sort_directory:
+ test dword [status],16
+ jnz still
+ or dword [status],16
+
+ call get_memory_for_tread_stack
+ mov [thread_stack_5],eax
+ mcall 51, 1, thread5 ;, thread_stack_5
+ jmp still
+;---------------------------------------------------------------------
+thread5: ; start of bgrd thread
+ mcall 9, procinfo_threads, -1
+ mov eax,[ebx+30]
+ mov [PID5],eax
+ mcall 40, 0x27
+ mov eax,[sort_type]
+ cmp [sort_type],dword 0
+ jne @f
+ mov [option_group2],sort0
+ jmp .thread5
+@@:
+ cmp [sort_type],dword 2
+ jne @f
+ mov [option_group2],sort2
+ jmp .thread5
+@@:
+ cmp [sort_type],dword 4
+ jne @f
+ mov [option_group2],sort4
+ jmp .thread5
+@@:
+; cmp [sort_type],dword 6
+; jne @f
+ mov [option_group2],sort6
+; jmp .thread5
+;@@:
+.thread5:
+ mov [sort_type_old],eax
+ mov eax,[option_group2]
+ mov [option_group2_old],eax
+
+.red:
+ call .draw_window
+
+.still:
+
+ mov eax,10 ; wait here for event
+ mcall
+
+ cmp eax,1 ; redraw request ?
+ je .red
+ cmp eax,2 ; key in buffer ?
+ je .key
+ cmp eax,3 ; button in buffer ?
+ je .button
+ cmp eax,6 ; mouse in buffer ?
+ je .mouse
+ jmp .still
+
+.mouse:
+ push dword option_boxes_sort
+ call [option_box_mouse]
+
+ cmp [option_group2],sort0
+ jne @f
+ mov [sort_type],dword 0
+ jmp .still
+@@:
+ cmp [option_group2],sort2
+ jne @f
+ mov [sort_type],dword 2
+ jmp .still
+@@:
+ cmp [option_group2],sort4
+ jne @f
+ mov [sort_type],dword 4
+ jmp .still
+@@:
+ cmp [option_group2],sort6
+ jne @f
+ mov [sort_type],dword 6
+ jmp .still
+
+.key:
+ mcall
+ cmp ah,27
+ je .close
+ cmp ah,13
+ je .kok
+ cmp ah,177 ;down
+ je .fdn
+ cmp ah,178 ;up
+ jne .still
+ cmp [sort_type],0
+ je .still
+
+ sub [sort_type],2
+ jmp .flagcont
+
+.fdn:
+ cmp [sort_type],6
+ je .still
+ add [sort_type],2
+
+.flagcont:
+ cmp [sort_type],dword 0
+ jne @f
+ mov [option_group2],sort0
+ call .draw_opt_boxes
+ jmp .still
+@@:
+ cmp [sort_type],dword 2
+ jne @f
+ mov [option_group2],sort2
+ call .draw_opt_boxes
+ jmp .still
+@@:
+ cmp [sort_type],dword 4
+ jne @f
+ mov [option_group2],sort4
+ call .draw_opt_boxes
+ jmp .still
+@@:
+ cmp [sort_type],dword 6
+ jne .still ;@f
+ mov [option_group2],sort6
+ call .draw_opt_boxes
+ jmp .still
+
+.button: ; button
+ mov eax,17 ; get id
+ mcall
+
+ cmp ah,1 ; button id=1 ?
+ jne .noclose
+.close:
+ mov eax,[sort_type_old]
+ mov [sort_type],eax
+ mov eax,[option_group2_old]
+ mov [option_group2],eax
+.close_1:
+ xor dword [status],16
+ xor eax,eax
+ mov [PID5],eax
+
+ mcall 68,13,[thread_stack_5]
+ mov eax,-1 ; close this program
+ mcall
+.noclose:
+.kok:
+ mov eax,[load_directory_pointer]
+ cmp [eax+4],dword 0
+ je .close_1
+ call load_directory.copy_dir_path
+ call load_directory.sort
+ mov [sort_directory_flag],byte 1
+ jmp .close_1
+
+; *********************************************
+; ******* WINDOW DEFINITIONS AND DRAW ********
+; *********************************************
+
+
+.draw_window:
+ mcall 12,1
+
+ ; DRAW WINDOW
+ xor eax,eax ; function 0 : define and draw window
+ mov ebx,100*65536+300 ; [x start] *65536 + [x size]
+ mov ecx,100*65536+110 ; [y start] *65536 + [y size]
+ mov edx,0x03909090 ; color of work area RRGGBB,8->color gl
+ mcall
+
+ mov eax,8
+ mov ebx,120*65536+40
+ mov ecx,50*65536+20
+ mov edx,4
+ mov esi,0xdddddd
+ mcall
+
+ ; WINDOW LABEL
+ mcall 71,1, labelt5
+
+ mov eax,4 ; function 4 : write text to window
+ mov ebx,46*65536+28 ; [x start] *65536 + [y start]
+ mov ecx,0xffffff
+ mov edx, sorttext
+ mov esi, sorttext.size
+ mcall
+ mov ebx,135*65536+57
+ mov edx, ok_btn
+ mov esi, ok_btn.size ;2
+ mov ecx,0
+ mcall
+
+ call .draw_opt_boxes
+; mcall 47,0x80000,[PID5],<200, 5>,0xffffff
+ mcall 12,2
+
+ ret
+;---------------------------------------------------------------------
+.draw_opt_boxes:
+ push dword option_boxes_sort
+ call [option_box_draw]
+ ret
\ No newline at end of file
diff --git a/programs/media/zsea/zSea.asm b/programs/media/zsea/zSea.asm
new file mode 100644
index 0000000000..deb96b1fe5
--- /dev/null
+++ b/programs/media/zsea/zSea.asm
@@ -0,0 +1,448 @@
+;*****************************************************************************
+; zSea - advanced image viewer for KolibriOS
+; Copyright (c) 2008-2011, Marat Zakiyanov aka Mario79, aka Mario
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+; * Neither the name of the nor the
+; names of its contributors may be used to endorse or promote products
+; derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;*****************************************************************************
+; v.1.0 r3 12.06.2011
+;******************************************************************************
+ use32
+ org 0x0
+ db 'MENUET01' ; 8 byte id
+ dd 0x01 ; header version
+ dd START ; start of code
+ dd IM_END ; size of image
+ dd I_END ; memory for app
+ dd stacktop ; esp
+ dd temp_area ; I_Param
+ dd path ; APPLICATION PACH
+
+include 'lang.inc'
+;include 'macros.inc'
+;include 'editbox_ex.mac'
+;include 'proc32.inc'
+
+include '../../macros.inc'
+include '../../develop/libraries/box_lib/trunk/box_lib.mac'
+include '../../proc32.inc'
+
+;include 'load_lib.mac'
+include '../../develop/libraries/box_lib/load_lib.mac'
+ @use_library ;use load lib macros
+;******************************************************************************
+
+START: ; start of execution
+ mcall 68, 11
+ mcall 66, 1,1
+ mcall 40, 0x27
+
+ mcall 9, procinfo, -1
+ mov eax,[ebx+30]
+ mov [PID],eax
+ xor ecx,ecx
+@@:
+ inc ecx
+ mcall 9, procinfo
+ mov eax,[PID]
+ cmp eax,[ebx+30]
+ jne @r
+ mov [active_process],ecx
+
+ mcall 68,12,1024
+ mov [menu_data_1.procinfo],eax
+ mov [menu_data_2.procinfo],eax
+ mov [menu_data_3.procinfo],eax
+ mov [menu_data_4.procinfo],eax
+ mov [menu_data_5.procinfo],eax
+ mov [menu_data_6.procinfo],eax
+
+ mov [load_directory_pointer],dir_header
+
+
+ call load_plugins
+
+
+ call load_buttons
+
+; call init_data_OpenDialog
+
+;init_OpenDialog OpenDialog_data
+ push dword OpenDialog_data
+ call [OpenDialog_Init]
+
+ call get_filter_data
+
+;-----------------------------------------------------
+; check for parameters
+ cmp dword [temp_area],'BOOT'
+ jne .no_boot
+.background:
+ call load_image
+ cmp [error_fs],0
+ jnz .exit
+ call convert
+
+ call background
+
+.exit:
+ call Set_ini
+.exit_1:
+ mov ebx,18
+ mov edx,PID1
+ mov esi,7
+.kill_successors:
+ mov ecx,[edx]
+ add edx,4
+ test ecx,ecx
+ jz @f
+ mcall 18
+@@:
+ dec esi
+ jnz .kill_successors
+
+ mcall -1
+;-----------------------------------------------------
+ .no_boot:
+ xor eax,eax
+ cmp byte [temp_area],al
+ jnz @f
+ mov [file_name],eax
+ jmp .no_param
+@@:
+
+
+ mov edi,string ; clear string
+ mov ecx,256/4 ; length of a string
+ xor eax,eax ; symbol <0>
+ rep stosd
+
+
+ mov edi,temp_area ; look for <0> in temp_area
+
+ cmp [edi],byte "\"
+ jne .continue
+ cmp [edi+1],byte "T"
+ jne @f
+ mov [bgrmode],dword 1
+ jmp .continue_1
+@@:
+ cmp [edi+1],byte "S"
+ jne START.exit
+ mov [bgrmode],dword 2
+.continue_1:
+ add edi,4
+.continue:
+ mov esi,edi
+ mov ecx,257 ; strlen
+ repne scasb
+ lea ecx, [edi-temp_area]
+
+ mov edi,string
+ rep movsb ; copy string from temp_area to "string" (filename)
+ cmp [temp_area],byte "\"
+ je START.background
+ call load_directory
+ test eax,eax
+ jnz @f
+ call load_image
+ test eax,eax
+ jnz @f
+ call convert
+ jmp .no_param
+@@:
+ mov [load_directory_pointer],dir_header
+ mov [error_fs],eax
+ call convert.error
+;-----------------------------------------------------
+ .no_param:
+; or ecx,-1 ; get information about me
+; call getappinfo
+
+; mov edx,[process_info+30] ; edx
+; mov ecx,eax
+
+; @@:
+; call getappinfo
+; cmp edx,[process_info+30]
+; je @f ; PID PID ,
+; dec ecx ;
+; jne @b ; ,
+; @@:
+
+; ecx
+; mov [process],ecx
+;---------------------------------------------------------------------
+ cmp [wnd_width],635
+ jae @f
+ mov [wnd_width],635
+@@:
+ cmp [wnd_height],150
+ jae @f
+ mov [wnd_height],150
+@@:
+; call draw_window
+red:
+;draw_still:
+; pusha
+ call get_window_param
+ test [window_status],10b
+ jnz red_1 ;still
+ test [window_status],100b
+ jnz red_1
+ test [window_status],1b
+ jnz red_1
+ mov esi,-1
+ mov eax,procinfo
+ mov eax,[eax+66]
+ cmp eax,150
+; cmp [window_high],150
+ jae @f
+ mov esi,150
+ mcall 67,-1,ebx,ebx
+@@:
+ mov edx,-1
+ mov eax,procinfo
+ mov eax,[eax+62]
+ cmp eax,635
+; cmp [window_width],635
+ jae @f ;red_1
+ mov edx,635
+ mcall 67,-1,ebx, ,ebx
+@@:
+; mcall 67,-1,ebx
+; popa
+; xor esi,esi
+red_1:
+; xor eax,eax
+; mov [scroll_bar_data_vertical.position],eax
+; mov [scroll_bar_data_horizontal.position],eax
+
+ call draw_window
+
+ cmp [redraw_wallpaper_flag],0
+ je still
+ mov [redraw_wallpaper_flag],0
+ call clear_thread
+; mcall 15,3
+; jmp red_1
+still:
+ cmp [RAW1_flag],1
+ je animation_handler
+ mcall 10
+.1:
+ cmp [open_file_flag],1
+ je kopen_1
+ cmp [sort_directory_flag],byte 1
+ je red_sort_directory
+ cmp [redraw_flag],byte 1
+ je redraw_window
+ cmp eax,1 ; ?
+ je red ; - red
+ cmp eax,2 ; ?
+ je key ; - key
+ cmp eax,3 ; ?
+ je button ; - button
+ cmp eax,6
+ je mouse
+; cmp [redraw_wallpaper_flag],1
+; jne still
+; mov [redraw_wallpaper_flag],0
+; mcall 15,3
+ jmp still ; -
+
+red_sort_directory:
+ mov [sort_directory_flag],byte 0
+ jmp red_1
+
+redraw_window:
+ mov [redraw_flag],byte 0
+ jmp red_1
+;---------------------------------------------------------------------
+; red:
+; test dword [status], 4
+; jz draw_still
+; mov al,18
+; mov ebx,3
+; mov ecx,[process]
+; mcall 18,3,[active_process]
+; and byte [status], not 4
+; jmp still
+;---------------------------------------------------------------------
+button: ; button
+ mov eax,17 ; get id
+ mcall
+ cmp ah,1 ; button id=1 ?
+ je START.exit
+; jne .noclose
+;
+; mov eax,-1 ; close this program
+; mcall
+.noclose:
+ cmp ah,2
+ je slide_show.3 ;still
+ jmp slide_show
+;---------------------------------------------------------------------
+kopen_1:
+
+ mov [open_file_flag],0
+ call load_directory
+ test eax,eax
+ jz kopen
+.err:
+ mov [load_directory_pointer],dir_header
+ mov [error_fs],eax
+ call convert.error
+ jmp still ;red_1
+
+kopen:
+ cmp [string],byte 0
+ je still
+
+ mov ecx,-1
+ call getappinfo
+
+ call load_image
+
+ test eax,eax
+ jnz kopen_1.err
+ call convert
+
+.1:
+ call get_window_param
+ test [window_status],1b
+ jz red ;draw_still
+ mov [no_draw_window],1
+
+; push edx
+; mov edx,size_after_convert_2
+; call write_memory_size
+; pop edx
+
+ call draw_other
+
+ mov [no_draw_window],0
+; jmp draw_still
+ jmp still
+;---------------------------------------------------------------------
+getappinfo:
+ mov eax,9
+ mov ebx,process_info
+ mcall
+ ret
+;---------------------------------------------------------------------
+;
+background:
+ cmp [soi],0
+ je .end
+ mov ecx,[img_width] ;
+ test ecx,ecx
+ jz .end
+ mov edx,[img_high] ;
+ test edx,edx
+ jz .end
+ mcall 15,1 ; set size
+
+ mov esi,ecx
+ imul esi,edx
+ lea esi,[esi*3]
+; mov ebx,5
+ mov ecx,[soi]
+
+ xor edx,edx
+
+ cmp [img_resolution],24
+ je @f
+ mov eax,image_file
+; call [plugin_convert_background]
+ call [convert_Conv_24b]
+ mov ecx,[raw_pointer_2]
+ mcall 15,5 ;15,5 set data
+ mov ecx,[raw_pointer_2]
+ mcall 68,13
+ jmp .set_mode
+@@:
+
+ mcall 15,5 ; 15,5 set data
+.set_mode:
+; dec ebx ;tile/stretch
+ mov ecx,[bgrmode]
+ mcall 15,4 ; 15,4 set mode
+
+ dec ebx ; 15,3 redraw background
+ mcall
+
+.end:
+ ret
+;---------------------------------------------------------------------
+get_window_param:
+ mcall 9, procinfo, -1
+ mov eax,[ebx+34]
+ mov [window_start_x],eax
+ mov eax,[ebx+38]
+ mov [window_start_y],eax
+ mov eax,[ebx+66] ;46]
+ inc eax
+ mov [window_high],eax
+ mov eax,[ebx+62] ;42]
+ inc eax
+ mov [window_width],eax
+ mov eax,[ebx+70]
+ mov [window_status],eax
+; mcall 48,4
+; mov [skin_high],eax
+ ret
+;---------------------------------------------------------------------
+;write_memory_size:
+; pusha
+; mcall 9, procinfo, -1
+; mov eax,[ebx+26]
+; mov [edx],eax
+; popa
+; ret
+;---------------------------------------------------------------------
+include 'draw_win.inc'
+include 'full_win.inc'
+include 'mouse.inc'
+include 'key.inc'
+include 'menu_key.inc'
+include 'clr_bcgr.inc'
+include 'w_error.inc'
+include 'load.inc'
+include 'animat.inc'
+include 'draw_img.inc'
+include 'convert.inc'
+include 'zoom.inc'
+include 'w_about.inc'
+include 'win_file.inc'
+include 'win_info.inc'
+include 'win_bcgr.inc'
+include 'win_sort.inc'
+include 'win_opti.inc'
+include 'libini.inc'
+include 'dll.inc'
+include 'data.inc'
+;---------------------------------------------------------------------
+IM_END:
+include 'dat_area.inc'
+I_END:
diff --git a/programs/media/zsea/zSea.ini b/programs/media/zsea/zSea.ini
new file mode 100644
index 0000000000..8301415507
--- /dev/null
+++ b/programs/media/zsea/zSea.ini
@@ -0,0 +1,35 @@
+[Associations]
+ImageEditor=/sys/media/animage
+TextViewer=/sys/tinypad
+
+[Path]
+Plugins=/plugins/
+SysLibrary=/sys/lib/
+ButtonPictures=/buttons/
+
+[Files]
+PassiveButtonsPic=1.png
+AktiveButtonsPic=2.png
+ClickButtonsPic=3.png
+DisableAButtonsPic=4.png
+HelpText=zSea_keys.txt
+
+[Plugins]
+BoxLib=box_lib.obj
+Sort=sort.obj
+Convert=convert.obj
+Rotate=rotate.obj
+Scaling=scaling.obj
+Plugin1=cnv_bmp.obj
+Plugin2=cnv_png.obj
+Plugin3=cnv_jpeg.obj
+Plugin4=cnv_gif.obj
+
+[Var]
+SortMode=2
+ArrowsOffset=10
+SlideShowDelay=300
+
+ShowFileName=1
+FullScreen=1
+Zoom=100
\ No newline at end of file
diff --git a/programs/media/zsea/zoom.inc b/programs/media/zsea/zoom.inc
new file mode 100644
index 0000000000..b2a16da5d1
--- /dev/null
+++ b/programs/media/zsea/zoom.inc
@@ -0,0 +1,725 @@
+;---------------------------------------------------------------------
+invert_left_to_right:
+ mov ebx,3
+ jmp rotate_counter_clockwise.1
+;---------------------------------------------------------------------
+invert_up_to_down:
+ mov ebx,4
+ jmp rotate_counter_clockwise.1
+;---------------------------------------------------------------------
+rotate_clockwise:
+ mov ebx,1
+ jmp rotate_counter_clockwise.1
+;---------------------------------------------------------------------
+rotate_counter_clockwise:
+ mov ebx,2
+.1:
+ mov eax,[soi]
+ test eax,eax
+ jz still
+
+ mov eax,[RAW1_pointer]
+ test eax,eax
+ jz @f
+ cmp [Total_Repeat_N],1
+ ja still
+@@:
+
+ push ebx
+ call proc_position_correct
+ mov eax,[vertical_position_coorect]
+ mov ebx,[horizontal_position_coorect]
+ mov [horizontal_position_coorect],eax
+ mov [vertical_position_coorect],ebx
+ pop ebx
+ mov eax,image_file
+; call [plugin_rotate]
+ call [rotate_Start]
+ mov ebx,[raw_pointer]
+ mov eax,[ebx+4]
+ mov [img_width],eax
+ mov eax,[ebx+8]
+ mov [img_high],eax
+ call convert.img_resolution_ok
+ jmp kopen.1
+;---------------------------------------------------------------------
+calculate_arrows_offset:
+ mov eax,[arrows_offset]
+ imul eax,[scaling_mode]
+ mov ebx,100
+ xor edx,edx
+ div ebx
+ mov [scroll_bar_data_vertical.ar_offset],eax
+ mov [scroll_bar_data_horizontal.ar_offset],eax
+ ret
+;---------------------------------------------------------------------
+no_scaling:
+ mov eax,scaling_mode
+ cmp [eax],dword 100
+ je still
+.1:
+ mov [eax],dword 100
+ mov [zoom_factors],dword zoom_factors.100
+ mov eax,[eax]
+ jmp zoom_plus.2
+
+; call calculate_arrows_offset
+; call draw_zoom_factors
+; jmp red
+;---------------------------------------------------------------------
+scaling:
+ mov eax,[soi]
+ test eax,eax
+ jz still
+ mov eax,scaling_mode
+ xor ebx,ebx
+ cmp [eax],ebx ;dword 0
+ je still
+ mov [eax],ebx ;dword 0
+ mov [zoom_factors],dword zoom_factors.1
+ call .1
+ call draw_zoom_factors
+ jmp still
+;---------------------------
+.compens_x:
+ call .get_x_y
+ xor ecx,ecx
+ mov cx,[wa_high_1]
+ imul eax,ecx
+ xor edx,edx
+ div ebx
+ ret
+;---------------------------
+.compens_y:
+ call .get_x_y
+ xchg eax,ebx
+ xor ecx,ecx
+ mov cx,[wa_width_1]
+ imul eax,ecx
+ xor edx,edx
+ div ebx
+ ret
+;---------------------------
+.get_x_y:
+ mov ebx,[raw_pointer]
+ mov eax,[ebx+4]
+ mov ebx,[ebx+8]
+ ret
+;---------------------------
+.fill_for_L_R:
+ cmp [no_fill],1
+ je @f
+; xor eax,eax
+; mov [no_fill],al
+; ret
+;@@:
+ pusha
+ mov ebx,[image_start_coordinates]
+ mov ecx,ebx
+ shl ecx,16
+ mov bx,ax
+ mov cx,[wa_high_1]
+ mcall 13,,,[fill_color] ;0xffffff
+ mov ax,bx
+ ror ebx,16
+ add bx,ax
+ add bx,[wa_width_2]
+ mov ax,[wa_width_1]
+; add ax,5
+ sub ax,bx
+ rol ebx,16
+ mov bx,ax
+ mcall 13,,,[fill_color] ;0xffffff
+ popa
+@@:
+ ret
+;---------------------------
+.fill_for_U_D:
+ cmp [no_fill],1
+ je @f
+; xor eax,eax
+; mov [no_fill],al
+; ret
+;@@:
+ pusha
+ mov ebx,[image_start_coordinates]
+ mov ecx,ebx
+ shl ecx,16
+ mov cx,ax
+ mov bx,[wa_width_1]
+ mcall 13,,,[fill_color] ;0xffffff
+ mov ax,cx
+ ror ecx,16
+ add cx,ax
+ add cx,[wa_high_2]
+ mov ax,[wa_high_1]
+ add ax,28 ;50
+ sub ax,cx
+ rol ecx,16
+ mov cx,ax
+ mcall 13,,,[fill_color] ;0xffffff
+ popa
+@@:
+ ret
+;---------------------------
+.1:
+ call .get_x_y
+ cmp eax,ebx
+ jb .y
+;---------------------------
+.x:
+ call .compens_y
+ cmp ax,[wa_high_1]
+ jbe @f
+ call .compens_x
+ mov [wa_width_2],ax
+ jmp .4
+@@:
+ mov [wa_high_2],ax
+ jmp .4
+;---------------------------
+.y:
+ call .compens_x
+ cmp ax,[wa_width_1]
+ jbe @f
+ call .compens_y
+ mov [wa_high_2],ax
+ jmp .4
+@@:
+ mov [wa_width_2],ax
+;---------------------------
+.4:
+ mov bx,[wa_width_2]
+ shl ebx,16
+ mov bx,[wa_high_2]
+
+ xor ecx,ecx
+.5:
+
+; mov eax,ebx
+; and eax,0xffff
+; mov [test1],eax
+
+; mov eax,ebx
+; shr eax,16
+; mov [test2],eax
+
+; mov eax,ecx
+; and eax,0xffff
+; mov [test3],eax
+
+; mov eax,ecx
+; shr eax,16
+; mov [test4],eax
+
+ mov eax,image_file
+ mov edx,[scaling_mode]
+ movzx esi,byte [filtering_flag]
+ mov edi,[background_color]
+
+; pusha
+; mcall 26,9
+; mov [test1],eax
+; popa
+
+; call [plugin_scaling]
+
+ call [Scaling_Start]
+
+; pusha
+; mcall 26,9
+; mov ebx,[test1]
+; sub eax,ebx
+; cmp [test2],0
+; je @f
+; add eax,[test2]
+; shr eax,1
+; cmp eax,[test3]
+; jbe @f
+; mov [test3],eax
+;@@:
+; mov [test2],eax
+; popa
+
+ mov ecx,ebx
+
+ mov edx,[image_start_coordinates]
+
+ mov eax,edx
+ shl eax,16
+ mov ax,cx
+ mov [scroll_bar_data_vertical.y],eax
+
+ mov eax,edx
+ mov ebx,ecx
+ shr ebx,16
+ mov ax,bx
+ mov [scroll_bar_data_horizontal.x],eax
+
+; call correct_cur_area
+
+; movzx eax,[wa_width_1]
+; mov [test1],eax
+; movzx eax,[wa_width_2]
+; mov [test2],eax
+
+; movzx eax,[wa_high_1]
+; mov [test3],eax
+; movzx eax,[wa_high_2]
+; mov [test4],eax
+
+ xor eax,eax
+ mov ax,[wa_width_1]
+ sub ax,[wa_width_2]
+ shr ax,1
+ test ax,ax
+ jz @f
+ shl eax,16
+ add edx,eax
+ shr eax,16
+ call .fill_for_L_R
+@@:
+ mov ax,[wa_high_1]
+ sub ax,[wa_high_2]
+ shr ax,1
+ test ax,ax
+ jz @f
+ add edx,eax
+ call .fill_for_U_D
+@@:
+ mov esi,[img_resolution]
+ cmp [img_resolution_2],15
+ jne @f
+ mov esi,15
+@@:
+ mov eax,[raw_pointer]
+ mov edi,[eax+20]
+ add edi,eax
+; mov edi,[img_palette]
+ xor ebp,ebp
+
+ mov ebx,[raw_pointer_2]
+
+ mov eax,ecx
+ test ax,ax
+ jz .no_draw ;@f
+ shr eax,16
+ test eax,eax
+ jz .no_draw ;@f
+
+ cmp [filtering_flag],0
+ je @f
+ cmp esi,8
+ jne @f
+ mov esi,24
+@@:
+ mcall 65
+.no_draw:
+; mov eax,ecx
+; shr eax,16
+; mov [test1],eax
+;
+; mov eax,ecx
+; and eax,0xffff
+; mov [test2],eax
+;
+; mov eax,edx
+; shr eax,16
+; mov [test3],eax
+;
+; mov eax,edx
+; and eax,0xffff
+; mov [test4],eax
+
+ push ebx
+ call draw_file_name_to_work_area
+ pop ebx
+ mov ecx,ebx ;[raw_pointer_2]
+ mcall 68,13
+
+
+ xor eax,eax
+ mov ax,[wa_width_2]
+; imul eax,100
+; = * 100
+ shl eax,2 ; 4
+ lea eax,[eax+eax*4] ; 5
+ lea eax,[eax+eax*4] ; 5
+ mov ebx,[img_width]
+ test ebx,ebx
+ jnz @f
+ inc ebx
+@@:
+ xor edx,edx
+ div ebx
+ shl edx,1
+ cmp ebx,edx
+ jb @f
+ inc eax
+@@:
+ mov [zoom_auto_factor],eax
+
+ ret
+;---------------------------------------------------------------------
+calculation_next_value_plus:
+ mov ebx,[zoom_auto_factor]
+ mov ecx,zoom_factors.min
+ sub ecx,4
+@@:
+ add ecx,4
+ cmp ecx,dword zoom_factors.max
+ jae .max
+ mov eax,[ecx]
+ cmp eax,ebx
+ jb @r
+@@:
+ mov eax,zoom_factors
+ mov [eax],ecx
+; jmp zoom_plus.1
+ ret
+.max:
+ mov ecx,dword zoom_factors.max
+ jmp @r
+;---------------------------------------------------------------------
+calculation_next_value_minus:
+ mov ebx,[zoom_auto_factor]
+ mov ecx,zoom_factors.max
+ add ecx,4
+@@:
+ sub ecx,4
+ cmp ecx,dword zoom_factors.min
+ jbe .min
+ mov eax,[ecx]
+ cmp eax,ebx
+ ja @r
+@@:
+ mov eax,zoom_factors
+ mov [eax],ecx
+; jmp zoom_plus.1
+ ret
+.min:
+ mov ecx,dword zoom_factors.min
+ jmp @r
+;---------------------------------------------------------------------
+proc_position_correct:
+ mov [position_coorect],1
+ mov eax,[scroll_bar_data_vertical.max_area]
+ xor ebx,ebx
+ mov bx,[wa_high_1]
+ shr ebx,1
+ shl eax,8
+ add ebx,[scroll_bar_data_vertical.position]
+ test ebx,ebx
+ jnz @f
+ inc ebx
+@@:
+ xor edx,edx
+ div ebx
+ mov [vertical_position_coorect],eax
+
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ xor ebx,ebx
+ mov bx,[wa_width_1]
+ shr ebx,1
+ shl eax,8
+ add ebx,[scroll_bar_data_horizontal.position]
+ test ebx,ebx
+ jnz @f
+ inc ebx
+@@:
+ xor edx,edx
+ div ebx
+ mov [horizontal_position_coorect],eax
+ ret
+;---------------------------------------------------------------------
+zoom_plus:
+; cmp [scaling_mode],dword 0
+ mov eax,[scaling_mode]
+ test eax,eax
+; jz no_scaling.1
+; jz calculation_next_value_plus
+ jnz @f
+ call calculation_next_value_plus
+ jmp .1
+@@:
+; jne @f
+; mov [scaling_mode],dword 100
+; mov [zoom_factors],dword zoom_factors.100
+; call draw_zoom_factors
+; jmp red
+;@@:
+ mov eax,zoom_factors
+ cmp [eax],dword zoom_factors.max
+ jae still
+ add [eax],dword 4
+.1:
+ mov eax,[eax]
+ mov eax,[eax]
+.2:
+ mov [scaling_mode],eax
+
+ mov [correct_scrollbar_100_flag],1
+ call calculate_arrows_offset
+
+ call proc_position_correct
+
+ call drawimage
+
+ call set_draw_scrollbar_all
+ call draw_scrollbars
+ call set_nodraw_scrollbar_all
+
+ call draw_zoom_factors
+ jmp still
+
+zoom_all:
+;******************************
+ mov eax,wa_width_1
+ mov eax,[eax]
+ push eax
+ mov eax,wa_high_1
+ mov eax,[eax]
+ push eax
+;******************************
+ cmp [position_coorect],0
+ je .correct_end
+ mov [position_coorect],0
+ mov eax,[scroll_bar_data_vertical.max_area]
+; xor ebx,ebx
+; mov bx,[wa_high_1]
+; shr ebx,1
+; add eax,ebx ;[scroll_bar_data_vertical.cur_area]
+ shl eax,8
+ mov ebx,[vertical_position_coorect]
+ test ebx,ebx
+ jnz @f
+ inc ebx
+@@:
+ xor edx,edx
+ div ebx
+; shr eax,8
+ xor ebx,ebx
+ mov bx,[wa_high_1]
+ shr ebx,1
+ cmp eax,ebx
+ jae @f
+ xor eax,eax
+ jmp .position_vertical_correct
+@@:
+ sub eax,ebx
+.position_vertical_correct:
+ mov [scroll_bar_data_vertical.position],eax
+
+ mov eax,[scroll_bar_data_horizontal.max_area]
+; xor ebx,ebx
+; mov bx,[wa_width_1]
+; shr ebx,1
+; add eax,ebx ;[scroll_bar_data_horizontal.cur_area]
+ shl eax,8
+ mov ebx,[horizontal_position_coorect]
+ test ebx,ebx
+ jnz @f
+ inc ebx
+@@:
+ xor edx,edx
+ div ebx
+; shr eax,8
+ xor ebx,ebx
+ mov bx,[wa_width_1]
+ shr ebx,1
+ cmp eax,ebx
+ jae @f
+ xor eax,eax
+ jmp .position_horizontal_correct
+@@:
+ sub eax,ebx
+.position_horizontal_correct:
+ mov [scroll_bar_data_horizontal.position],eax
+
+.correct_end:
+
+;****************************************************************************
+; Vertical SCROLLBAR
+; At a case of resizing of the window
+; Check the position of a runner has crossed a limit
+;****************************************************************************
+ mov eax,[scroll_bar_data_vertical.max_area]
+ xor ebx,ebx
+ mov bx,[wa_high_1]
+ cmp eax,ebx
+ ja @f
+ xor eax,eax
+ jmp .p_5
+@@:
+ sub eax,ebx ;[scroll_bar_data_vertical.cur_area]
+ cmp eax,[scroll_bar_data_vertical.position]
+ jae @f
+.p_5:
+ mov [scroll_bar_data_vertical.position],eax
+@@:
+;****************************************************************************
+; Horizontal SCROLLBAR
+; At a case of resizing of the window
+; Check the position of a runner has crossed a limit
+;****************************************************************************
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ xor ebx,ebx
+ mov bx,[wa_width_1]
+ cmp eax,ebx
+ ja @f
+ xor eax,eax
+ jmp .p_6
+@@:
+ sub eax,ebx ;[scroll_bar_data_horizontal.cur_area]
+ cmp eax,[scroll_bar_data_horizontal.position]
+ jae @f
+.p_6:
+ mov [scroll_bar_data_horizontal.position],eax
+@@:
+;****************************************************************************
+
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ mov ebx,[scroll_bar_data_vertical.max_area]
+
+
+ sub eax,[scroll_bar_data_horizontal.position] ;100
+ sub ebx,[scroll_bar_data_vertical.position] ;100
+
+ xor ecx,ecx
+ mov cx,word [wa_width_1]
+ cmp eax,ecx
+ jbe @f
+ xor eax,eax
+ mov ax,[wa_width_1]
+@@:
+ mov [wa_width_2],ax
+ mov ecx,eax
+ shl ecx,16
+ xchg eax,ebx
+
+ xor edx,edx
+ mov dx,word [wa_high_1]
+ cmp eax,edx
+ jbe @f
+ xor eax,eax
+ mov ax,[wa_high_1]
+@@:
+ mov [wa_high_2],ax
+ mov cx,ax
+
+ call correct_cur_area
+
+ mov ebx,ecx
+
+ push eax
+ mov eax,[scroll_bar_data_vertical.max_area]
+ cmp eax,[scroll_bar_data_vertical.cur_area]
+ jbe .horizontal ;@f
+ mov ax,[wa_width_1]
+ sub ax,[scroll_bar_data_vertical.size_x]
+ mov [wa_width_1],ax
+ cmp ax,[wa_width_2]
+ jae .horizontal
+ mov [wa_width_2],ax
+.horizontal:
+ mov eax,[scroll_bar_data_horizontal.max_area]
+ cmp eax,[scroll_bar_data_horizontal.cur_area]
+ jbe .finish ;@f
+ mov ax,[wa_high_1]
+ sub ax,[scroll_bar_data_horizontal.size_y]
+ mov [wa_high_1],ax
+ cmp ax,[wa_high_2]
+ jae .finish
+ mov [wa_high_2],ax
+.finish: ;@@:
+ pop eax
+
+ mov cx,[wa_width_2]
+ shl ecx,16
+ mov cx,[wa_high_2]
+
+ call correct_cur_area
+
+ mov ebx,ecx
+
+ mov eax,[scroll_bar_data_horizontal.position]
+
+; imul eax,100
+; = * 100
+ shl eax,2 ; 4
+ lea eax,[eax+eax*4] ; 5
+ lea eax,[eax+eax*4] ; 5
+ push ebx
+ mov ebx,[scaling_mode]
+ xor edx,edx
+ div ebx
+
+; shl edx,1
+; cmp edx,ebx
+; jb @f
+; inc eax
+;@@:
+
+ pop ebx
+
+ mov ecx,eax
+ shl ecx,16
+
+ mov eax,[scroll_bar_data_vertical.position]
+
+; imul eax,100
+; = * 100
+ shl eax,2 ; 4
+ lea eax,[eax+eax*4] ; 5
+ lea eax,[eax+eax*4] ; 5
+ push ebx
+ mov ebx,[scaling_mode]
+ xor edx,edx
+ div ebx
+
+; shl edx,1
+; cmp edx,ebx
+; jb @f
+; inc eax
+;@@:
+
+ pop ebx
+
+ mov cx,ax
+
+ call scaling.5
+;******************************
+ pop eax
+ mov ebx,wa_high_1
+ mov [ebx],eax
+
+ pop eax
+ mov ebx,wa_width_1
+ mov [ebx],eax
+;******************************
+
+ ret
+;---------------------------------------------------------------------
+zoom_minus:
+; cmp [scaling_mode],dword 0
+ mov eax,[scaling_mode]
+ test eax,eax
+; jz no_scaling.1
+; jz calculation_next_value_minus
+ jnz @f
+ call calculation_next_value_minus
+ jmp zoom_plus.1
+@@:
+; je no_scaling.1
+; jne @f
+; mov [scaling_mode],dword 100
+; mov [zoom_factors],dword zoom_factors.100
+; call draw_zoom_factors
+; jmp red
+;@@:
+ mov eax,zoom_factors
+ cmp [eax],dword zoom_factors.min
+ jbe still
+ sub [eax],dword 4
+ jmp zoom_plus.1
+;---------------------------------------------------------------------
\ No newline at end of file
diff --git a/programs/media/zsea/zoom_values.txt b/programs/media/zsea/zoom_values.txt
new file mode 100644
index 0000000000..59e624658d
--- /dev/null
+++ b/programs/media/zsea/zoom_values.txt
@@ -0,0 +1,124 @@
+ACD See
+5
+7
+10
+15
+20
+30
+50
+70
+100
+150
+200
+300
+500
+700
+1000
+2000
+3000
+5000
+
+Fast Stone
+2
+5
+10
+15
+20
+30
+40
+50
+60
+100
+125
+150
+175
+200
+300
+500
+700
+1000
+2000
+3000
+5000
+
+Photoshop
+0,2
+0,3
+0,4
+0,5
+0,7
+1
+1,5
+2
+3
+4
+5
+6,25
+8,33
+12,5
+16,67
+25
+33,33
+50
+66,67
+100
+200
+300
+400
+500
+600
+700
+800
+1200
+1600
+
+
+zSea
+1
+2
+3
+ 4
+5
+7
+10
+ 17
+25
+ 37
+50
+ 62
+75
+ 87
+100
+ 112
+125
+150
+175
+200
+ 225
+250
+ 275
+300
+ 350
+400
+ 450
+500
+ 600
+700
+ 800
+ 900
+1000
+ 1100
+1250 1200
+ 1300
+ 1400
+1500
+ 1750
+2000
+ 2250
+2500
+ 2750
+3000
+ 3500
+ 4000
+ 4500
+5000