Subversion Repositories Kolibri OS

Rev

Rev 1422 | Rev 1470 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1422 Rev 1427
Line 32... Line 32...
32
	jz	set_bgr
32
	jz	set_bgr
33
	inc	ecx	; for 15.4: 2 = stretch
33
	inc	ecx	; for 15.4: 2 = stretch
34
	cmp	word [@PARAMS], '\S'
34
	cmp	word [@PARAMS], '\S'
35
	jz	set_bgr
35
	jz	set_bgr
Line -... Line 36...
-
 
36
 
-
 
37
; initialize keyboard handling
-
 
38
	invoke	ini_get_shortcut, inifilename, aShortcuts, aNext, -1, next_mod
-
 
39
	mov	[next_key], eax
-
 
40
	invoke	ini_get_shortcut, inifilename, aShortcuts, aPrev, -1, prev_mod
-
 
41
	mov	[prev_key], eax
-
 
42
	mcall	66, 1, 1	; set kbd mode to scancodes
36
 
43
 
37
	cmp	byte [@PARAMS], 0
44
	cmp	byte [@PARAMS], 0
Line 38... Line 45...
38
	jnz	params_given
45
	jnz	params_given
39
 
46
 
Line 55... Line 62...
55
	call	set_as_bgr
62
	call	set_as_bgr
56
	jmp	exit
63
	jmp	exit
Line 57... Line 64...
57
 
64
 
Line 58... Line 65...
58
params_given:
65
params_given:
-
 
66
 
-
 
67
	mov	esi, @PARAMS
-
 
68
	push	esi
-
 
69
	call	find_last_name_component
59
 
70
 
60
	mov	eax, @PARAMS
71
	pop	eax
-
 
72
	call	load_image
Line 61... Line 73...
61
	call	load_image
73
	jc	exit
Line 62... Line 74...
62
	jc	exit
74
	call	generate_header
63
 
75
 
Line 90... Line 102...
90
	jz	red
102
	jz	red
91
	dec	eax
103
	dec	eax
92
	jnz	button
104
	jnz	button
Line 93... Line 105...
93
 
105
 
-
 
106
key:
-
 
107
	xor	esi, esi
94
key:
108
keyloop:
-
 
109
	mcall	2
-
 
110
	test	al, al
-
 
111
	jnz	keyloopdone
-
 
112
	shr	eax, 8
-
 
113
	mov	ecx, eax
-
 
114
	mcall	66, 3
-
 
115
	mov	edx, next_mod
-
 
116
	call	check_shortcut
-
 
117
	jz	.next
-
 
118
	add	edx, prev_mod - next_mod
-
 
119
	call	check_shortcut
-
 
120
	jnz	keyloop
-
 
121
.prev:
-
 
122
	dec	esi
-
 
123
	jmp	keyloop
-
 
124
.next:
-
 
125
	inc	esi
-
 
126
	jmp	keyloop
-
 
127
keyloopdone:
95
	mcall	2
128
	test	esi, esi
-
 
129
	jz	still
-
 
130
next_or_prev_handler:
-
 
131
	call	next_or_prev_image
Line 96... Line 132...
96
	jmp	still
132
	jmp	red
97
 
133
 
98
red_update_frame:
134
red_update_frame:
99
	mov	eax, [cur_frame]
135
	mov	eax, [cur_frame]
Line 184... Line 220...
184
	call	set_as_bgr
220
	call	set_as_bgr
185
	jmp	still
221
	jmp	still
Line 186... Line 222...
186
 
222
 
Line -... Line 223...
-
 
223
    @@:
187
    @@:
224
 
188
 
-
 
189
	cmp	eax, 'bck'
225
	or	esi, -1
190
	jnz	@f
226
	cmp	eax, 'bck'
191
	call	prev_image
-
 
192
	jmp	red
227
	jz	next_or_prev_handler
193
    @@:
-
 
194
	cmp	eax, 'fwd'
228
	neg	esi
195
	jnz	@f
-
 
196
	call	next_image
-
 
Line 197... Line 229...
197
	jmp	red
229
	cmp	eax, 'fwd'
198
    @@:
230
	jz	next_or_prev_handler
Line 199... Line 231...
199
 
231
 
Line 305... Line 337...
305
 
337
 
306
@@:
338
@@:
307
	mcall	15, 3
339
	mcall	15, 3
Line -... Line 340...
-
 
340
	ret
-
 
