Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 3116 → Rev 3099

/programs/media/kiv/trunk/kiv.asm
6,11 → 6,12
 
;-----------------------------------------------------------------------------
 
include '../../../config.inc'
FALSE = 0
TRUE = 1
include '../../../config.inc' ;for nightbuild
include '../../../proc32.inc'
include '../../../macros.inc'
include '../../../dll.inc'
;include '../../../debug.inc'
include 'dll.inc'
 
include '../../../develop/libraries/libs-dev/libio/libio.inc'
include '../../../develop/libraries/libs-dev/libimg/libimg.inc'
52,10 → 53,6
mov [next_key], eax
invoke ini_get_shortcut, inifilename, aShortcuts, aPrev, -1, prev_mod
mov [prev_key], eax
invoke ini_get_shortcut, inifilename, aShortcuts, aSlide, -1, slide_mod
mov [slide_key], eax
invoke ini_get_shortcut, inifilename, aShortcuts, aTglbar, -1, tglbar_mod
mov [tglbar_key], eax
mcall 66, 1, 1 ; set kbd mode to scancodes
 
cmp byte [@PARAMS], 0
143,30 → 140,7
jz .next
add edx, prev_mod - next_mod
call check_shortcut
jz .prev
add edx, slide_mod - prev_mod
call check_shortcut
jz .slide
add edx, tglbar_mod - slide_mod
call check_shortcut
jz .tglbar
cmp cl, 1 ; Esc
jz .esc
jmp keyloop
.esc:
test byte [bSlideShow], 1
jnz .slide
jmp keyloop
.tglbar:
mov byte [bTglbar], 1
test byte[bSlideShow], 1
jnz @f
xor [toolbar_height], 31
@@:
jmp keyloop
.slide:
call slide_show
jmp keyloop
jnz keyloop
.prev:
dec esi
jmp keyloop
175,12 → 149,7
jmp keyloop
keyloopdone:
test esi, esi
jnz next_or_prev_handler
test byte [bSlideShow], 2
jnz red
test byte [bTglbar], 1
jnz red
jmp still
jz still
next_or_prev_handler:
call next_or_prev_image
jmp red
289,14 → 258,7
jmp still
 
@@:
cmp eax, 'sld'
jne @f
 
call slide_show
jmp red
 
@@:
 
or esi, -1
cmp eax, 'bck'
jz next_or_prev_handler
334,6 → 296,10
inc eax
jz .error
 
; img.decode checks for img.is_img
; invoke img.is_img, [img_data], [img_data_len]
; or eax, eax
; jz exit
invoke img.decode, [img_data], [img_data_len], 0
or eax, eax
jz .error
385,11 → 351,10
.not_in_row:
mov [draw_width], edx
add edx, 19
cmp edx, 50 + 25*numimages
cmp edx, 40 + 25*9
jae @f
mov edx, 50 + 25*numimages
mov edx, 40 + 25*9
@@:
; dec edx
mov [wnd_width], edx
mov esi, [eax + Image.Height]
test [eax + Image.Flags], Image.IsAnimated
405,16 → 370,10
@@: pop eax
.max_equals_first:
mov [draw_height], esi
add esi, [toolbar_height]
add esi, [image_padding]
add esi, [image_padding]
add esi, 5 ; window bottom frame height
dec esi
add esi, 44
mov [wnd_height], esi
popf
jz .no_resize
test [wnd_style], 1 SHL 25
jz .no_resize
mcall 48, 4
add esi, eax
mcall 67,-1,-1
440,23 → 399,6
mcall 15, 3
ret
 
slide_show:
or byte [bSlideShow], 2
xor byte [bSlideShow], 1
btc dword [wnd_style], 25
jc @f
mov eax, [toolbar_height_old]
mov [toolbar_height], eax
mov [image_padding], 5
jmp .toolbar_height_done
@@:
mov eax, [toolbar_height]
mov [toolbar_height_old], eax
mov [toolbar_height], 0
mov [image_padding], 0
.toolbar_height_done:
ret
 
