34,13 → 34,6 |
cmp word [@PARAMS], '\S' |
jz set_bgr |
|
; initialize keyboard handling |
invoke ini_get_shortcut, inifilename, aShortcuts, aNext, -1, next_mod |
mov [next_key], eax |
invoke ini_get_shortcut, inifilename, aShortcuts, aPrev, -1, prev_mod |
mov [prev_key], eax |
mcall 66, 1, 1 ; set kbd mode to scancodes |
|
cmp byte [@PARAMS], 0 |
jnz params_given |
|
64,14 → 57,9 |
|
params_given: |
|
mov esi, @PARAMS |
push esi |
call find_last_name_component |
|
pop eax |
mov eax, @PARAMS |
call load_image |
jc exit |
call generate_header |
|
;----------------------------------------------------------------------------- |
|
104,32 → 92,8 |
jnz button |
|
key: |
xor esi, esi |
keyloop: |
mcall 2 |
test al, al |
jnz keyloopdone |
shr eax, 8 |
mov ecx, eax |
mcall 66, 3 |
mov edx, next_mod |
call check_shortcut |
jz .next |
add edx, prev_mod - next_mod |
call check_shortcut |
jnz keyloop |
.prev: |
dec esi |
jmp keyloop |
.next: |
inc esi |
jmp keyloop |
keyloopdone: |
test esi, esi |
jz still |
next_or_prev_handler: |
call next_or_prev_image |
jmp red |
jmp still |
|
red_update_frame: |
mov eax, [cur_frame] |
222,12 → 186,16 |
|
@@: |
|
or esi, -1 |
cmp eax, 'bck' |
jz next_or_prev_handler |
neg esi |
jnz @f |
call prev_image |
jmp red |
@@: |
cmp eax, 'fwd' |
jz next_or_prev_handler |
jnz @f |
call next_image |
jmp red |
@@: |
|
cmp eax, 1 |
jne still |
339,40 → 307,28 |
mcall 15, 3 |
ret |
|
; seek to ESI image files |
; esi>0 means next file, esi<0 - prev file |
next_or_prev_image: |
push esi |
prev_image: |
call load_directory |
pop esi |
cmp [directory_ptr], 0 |
jz .ret |
mov ebx, [directory_ptr] |
test ebx, ebx |
jz .ret |
cmp dword[ebx+4], 0 |
jz .ret |
mov eax, [cur_file_idx] |
cmp eax, -1 |
jnz @f |
test esi, esi |
jns @f |
mov eax, [ebx+4] |
@@: |
push [image] |
add eax, esi |
@@: |
test eax, eax |
.scanloop: |
dec eax |
jns @f |
add eax, [ebx+4] |
jmp @b |
mov eax, [ebx+4] |
dec eax |
cmp [cur_file_idx], -1 |
jz .notfound |
@@: |
cmp eax, [ebx+4] |
jb @f |
sub eax, [ebx+4] |
jmp @b |
@@: |
push eax |
.scanloop: |
push eax ebx esi |
cmp eax, [cur_file_idx] |
jz .notfound |
push eax ebx |
imul esi, eax, 304 |
add esi, [directory_ptr] |
add esi, 32 + 40 |
407,36 → 363,76 |
jnz @b |
mov byte [esi], 0 |
popf |
pop esi ebx eax |
jnc .loadedok |
test esi, esi |
js .try_prev |
.try_next: |
pop ebx eax |
jc .scanloop |
mov [cur_file_idx], eax |
invoke img.destroy |
.ret: |
ret |
.notfound: |
pop [image] |
call init_frame |
ret |
|
next_image: |
call load_directory |
cmp [directory_ptr], 0 |
jz .ret |
mov ebx, [directory_ptr] |
mov eax, [cur_file_idx] |
push [image] |
.scanloop: |
inc eax |
cmp eax, [ebx+4] |
jb @f |
xor eax, eax |
cmp [cur_file_idx], -1 |
jz .notfound |
@@: |
.try_common: |
cmp eax, [esp] |
cmp eax, [cur_file_idx] |
jz .notfound |
jmp .scanloop |
.try_prev: |
dec eax |
jns @f |
mov eax, [ebx+4] |
dec eax |
push eax ebx |
imul esi, eax, 304 |
add esi, [directory_ptr] |
add esi, 32 + 40 |
mov edi, curdir |
@@: |
jmp .try_common |
.loadedok: |
inc edi |
cmp byte [edi-1], 0 |
jnz @b |
mov byte [edi-1], '/' |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
mov eax, curdir |
call load_image |
pushf |
mov esi, curdir |
push esi |
mov edi, @PARAMS |
mov ecx, 512/4 |
rep movsd |
mov byte [edi-1], 0 |
pop esi |
@@: |
lodsb |
test al, al |
jnz @b |
@@: |
dec esi |
cmp byte [esi], '/' |
jnz @b |
mov byte [esi], 0 |
popf |
pop ebx eax |
jc .scanloop |
mov [cur_file_idx], eax |
pop eax |
invoke img.destroy |
call generate_header |
.ret: |
ret |
.notfound: |
pop eax |
pop [image] |
call init_frame |
ret |
445,13 → 441,20 |
cmp [directory_ptr], 0 |
jnz .ret |
mov esi, @PARAMS |
mov ecx, esi |
@@: |
lodsb |
test al, al |
jnz @b |
@@: |
dec esi |
cmp byte [esi], '/' |
jnz @b |
mov [last_name_component], esi |
sub esi, ecx |
xchg ecx, esi |
mov edi, curdir |
mov ecx, [last_name_component] |
sub ecx, esi |
dec ecx |
js @f |
rep movsb |
@@: |
mov byte [edi], 0 |
mcall 68, 12, 0x1000 |
test eax, eax |
547,6 → 550,7 |
add edi, 32 + 40 |
.scan: |
mov esi, [last_name_component] |
inc esi |
push edi |
invoke strcmpi |
pop edi |
566,25 → 570,6 |
and [directory_ptr], 0 |
ret |
|
; in: esi->full name (e.g. /path/to/file.png) |
; out: [last_name_component]->last component (e.g. file.png) |
find_last_name_component: |
mov ecx, esi |
@@: |
lodsb |
test al, al |
jnz @b |
@@: |
dec esi |
cmp esi, ecx |
jb @f |
cmp byte [esi], '/' |
jnz @b |
@@: |
inc esi |
mov [last_name_component], esi |
ret |
|
init_frame: |
push eax |
mov eax, [image] |
634,7 → 619,7 |
__mov ebx, 100, 0 |
add ebx, [wnd_width] |
lea ecx, [100*65536 + eax] |
mcall 0, , , 0x73FFFFFF, 0, real_header |
mcall 0, , , 0x73FFFFFF, 0, s_header |
|
mcall 9, procinfo, -1 |
mov [bFirstDraw], 1 |
803,95 → 788,9 |
pop ecx ebx |
ret 4 |
|
check_shortcut: |
; in: cl = scancode (from sysfn 2), |
; eax = state of modifiers (from sysfn 66.3), |
; edx -> shortcut descriptor |
; out: ZF set <=> fail |
cmp cl, [edx+4] |
jnz .not |
push eax |
mov esi, [edx] |
and esi, 0xF |
and al, 3 |
call dword [check_modifier_table+esi*4] |
test al, al |
pop eax |
jnz .not |
push eax |
mov esi, [edx] |
shr esi, 4 |
and esi, 0xF |
shr al, 2 |
and al, 3 |
call dword [check_modifier_table+esi*4] |
test al, al |
pop eax |
jnz .not |
push eax |
mov esi, [edx] |
shr esi, 8 |
and esi, 0xF |
shr al, 4 |
and al, 3 |
call dword [check_modifier_table+esi*4] |
test al, al |
pop eax |
; jnz .not |
.not: |
ret |
|
check_modifier_0: |
setnz al |
ret |
check_modifier_1: |
setp al |
ret |
check_modifier_2: |
cmp al, 3 |
setnz al |
ret |
check_modifier_3: |
cmp al, 1 |
setnz al |
ret |
check_modifier_4: |
cmp al, 2 |
setnz al |
ret |
|
; fills real_header with window title |
; window title is generated as '<filename> - Kolibri Image Viewer' |
generate_header: |
push eax |
mov esi, [last_name_component] |
mov edi, real_header |
@@: |
lodsb |
test al, al |
jz @f |
stosb |
cmp edi, real_header+256 |
jb @b |
.overflow: |
mov dword [edi-4], '...' |
.ret: |
pop eax |
ret |
@@: |
mov esi, s_header |
@@: |
lodsb |
stosb |
test al, al |
jz .ret |
cmp edi, real_header+256 |
jb @b |
jmp .overflow |
|
;----------------------------------------------------------------------------- |
|
s_header db ' - Kolibri Image Viewer', 0 |
s_header db 'Kolibri Image Viewer', 0 |
|
;----------------------------------------------------------------------------- |
|
1097,7 → 996,6 |
libio , 'libio.obj' , \ |
libgfx , 'libgfx.obj' , \ |
libimg , 'libimg.obj' , \ |
libini , 'libini.obj' , \ |
sort , 'sort.obj' |
|
import libio , \ |
1124,9 → 1022,6 |
img.destroy , 'img_destroy', \ |
img.draw , 'img_draw' |
|
import libini, \ |
ini_get_shortcut, 'ini_get_shortcut' |
|
import sort, sort.START, 'START', SortDir, 'SortDir', strcmpi, 'strcmpi' |
|
bFirstDraw db 0 |
1162,19 → 1057,6 |
end repeat |
end repeat |
|
inifilename db '/sys/media/kiv.ini',0 |
aShortcuts db 'Shortcuts',0 |
aNext db 'Next',0 |
aPrev db 'Prev',0 |
|
align 4 |
check_modifier_table: |
dd check_modifier_0 |
dd check_modifier_1 |
dd check_modifier_2 |
dd check_modifier_3 |
dd check_modifier_4 |
|
; DATA AREA |
get_loops dd 0 |
dlg_pid_get dd 0 |
1220,13 → 1102,9 |
cur_frame_time dd ? |
cur_frame dd ? |
|
next_mod dd ? |
next_key dd ? |
prev_mod dd ? |
prev_key dd ? |
ctx dd ? |
|
procinfo: rb 1024 |
path: rb 1024+16 |
real_header rb 256 |
|
@PARAMS rb 512 |