341
 
308
	ret
342
; seek to ESI image files
-
 
343
; esi>0 means next file, esi<0 - prev file
309
 
344
next_or_prev_image:
310
prev_image:
-
 
311
	call	load_directory
345
	push	esi
312
	cmp	[directory_ptr], 0
346
	call	load_directory
-
 
347
	pop	esi
-
 
348
	mov	ebx, [directory_ptr]
-
 
349
	test	ebx, ebx
-
 
350
	jz	.ret
313
	jz	.ret
351
	cmp	dword[ebx+4], 0
314
	mov	ebx, [directory_ptr]
352
	jz	.ret
315
	mov	eax, [cur_file_idx]
353
	mov	eax, [cur_file_idx]
-
 
354
	cmp	eax, -1
-
 
355
	jnz	@f
316
	cmp	eax, -1
356
	test	esi, esi
317
	jnz	@f
357
	jns	@f
318
	mov	eax, [ebx+4]
358
	mov	eax, [ebx+4]
319
@@:
359
@@:
-
 
360
	push	[image]
320
	push	[image]
361
	add	eax, esi
321
.scanloop:
362
@@:
322
	dec	eax
363
	test	eax, eax
323
	jns	@f
364
	jns	@f
324
	mov	eax, [ebx+4]
-
 
325
	dec	eax
-
 
326
	cmp	[cur_file_idx], -1
365
	add	eax, [ebx+4]
327
	jz	.notfound
366
	jmp	@b
328
@@:
367
@@:
-
 
368
	cmp	eax, [ebx+4]
-
 
369
	jb	@f
-
 
370
	sub	eax, [ebx+4]
-
 
371
	jmp	@b
-
 
372
@@:
329
	cmp	eax, [cur_file_idx]
373
	push	eax
330
	jz	.notfound
374
.scanloop:
331
	push	eax ebx
375
	push	eax ebx esi
332
	imul	esi, eax, 304
376
	imul	esi, eax, 304
333
	add	esi, [directory_ptr]
377
	add	esi, [directory_ptr]
334
	add	esi, 32 + 40
378
	add	esi, 32 + 40
Line 361... Line 405...
361
	dec	esi
405
	dec	esi
362
	cmp	byte [esi], '/'
406
	cmp	byte [esi], '/'
363
	jnz	@b
407
	jnz	@b
364
	mov	byte [esi], 0
408
	mov	byte [esi], 0
365
	popf
409
	popf
366
	pop	ebx eax
410
	pop	esi ebx eax
367
	jc	.scanloop
411
	jnc	.loadedok
368
	mov	[cur_file_idx], eax
-
 
369
	invoke	img.destroy
-
 
370
.ret:
-
 
371
	ret
-
 
372
.notfound:
-
 
373
	pop	[image]
412
	test	esi, esi
374
	call	init_frame
-
 
375
	ret
-
 
376
 
-
 
377
next_image:
-
 
378
	call	load_directory
-
 
379
	cmp	[directory_ptr], 0
-
 
380
	jz	.ret
413
	js	.try_prev
381
	mov	ebx, [directory_ptr]
-
 
382
	mov	eax, [cur_file_idx]
-
 
383
	push	[image]
-
 
384
.scanloop:
414
.try_next:
385
	inc	eax
415
	inc	eax
386
	cmp	eax, [ebx+4]
416
	cmp	eax, [ebx+4]
387
	jb	@f
417
	jb	@f
388
	xor	eax, eax
418
	xor	eax, eax
389
	cmp	[cur_file_idx], -1
-
 
390
	jz	.notfound
-
 
391
@@:
419
@@:
-
 
420
.try_common:
392
	cmp	eax, [cur_file_idx]
421
	cmp	eax, [esp]
393
	jz	.notfound
422
	jz	.notfound
394
	push	eax ebx
-
 
395
	imul	esi, eax, 304
423
	jmp	.scanloop
396
	add	esi, [directory_ptr]
-
 
397
	add	esi, 32 + 40
-
 
398
	mov	edi, curdir
424
.try_prev:
399
@@:
-
 
400
	inc	edi
425
	dec	eax
401
	cmp	byte [edi-1], 0
-
 
402
	jnz	@b
-
 
403
	mov	byte [edi-1], '/'
-
 
404
@@:
-
 
405
	lodsb
-
 
406
	stosb
-
 
407
	test	al, al
-
 
408
	jnz	@b