; seek to ESI image files
; esi>0 means next file, esi<0 - prev file
next_or_prev_image:
632,8 → 574,7
jz .copy
cmp ecx, 'cur'
jz .copy
cmp ecx, 'tga'
jz .copy
; dunkaist [
cmp ecx, 'pcx'
jz .copy
cmp ecx, 'xcf'
650,6 → 591,7
jz @f
cmp ecx, 'wbmp'
jz @f
; dunkaist ]
cmp ecx, 'jpeg'
jz @f
cmp ecx, 'jpeG'
736,57 → 678,21
ret
 
draw_window:
btr word [bSlideShow], 1 ; mode changed
jc .mode_changed
test byte [bTglbar], 1
jz .mode_not_changed
.mode_changed:
test [wnd_style], 1 SHL 25
jz .mode_slide
mov [bg_color], 0x00ffffff
mov eax, [image]
cmp eax, eax
call update_image_sizes
mcall 48, 4
mov esi, [wnd_height]
add esi, eax
test byte [bTglbar], 1
jz @f
mcall 67, -1, -1, [wnd_width],
jmp .mode_not_changed
@@:
mcall 67, [wnd_x], [wnd_y], [wnd_width],
jmp .mode_not_changed
.mode_slide:
mov [bg_color], 0x00000000
mov eax, [procinfo.box.left]
mov [wnd_x], eax
mov eax, [procinfo.box.top]
mov [wnd_y], eax
mcall 14
mov edx, eax
shr edx, 16
movzx eax, ax
mov esi, eax
mcall 67, 0, 0, ,
jmp .posok.slide_show
 
.mode_not_changed:
cmp [bFirstDraw], 0
jz .posok
or ecx, -1
mcall 9, procinfo
 
test byte [procinfo.wnd_state], 0x04
jnz .posok
cmp dword [ebx + 66], 0
jle .posok
 
mov edx, ecx
mov esi, ecx
cmp dword [procinfo.box.width], 50 + 25 * numimages
cmp dword [ebx + 42], 40 + 25 * 9
jae @f
mov edx, 50 + 25 * numimages
mov edx, 40 + 25 * 9
@@:
cmp dword [procinfo.box.height], 70
cmp dword [ebx + 46], 70
jae @f
mov esi, 70
@@:
799,66 → 705,28
@@:
 
.posok:
test [wnd_style], 1 SHL 25
jz .posok.slide_show
mcall 12, 1
mcall 48, 4
mov ebp, eax ; save skin height
add eax, [wnd_height]
mov ebx, [wnd_x]
shl ebx, 16
__mov ebx, 100, 0
add ebx, [wnd_width]
mov ecx, [wnd_y]
shl ecx, 16
add ecx, eax
mcall 0, , , [wnd_style], 0, real_header
jmp .posok.common
.posok.slide_show:
mcall 12, 1
mcall 14
mov ebx, eax
shr ebx, 16
movzx eax, ax
mov ecx, eax
mcall 0, , , [wnd_style], 0, real_header
.posok.common:
lea ecx, [100*65536 + eax]
mcall 0, , , 0x73FFFFFF, 0, real_header
 