426
	jns	@f
409
	mov	eax, curdir
427
	mov	eax, [ebx+4]
410
	call	load_image
-
 
411
	pushf
-
 
412
	mov	esi, curdir
-
 
413
	push	esi
-
 
414
	mov	edi, @PARAMS
-
 
415
	mov	ecx, 512/4
-
 
416
	rep	movsd
-
 
417
	mov	byte [edi-1], 0
-
 
418
	pop	esi
428
	dec	eax
419
@@:
-
 
420
	lodsb
-
 
421
	test	al, al
-
 
422
	jnz	@b
-
 
423
@@:
429
@@:
424
	dec	esi
-
 
425
	cmp	byte [esi], '/'
430
	jmp	.try_common
426
	jnz	@b
-
 
427
	mov	byte [esi], 0
-
 
428
	popf
-
 
429
	pop	ebx eax
431
.loadedok:
430
	jc	.scanloop
-
 
431
	mov	[cur_file_idx], eax
432
	mov	[cur_file_idx], eax
-
 
433
	pop	eax
432
	invoke	img.destroy
434
	invoke	img.destroy
-
 
435
	call	generate_header
433
.ret:
436
.ret:
434
	ret
437
	ret
435
.notfound:
438
.notfound:
-
 
439
	pop	eax
436
	pop	[image]
440
	pop	[image]
437
	call	init_frame
441
	call	init_frame
438
	ret
442
	ret
Line 439... Line 443...
439
 
443
 
440
load_directory:
444
load_directory:
441
	cmp	[directory_ptr], 0
445
	cmp	[directory_ptr], 0
442
	jnz	.ret
446
	jnz	.ret
443
	mov	esi, @PARAMS
-
 
444
	mov	ecx, esi
-
 
445
@@:
-
 
446
	lodsb
-
 
447
	test	al, al
-
 
448
	jnz	@b
-
 
449
@@:
-
 
450
	dec	esi
-
 
451
	cmp	byte [esi], '/'
-
 
452
	jnz	@b
-
 
453
	mov	[last_name_component], esi
-
 
454
	sub	esi, ecx
-
 
455
	xchg	ecx, esi
447
	mov	esi, @PARAMS
-
 
448
	mov	edi, curdir
-
 
449
	mov	ecx, [last_name_component]
-
 
450
	sub	ecx, esi
-
 
451
	dec	ecx
456
	mov	edi, curdir
452
	js	@f
-
 
453
	rep	movsb
457
	rep	movsb
454
@@:
458
	mov	byte [edi], 0
455
	mov	byte [edi], 0
459
	mcall	68, 12, 0x1000
456
	mcall	68, 12, 0x1000
460
	test	eax, eax
457
	test	eax, eax
461
	jz	.ret
458
	jz	.ret
Line 548... Line 545...
548
	xor	eax, eax
545
	xor	eax, eax
549
	mov	edi, [directory_ptr]
546
	mov	edi, [directory_ptr]
550
	add	edi, 32 + 40
547
	add	edi, 32 + 40
551
.scan:
548
.scan:
552
	mov	esi, [last_name_component]
549
	mov	esi, [last_name_component]
553
	inc	esi
-
 
554
	push	edi
550
	push	edi
555
	invoke	strcmpi
551
	invoke	strcmpi
556
	pop	edi
552
	pop	edi
557
	jz	.found
553
	jz	.found
558
	inc	eax
554
	inc	eax
Line 568... Line 564...
568
free_directory:
564
free_directory:
569
	mcall	68, 13, [directory_ptr]
565
	mcall	68, 13, [directory_ptr]
570
	and	[directory_ptr], 0
566
	and	[directory_ptr], 0
571
	ret
567
	ret
Line -... Line 568...
-
 
568
 
-
 
569
; in: esi->full name (e.g. /path/to/file.png)
-
 
570
; out: [last_name_component]->last component (e.g. file.png)
-
 
571
find_last_name_component:
-
 
572
	mov	ecx, esi
-
 
573
@@:
-
 
574
	lodsb
-
 
575
	test	al, al
-
 
576
	jnz	@b
-
 
577
@@:
-
 
578
	dec	esi
-
 
579
	cmp	esi, ecx
-
 
580
	jb	@f
-
 
581
	cmp	byte [esi], '/'
-
 
582
	jnz	@b
-
 
583
@@:
-
 
584
	inc	esi
-
 
585
	mov	[last_name_component], esi
-
 
586
	ret
572
 
587
 
573
init_frame:
588
init_frame:
574
	push	eax
589
	push	eax
575
	mov	eax, [image]
590
	mov	eax, [image]
576
	mov	[cur_frame], eax
591
	mov	[cur_frame], eax
Line 617... Line 632...
617
	mov	ebp, eax	; save skin height
632
	mov	ebp, eax	; save skin height
618
	add	eax, [wnd_height]
633
	add	eax, [wnd_height]
619
	__mov	ebx, 100, 0
634
	__mov	ebx, 100, 0
620
	add	ebx, [wnd_width]
635
	add	ebx, [wnd_width]
621
	lea	ecx, [100*65536 + eax]
636
	lea	ecx, [100*65536 + eax]
622
	mcall	0, , , 0x73FFFFFF, 0, s_header
637
	mcall	0, , , 0x73FFFFFF, 0, real_header
Line 623... Line 638...
623
 
638
 
624
	mcall	9, procinfo, -1
639
	mcall	9, procinfo, -1
625
	mov	[bFirstDraw], 1
640
	mov	[bFirstDraw], 1
626
	cmp	dword [ebx + 66], 0
641
	cmp	dword [ebx + 66], 0
Line 786... Line 801...
786
	mov	ecx, [esp+12]
801
	mov	ecx, [esp+12]
787
	mcall	68, 13
802
	mcall	68, 13
788
	pop	ecx ebx
803
	pop	ecx ebx
789
	ret	4
804
	ret	4
Line -... Line 805...
-
 
805
 
-
 
806
check_shortcut:
-
 
807
; in:	cl = scancode (from sysfn 2),
-
 
808
;	eax = state of modifiers (from sysfn 66.3),
-
 
809
;	edx -> shortcut descriptor
-
 
810
; out:	ZF set <=> fail
-
 
811
	cmp	cl, [edx+4]
-
 
812
	jnz	.not
-
 
813
	push	eax
-
 
814
	mov	esi, [edx]
-
 
815
	and	esi, 0xF
-
 
816
	and	al, 3
-
 
817
	call	dword [check_modifier_table+esi*4]
-
 
818
	test	al, al
-
 
819
	pop	eax
-
 
820
	jnz	.not
-
 
821
	push	eax
-
 
822
	mov	esi, [edx]
-
 
823
	shr	esi, 4
-
 
824
	and	esi, 0xF
-
 
825
	shr	al, 2
-
 
826
	and	al, 3
-
 
827
	call	dword [check_modifier_table+esi*4]
-
 
828
	test	al, al
-
 
829
	pop	eax
-
 
830
	jnz	.not
-
 
831
	push	eax
-
 
832
	mov	esi, [edx]
-
 
833
	shr	esi, 8
-
 
834
	and	esi, 0xF
-
 
835
	shr	al, 4
-
 
836
	and	al, 3
-
 
837
	call	dword [check_modifier_table+esi*4]
-
 
838
	test	al, al
-
 
839
	pop	eax
-
 
840
;	jnz	.not
-
 
841
.not:
-
 
842
	ret
-
 
843
 
-
 
844
check_modifier_0:
-
 
845
	setnz	al
-
 
846
	ret
-
 
847
check_modifier_1:
-
 
848
	setp	al
-
 
849
	ret
-
 
850
check_modifier_2:
-
 
851
	cmp	al, 3
-
 
852
	setnz	al
-
 
853
	ret
-
 
854
check_modifier_3:
-
 
855
	cmp	al, 1
-
 
856
	setnz	al
-
 
857
	ret
-
 
858
check_modifier_4:
-
 
859
	cmp	al, 2
-
 
860
	setnz	al
-
 
861
	ret
-
 
862
 
-
 
863
; fills real_header with window title
-
 
864
; window title is generated as ' - Kolibri Image Viewer'
-
 
865
generate_header:
-
 
866
	push	eax
-
 
867
	mov	esi, [last_name_component]
-
 
868
	mov	edi, real_header
-
 
869
@@:
-
 
870
	lodsb
-
 
871
	test	al, al
-
 
872
	jz	@f
-
 
873
	stosb
-
 
874
	cmp	edi, real_header+256
-
 
875
	jb	@b
-
 
876
.overflow:
-
 
877
	mov	dword [edi-4], '...'
-
 
878
.ret:
-
 
879
	pop	eax