mcall 9, procinfo, -1
mov eax, [procinfo.client_box.width]
sub eax, [image_padding]
sub eax, [image_padding]
sub eax, [draw_width]
sar eax, 1
test eax, eax
jns @f
mov eax, 0
@@:
add eax, [image_padding]
mov [draw_x], eax
mov eax, [procinfo.client_box.height]
sub eax, [toolbar_height]
sub eax, [image_padding]
sub eax, [image_padding]
sub eax, [draw_height]
sar eax, 1
test eax, eax
jns @f
mov eax, 0
@@:
add eax, [toolbar_height]
add eax, [image_padding]
mov [draw_y], eax
mov [bFirstDraw], 1
cmp dword [procinfo.client_box.height], 0
cmp dword [ebx + 66], 0
jle .nodraw
mov ebx, [procinfo.client_box.width]
mov ebx, [ebx + 62]
inc ebx
mov ecx, [draw_y]
mcall 13, , , [bg_color]
mov ecx, [procinfo.client_box.height]
mcall 13, , <0, 35>, 0xFFFFFF
mov ecx, [procinfo + 66]
inc ecx
mov esi, [cur_frame]
mov esi, [esi + Image.Height]
add esi, [draw_y]
; mov esi, [draw_height] ; we can not use [draw_height] here because for *.ico files containing several frames
mov esi, [image] ; with different size window height should depend on maximum frame height, not the first one
mov esi, [esi+Image.Height] ;
add esi, 35
sub ecx, esi
jbe @f
push esi
869,16 → 737,14
xor ecx, ecx
@@:
add ecx, esi
mov ebx, [draw_y]
sub ecx, ebx
shl ebx, 16
add ecx, ebx
mov ebx, [draw_x]
add ecx, 35*10000h - 35
__mov ebx, 0, 5
mcall
mov esi, [cur_frame]
mov esi, [esi + Image.Width]
; mov esi, [draw_width] ; we can not use [draw_width] here because for *.ico files containing several frames
mov esi, [image] ; with different size window width should depend on the sum of width of all frames
mov esi, [esi + Image.Width] ;
add esi, ebx
mov ebx, [procinfo.client_box.width]
mov ebx, [procinfo+62]
inc ebx
sub ebx, esi
jbe @f
887,17 → 753,12
mcall
@@:
 
test [wnd_style], 1 SHL 25
jz .slide_show_mode
mov byte [bTglbar], 0
cmp byte [toolbar_height], 0
je .decorations_done
mov ebx, [procinfo.client_box.width]
mov ebx, [procinfo + 62]
push ebx
mcall 38, , <30, 30>, 0x007F7F7F
mcall , <5 + 25 * 1, 5 + 25 * 1>, <0, 30>
mcall , <10 + 25 * 3, 10 + 25 * 3>
mcall , <15 + 25 * 5, 15 + 25 * 5>
mcall , <15 + 25 * 4, 15 + 25 * 4>
pop ebx
sub ebx, 25 * 5 + 10
push ebx
908,7 → 769,6
mcall , <10 + 25 * 1, 20>, , 'bck'+40000000h
mcall , <10 + 25 * 2, 20>, , 'fwd'+40000000h
mcall , <15 + 25 * 3, 20>, , 'bgr'+40000000h
mcall , <15 + 25 * 4, 20>, , 'sld'+40000000h
pop ebx
add ebx, 5
shl ebx, 16
929,8 → 789,7
mcall , buttons+backbtn*20, , <10 + 25 * 1, 5>
mcall , buttons+forwardbtn*20, , <10 + 25 * 2, 5>
mcall , buttons+bgrbtn*20, , <15 + 25 * 3, 5>
mcall , buttons+slidebtn*20, , <15 + 25 * 4, 5>
mov edx, [procinfo.client_box.width]
mov edx, [procinfo + 62]
sub edx, 25 * 5 + 4
shl edx, 16
mov dl, 5
943,11 → 802,7
mcall , buttons+rotccwbtn*20
add edx, 25 * 65536
mcall , buttons+rot180btn*20
jmp .decorations_done
 
.slide_show_mode:
 
.decorations_done:
call draw_cur_frame
 
.nodraw:
958,17 → 813,14
draw_cur_frame:
push 0 ; ypos
push 0 ; xpos
mov eax, [procinfo.client_box.height]
sub eax, [toolbar_height]
sub eax, [image_padding]
inc eax
mov eax, [procinfo+66]
sub eax, 34
push eax ; max height
mov eax, [procinfo.client_box.width]
sub eax, [image_padding]
inc eax
mov eax, [procinfo+62]
sub eax, 4
push eax ; max width
push [draw_y]
push [draw_x]
push 35 ; y
push 5 ; x
push [cur_frame]
call [img.draw]
mov eax, [image]
979,11 → 831,11
.done:
ret
.additional_frames:
mov ebx, [procinfo.client_box.width]
sub ebx, [image_padding]
inc ebx
mov ebx, [procinfo+62]
sub ebx, 4
jbe .done
mov esi, [draw_x]
push 5
pop esi
.afloop:
sub ebx, [eax + Image.Width]
jbe .done
995,14 → 847,11
inc esi
push 0 ; ypos
push 0 ; xpos
mov ecx, [procinfo.client_box.height]
sub ecx, [toolbar_height]
sub ecx, [image_padding]
inc ecx
; inc ebx
mov ecx, [procinfo+66]
sub ecx, 34
push ecx ; max height
push ebx ; max width
push [draw_y] ; y
push 35 ; y
push esi ; x
push eax ; image
call [img.draw]
1011,7 → 860,31
jnz .afloop
ret
 