-
 
880
	ret
-
 
881
@@:
-
 
882
	mov	esi, s_header
-
 
883
@@:
-
 
884
	lodsb
-
 
885
	stosb
-
 
886
	test	al, al
-
 
887
	jz	.ret
-
 
888
	cmp	edi, real_header+256
-
 
889
	jb	@b
-
 
890
	jmp	.overflow
790
 
891
 
Line 791... Line 892...
791
;-----------------------------------------------------------------------------
892
;-----------------------------------------------------------------------------
Line 792... Line 893...
792
 
893
 
Line 793... Line 894...
793
s_header db 'Kolibri Image Viewer', 0
894
s_header db ' - Kolibri Image Viewer', 0
794
 
895
 
Line 994... Line 1095...
994
 
1095
 
995
library 			\
1096
library 			\
996
	libio  , 'libio.obj'  , \
1097
	libio  , 'libio.obj'  , \
997
	libgfx , 'libgfx.obj' , \
1098
	libgfx , 'libgfx.obj' , \
-
 
1099
	libimg , 'libimg.obj' , \
998
	libimg , 'libimg.obj' , \
1100
	libini , 'libini.obj' , \
Line 999... Line 1101...
999
	sort   , 'sort.obj'
1101
	sort   , 'sort.obj'
1000
 
1102
 
1001
import	libio			  , \
1103
import	libio			  , \
Line 1020... Line 1122...
1020
	img.flip    , 'img_flip'   , \
1122
	img.flip    , 'img_flip'   , \
1021
	img.rotate  , 'img_rotate' , \
1123
	img.rotate  , 'img_rotate' , \
1022
	img.destroy , 'img_destroy', \
1124
	img.destroy , 'img_destroy', \
1023
	img.draw    , 'img_draw'
1125
	img.draw    , 'img_draw'
Line -... Line 1126...
-
 
1126
 
-
 
1127
import	libini, \
-
 
1128
	ini_get_shortcut, 'ini_get_shortcut'
1024
 
1129
 
Line 1025... Line 1130...
1025
import  sort, sort.START, 'START', SortDir, 'SortDir', strcmpi, 'strcmpi'
1130
import  sort, sort.START, 'START', SortDir, 'SortDir', strcmpi, 'strcmpi'
1026
 
1131
 
Line 1055... Line 1160...
1055
store dword a at $ - numimages*20*20 + numimages*20*z + (%-1)*4
1160
store dword a at $ - numimages*20*20 + numimages*20*z + (%-1)*4
1056
store dword b at $ - numimages*20*20 + numimages*20*y + (%-1)*4
1161
store dword b at $ - numimages*20*20 + numimages*20*y + (%-1)*4
1057
end repeat
1162
end repeat
1058
end repeat
1163
end repeat
Line -... Line 1164...
-
 
1164
 
-
 
1165
inifilename	db	'/sys/media/kiv.ini',0
-
 
1166
aShortcuts	db	'Shortcuts',0
-
 
1167
aNext		db	'Next',0
-
 
1168
aPrev		db	'Prev',0
-
 
1169
 
-
 
1170
align 4
-
 
1171
check_modifier_table:
-
 
1172
	dd	check_modifier_0
-
 
1173
	dd	check_modifier_1
-
 
1174
	dd	check_modifier_2
-
 
1175
	dd	check_modifier_3
-
 
1176
	dd	check_modifier_4
1059
 
1177
 
1060
; DATA AREA
1178
; DATA AREA
1061
get_loops   dd 0
1179
get_loops   dd 0
1062
dlg_pid_get dd 0
1180
dlg_pid_get dd 0
Line 1100... Line 1218...
1100
last_name_component	dd	?
1218
last_name_component	dd	?
1101
cur_file_idx	dd	?
1219
cur_file_idx	dd	?
1102
cur_frame_time	dd	?
1220
cur_frame_time	dd	?
1103
cur_frame	dd	?
1221
cur_frame	dd	?
Line -... Line 1222...
-
 
1222
 
1104
 
1223
next_mod	dd	?
-
 
1224
next_key	dd	?
-
 
1225
prev_mod	dd	?
Line 1105... Line 1226...
1105
ctx dd ?
1226
prev_key	dd	?
1106
 
1227
 
-
 
1228
procinfo:	rb	1024
Line 1107... Line 1229...
1107
procinfo:	rb	1024
1229
path:		rb	1024+16