; void* __stdcall mem.Alloc(unsigned size);
mem.Alloc:
push ebx ecx
mov ecx, [esp+12]
mcall 68, 12
pop ecx ebx
ret 4
 
; void* __stdcall mem.ReAlloc(void* mptr, unsigned size);
mem.ReAlloc:
push ebx ecx edx
mov edx, [esp+16]
mov ecx, [esp+20]
mcall 68, 20
pop edx ecx ebx
ret 8
 
; void __stdcall mem.Free(void* mptr);
mem.Free:
push ebx ecx
mov ecx, [esp+12]
mcall 68, 13
pop ecx ebx
ret 4
 
check_shortcut:
; in: cl = scancode (from sysfn 2),
; eax = state of modifiers (from sysfn 66.3),
1100,12 → 973,6
;-----------------------------------------------------------------------------
 
s_header db ' - Kolibri Image Viewer', 0
wnd_style dd 0x73FFFFFF
wnd_x dd 100
wnd_y dd 100
image_padding dd 5
toolbar_height dd 31
bg_color dd 0x00ffffff
 
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
1156,8 → 1023,6
OpenDialog_Start,'OpenDialog_start'
 
bFirstDraw db 0
bSlideShow db 0
bTglbar db 0
;-----------------------------------------------------------------------------
 
virtual at 0
1164,7 → 1029,7
file 'kivicons.bmp':0xA,4
load offbits dword from 0
end virtual
numimages = 10
numimages = 9
openbtn = 0
backbtn = 1
forwardbtn = 2
1174,7 → 1039,6
rotcwbtn = 6
rotccwbtn = 7
rot180btn = 8
slidebtn = 9
 
palette:
file 'kivicons.bmp':0x36,offbits-0x36
1195,8 → 1059,6
aShortcuts db 'Shortcuts',0
aNext db 'Next',0
aPrev db 'Prev',0
aSlide db 'SlideShow',0
aTglbar db 'ToggleBar',0
 
align 4
check_modifier_table:
1251,7 → 1113,7
db 'PNG',0
db 'ICO',0
db 'CUR',0
db 'TGA',0
; dunkaist [
db 'PCX',0
db 'XCF',0
db 'PBM',0
1260,6 → 1122,7
db 'TIF',0
db 'TIFF',0
db 'WBMP',0
; dunkaist ]
.end:
db 0
 
1281,10 → 1144,8
img_data_len dd ?
fh dd ?
image dd ?
wnd_width dd 100
wnd_height dd 100
draw_x dd ?
draw_y dd ?
wnd_width dd ?
wnd_height dd ?
draw_width dd ?
draw_height dd ?
last_name_component dd ?
1296,14 → 1157,8
next_key dd ?
prev_mod dd ?
prev_key dd ?
slide_mod dd ?
slide_key dd ?
tglbar_mod dd ?
tglbar_key dd ?
 
toolbar_height_old rd 1
 
procinfo process_information
procinfo: rb 1024
path: rb 4096 ;1024+16
real_header rb 256
@PARAMS rb 4096 ;512
/programs/media/kiv/trunk/kiv.ini
1,5 → 1,3
[Shortcuts]
Next=PgDn
Prev=PgUp
SlideShow=f
ToggleBar=Tab
/programs/media/kiv/trunk/dll.inc
0,0 → 1,99
 
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
push eax
mov eax, [eax]
cmp dword [eax], 'lib_'
pop eax
jnz @f
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
mov ebx,mem.Free
mov ecx,mem.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
/programs/media/kiv/trunk/kivicons.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream