Subversion Repositories Kolibri OS

Rev

Rev 1016 | Rev 1080 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1004 diamond 1
use32
2
org 0x0
3
 
4
db 'MENUET01'
5
dd 0x01, START, I_END, 0x4000, 0x4000, @PARAMS, 0x0
6
 
7
;-----------------------------------------------------------------------------
8
 
9
FALSE = 0
10
TRUE  = 1
11
 
12
include '../../../../../proc32.inc'
13
include '../../../../../macros.inc'
14
include 'dll.inc'
15
 
16
include '../../../develop/libraries/libs-dev/libio/libio.inc'
17
include '../../../develop/libraries/libs-dev/libimg/libimg.inc'
18
 
19
;-----------------------------------------------------------------------------
20
 
21
START:
22
	mcall	68, 11
23
 
24
	stdcall dll.Load, @IMPORT
25
	or	eax, eax
26
	jnz	exit
27
 
1016 diamond 28
	invoke	sort.START, 1
29
 
1004 diamond 30
	mov	ecx, 1	; for 15.4: 1 = tile
31
	cmp	word [@PARAMS], '\T'
32
	jz	set_bgr
33
	inc	ecx	; for 15.4: 2 = stretch
34
	cmp	word [@PARAMS], '\S'
35
	jz	set_bgr
36
 
37
	cmp	byte [@PARAMS], 0
38
	jnz	params_given
39
 
40
	call	opendialog
41
	jc	exit
42
	mov	esi, path
43
	mov	edi, @PARAMS
44
	mov	ecx, 512/4
45
	rep	movsd
46
	mov	byte [edi-1], 0
47
	jmp	params_given
48
 
49
set_bgr:
50
	mcall	15, 4
51
	mov	eax, @PARAMS + 4
52
	call	load_image
1016 diamond 53
	jc	exit
1004 diamond 54
 
1016 diamond 55
	call	set_as_bgr
1004 diamond 56
	jmp	exit
57
 
58
params_given:
59
 
60
	mov	eax, @PARAMS
61
	call	load_image
62
	jc	exit
63
 
64
;-----------------------------------------------------------------------------
65
 
66
red:
67
	call	draw_window
68
 
69
still:
70
	mcall	10
71
	dec	eax
72
	jz	red
73
	dec	eax
74
	jnz	button
75
 
76
  key:
77
	mcall	2
78
	jmp	still
79
 
80
  button:
81
	mcall	17
82
	shr	eax, 8
83
 
84
	; flip horizontally
85
	cmp	eax, 'flh'
86
	jne	@f
87
 
88
	invoke	img.flip, [image], FLIP_HORIZONTAL
89
	jmp	redraw_image
90
 
91
	; flip vertically
92
    @@: cmp	eax, 'flv'
93
	jne	@f
94
 
95
	invoke	img.flip, [image], FLIP_VERTICAL
96
	jmp	redraw_image
97
 
98
	; flip both horizontally and vertically
99
    @@: cmp	eax, 'flb'
100
	jne	@f
101
 
102
	invoke	img.flip, [image], FLIP_BOTH
103
	jmp	redraw_image
104
 
105
	; rotate left
106
    @@: cmp	eax, 'rtl'
107
	jne	@f
108
 
109
	push	ROTATE_90_CCW
110
.rotate_common:
111
	invoke	img.rotate, [image]
112
	mov	eax, [image]
113
	test	eax, eax	; clear ZF flag
114
	call	update_image_sizes
115
	jmp	redraw_image
116
 
117
	; rotate right
118
    @@: cmp	eax, 'rtr'
119
	jne	@f
120
 
121
	push	ROTATE_90_CW
122
	jmp	.rotate_common
123
 
124
	; open new file
125
    @@: cmp	eax, 'opn'
126
	jne	@f
127
 
128
	call	opendialog
129
	jc	still
130
	push	[image]
131
	mov	eax, path
132
	call	load_image
133
	jc	.restore_old
134
	mov	esi, path
135
	mov	edi, @PARAMS
136
	mov	ecx, 512/4
137
	rep	movsd
1016 diamond 138
	mov	byte [edi-1], 0
1004 diamond 139
	invoke	img.destroy
1016 diamond 140
	call	free_directory
1004 diamond 141
	jmp	red
142
    .restore_old:
143
	pop	[image]
144
	jmp	still
145
 
1016 diamond 146
	; set background
147
    @@:
148
	cmp	eax, 'bgr'
149
	jne	@f
150
 
151
	call	set_as_bgr
152
	jmp	still
153
 
154
    @@:
155
 
156
	cmp	eax, 'bck'
157
	jnz	@f
158
	call	prev_image
159
	jmp	still
160
    @@:
161
	cmp	eax, 'fwd'
162
	jnz	@f
163
	call	next_image
164
	jmp	still
165
    @@:
166
 
167
	cmp	eax, 1
1004 diamond 168
	jne	still
169
 
170
  exit:
171
	mcall	-1
172
 
173
  redraw_image = red
174
 
175
load_image:
176
	and	[img_data], 0
177
	push	eax
178
	invoke	file.open, eax, O_READ
179
	or	eax, eax
180
	jz	.error_pop
181
	mov	[fh], eax
182
	invoke	file.size
183
	mov	[img_data_len], ebx
184
	stdcall mem.Alloc, ebx
185
	test	eax, eax
186
	jz	.error_close
187
	mov	[img_data], eax
188
	invoke	file.read, [fh], eax, [img_data_len]
189
	cmp	eax, -1
190
	jz	.error_close
191
	cmp	eax, [img_data_len]
192
	jnz	.error_close
193
	invoke	file.close, [fh]
194
	inc	eax
195
	jz	.error
196
 
197
; img.decode checks for img.is_img
198
;	invoke	img.is_img, [img_data], [img_data_len]
199
;	or	eax, eax
200
;	jz	exit
201
	invoke	img.decode, [img_data], [img_data_len]
202
	or	eax, eax
203
	jz	.error
204
	cmp	[image], 0
205
	mov	[image], eax
206
	call	update_image_sizes
207
	call	free_img_data
208
	clc
209
	ret
210
 
211
.error_free:
212
	invoke	img.destroy, [image]
213
	jmp	.error
214
 
215
.error_pop:
216
	pop	eax
217
	jmp	.error
218
.error_close:
219
	invoke	file.close, [fh]
220
.error:
221
	call	free_img_data
222
	stc
223
	ret
224
 
225
free_img_data:
226
	mov	eax, [img_data]
227
	test	eax, eax
228
	jz	@f
229
	stdcall	mem.Free, eax
230
@@:
231
	ret
232
 
233
update_image_sizes:
234
	pushf
235
	mov	edx, [eax + Image.Width]
1040 diamond 236
	mov	[draw_width], edx
1004 diamond 237
	add	edx, 19
1016 diamond 238
	cmp	edx, 40 + 25*9
1004 diamond 239
	jae	@f
1016 diamond 240
	mov	edx, 40 + 25*9
1004 diamond 241
@@:
242
	mov	[wnd_width], edx
243
	mov	esi, [eax + Image.Height]
1040 diamond 244
	mov	[draw_height], esi
1004 diamond 245
	add	esi, 44
246
	mov	[wnd_height], esi
247
	popf
248
	jz	.no_resize
249
	mcall	48, 4
250
	add	esi, eax
251
	mcall	67,-1,-1
252
.no_resize:
253
	ret
254
 
1016 diamond 255
set_as_bgr:
256
	mov	esi, [image]
257
	mov	ecx, [esi + Image.Width]
258
	mov	edx, [esi + Image.Height]
259
	mcall	15, 1
260
 
261
	mcall	15, 6
262
	test	eax, eax
263
	jz	@f
264
 
265
	push	eax
266
	invoke	img.to_rgb2, esi, eax
267
	pop	ecx
268
	mcall	15, 7
269
 
270
@@:
271
	mcall	15, 3
272
	ret
273
 
274
prev_image:
275
	call	load_directory
276
	cmp	[directory_ptr], 0
277
	jz	.ret
278
	mov	ebx, [directory_ptr]
279
	mov	eax, [cur_file_idx]
280
	cmp	eax, -1
281
	jnz	@f
282
	mov	eax, [ebx+4]
283
@@:
284
	push	[image]
285
.scanloop:
286
	dec	eax
287
	jns	@f
288
	mov	eax, [ebx+4]
289
	dec	eax
290
	cmp	[cur_file_idx], -1
291
	jz	.notfound
292
@@:
293
	cmp	eax, [cur_file_idx]
294
	jz	.notfound
1040 diamond 295
	push	eax ebx
1016 diamond 296
	imul	esi, eax, 304
297
	add	esi, [directory_ptr]
298
	add	esi, 32 + 40
299
	mov	edi, curdir
300
@@:
301
	inc	edi
302
	cmp	byte [edi-1], 0
303
	jnz	@b
304
	mov	byte [edi-1], '/'
305
@@:
306
	lodsb
307
	stosb
308
	test	al, al
309
	jnz	@b
310
	mov	eax, curdir
311
	call	load_image
1040 diamond 312
	pushf
1016 diamond 313
	mov	esi, curdir
1040 diamond 314
	push	esi
1016 diamond 315
	mov	edi, @PARAMS
316
	mov	ecx, 512/4
317
	rep	movsd
318
	mov	byte [edi-1], 0
1040 diamond 319
	pop	esi
320
@@:
321
	lodsb
322
	test	al, al
323
	jnz	@b
324
@@:
325
	dec	esi
326
	cmp	byte [esi], '/'
327
	jnz	@b
328
	mov	byte [esi], 0
329
	popf
330
	pop	ebx eax
331
	jc	.scanloop
332
	mov	[cur_file_idx], eax
333
	invoke	img.destroy
1016 diamond 334
.ret:
335
	ret
336
.notfound:
337
	pop	[image]
338
	ret
339
 
340
next_image:
341
	call	load_directory
342
	cmp	[directory_ptr], 0
343
	jz	.ret
344
	mov	ebx, [directory_ptr]
345
	mov	eax, [cur_file_idx]
346
	push	[image]
347
.scanloop:
348
	inc	eax
349
	cmp	eax, [ebx+4]
350
	jb	@f
351
	xor	eax, eax
352
	cmp	[cur_file_idx], -1
353
	jz	.notfound
354
@@:
355
	cmp	eax, [cur_file_idx]
356
	jz	.notfound
357
	push	eax ebx
358
	imul	esi, eax, 304
359
	add	esi, [directory_ptr]
360
	add	esi, 32 + 40
361
	mov	edi, curdir
362
@@:
363
	inc	edi
364
	cmp	byte [edi-1], 0
365
	jnz	@b
366
	mov	byte [edi-1], '/'
367
@@:
368
	lodsb
369
	stosb
370
	test	al, al
371
	jnz	@b
372
	mov	eax, curdir
373
	call	load_image
1040 diamond 374
	pushf
1016 diamond 375
	mov	esi, curdir
376
	push	esi
377
	mov	edi, @PARAMS
378
	mov	ecx, 512/4
379
	rep	movsd
380
	mov	byte [edi-1], 0
381
	pop	esi
382
@@:
383
	lodsb
384
	test	al, al
385
	jnz	@b
386
@@:
387
	dec	esi
388
	cmp	byte [esi], '/'
389
	jnz	@b
390
	mov	byte [esi], 0
1040 diamond 391
	popf
392
	pop	ebx eax
393
	jc	.scanloop
394
	mov	[cur_file_idx], eax
395
	invoke	img.destroy
1016 diamond 396
.ret:
397
	ret
398
.notfound:
399
	pop	[image]
400
	ret
401
 
402
load_directory:
403
	cmp	[directory_ptr], 0
404
	jnz	.ret
405
	mov	esi, @PARAMS
406
	mov	ecx, esi
407
@@:
408
	lodsb
409
	test	al, al
410
	jnz	@b
411
@@:
412
	dec	esi
413
	cmp	byte [esi], '/'
414
	jnz	@b
415
	mov	[last_name_component], esi
416
	sub	esi, ecx
417
	xchg	ecx, esi
418
	mov	edi, curdir
419
	rep	movsb
420
	mov	byte [edi], 0
421
	mcall	68, 12, 0x1000
422
	test	eax, eax
423
	jz	.ret
424
	mov	ebx, readdir_fileinfo
425
	mov	dword [ebx+12], (0x1000 - 32) / 304
426
	mov	dword [ebx+16], eax
427
	mcall	70
428
	cmp	eax, 6
429
	jz	.dirok
430
	test	eax, eax
431
	jnz	free_directory
432
	mov	edx, [directory_ptr]
433
	mov	ecx, [edx+8]
434
	mov	[readblocks], ecx
435
	imul	ecx, 304
436
	add	ecx, 32
437
	mcall	68, 20
438
	test	eax, eax
439
	jz	free_directory
440
	mov	[directory_ptr], eax
441
	mcall	70, readdir_fileinfo
442
.dirok:
443
	cmp	ebx, 0
444
	jle	free_directory
445
	mov	eax, [directory_ptr]
446
	add	eax, 32
447
	mov	edi, eax
448
	push	0
449
.dirskip:
450
	push	eax
451
	test	byte [eax], 18h
452
	jnz	.nocopy
453
	lea	esi, [eax+40]
454
	mov	ecx, esi
455
@@:
456
	lodsb
457
	test	al, al
458
	jnz	@b
459
@@:
460
	dec	esi
461
	cmp	esi, ecx
462
	jb	.noext
463
	cmp	byte [esi], '.'
464
	jnz	@b
465
	inc	esi
466
	mov	ecx, [esi]
467
	or	ecx, 0x202020
468
	cmp	ecx, 'jpg'
469
	jz	.copy
470
	cmp	ecx, 'bmp'
471
	jz	.copy
472
	cmp	ecx, 'gif'
473
	jz	.copy
474
	cmp	ecx, 'png'
475
	jz	.copy
476
	cmp	ecx, 'jpe'
477
	jz	.copy
478
	cmp	ecx, 'jpeg'
479
	jz	@f
480
	cmp	ecx, 'jpeG'
481
	jnz	.nocopy
482
@@:
483
	cmp	byte [esi+4], 0
484
	jnz	.nocopy
485
.copy:
486
	mov	esi, [esp]
487
	mov	ecx, 304 / 4
488
	rep	movsd
489
	inc	dword [esp+4]
490
.nocopy:
491
.noext:
492
	pop	eax
493
	add	eax, 304
494
	dec	ebx
495
	jnz	.dirskip
496
	mov	eax, [directory_ptr]
497
	pop	ebx
498
	mov	[eax+4], ebx
499
	test	ebx, ebx
500
	jz	free_directory
501
	push	0	; sort mode
502
	push	ebx
503
	add	eax, 32
504
	push	eax
505
	call	[SortDir]
506
	xor	eax, eax
507
	mov	edi, [directory_ptr]
508
	add	edi, 32 + 40
509
.scan:
510
	mov	esi, [last_name_component]
511
	inc	esi
512
	push	edi
513
	invoke	strcmpi
514
	pop	edi
515
	jz	.found
516
	inc	eax
517
	add	edi, 304
518
	dec	ebx
519
	jnz	.scan
520
	or	eax, -1
521
.found:
522
	mov	[cur_file_idx], eax
523
.ret:
524
	ret
525
 
526
free_directory:
527
	mcall	68, 13, [directory_ptr]
528
	and	[directory_ptr], 0
529
	ret
530
 
1004 diamond 531
draw_window:
1040 diamond 532
	cmp	[bFirstDraw], 0
533
	jz	.posok
534
	or	ecx, -1
535
	mcall	9, procinfo
536
 
537
	cmp	dword [ebx + 66], 0
538
	jle	.noredraw
539
 
540
	mov	edx, ecx
541
	mov	esi, ecx
542
	cmp	dword [ebx + 42], 40 + 25 * 9
543
	jae	@f
544
	mov	edx, 40 + 25 * 9
545
@@:
546
	cmp	dword [ebx + 46], 70
547
	jae	@f
548
	mov	esi, 70
549
@@:
550
	mov	eax, edx
551
	and	eax, esi
552
	cmp	eax, -1
553
	jz	@f
554
	mov	ebx, ecx
555
	mcall	67
556
@@:
557
 
558
.posok:
559
	mcall	12, 1
1004 diamond 560
	mcall	48, 4
561
	mov	ebp, eax	; save skin height
562
	add	eax, [wnd_height]
563
	__mov	ebx, 100, 0
564
	add	ebx, [wnd_width]
565
	lea	ecx, [100*65536 + eax]
566
	mcall	0, , , 0x73FFFFFF, , s_header
567
 
568
	mcall	9, procinfo, -1
1040 diamond 569
	mov	[bFirstDraw], 1
1016 diamond 570
	mov	ebx, [procinfo + 62]
571
	inc	ebx
1004 diamond 572
	mcall	13, , <0, 35>, 0xFFFFFF
1016 diamond 573
	mov	ecx, [procinfo + 66]
1040 diamond 574
	inc	ecx
575
	mov	esi, [draw_height]
576
	add	esi, 35
577
	sub	ecx, esi
578
	jbe	@f
579
	push	esi
580
	shl	esi, 16
581
	add	ecx, esi
582
	pop	esi
1004 diamond 583
	mcall
1040 diamond 584
	xor	ecx, ecx
585
@@:
586
	add	ecx, esi
587
	add	ecx, 35*10000h - 35
588
	__mov	ebx, 0, 5
1004 diamond 589
	mcall
1040 diamond 590
	mov	esi, [draw_width]
591
	add	esi, ebx
592
	mov	ebx, [procinfo+62]
593
	inc	ebx
1004 diamond 594
	sub	ebx, esi
1040 diamond 595
	jbe	@f
596
	shl	esi, 16
1004 diamond 597
	add	ebx, esi
598
	mcall
1040 diamond 599
@@:
1004 diamond 600
 
1016 diamond 601
	mov	ebx, [procinfo + 62]
602
	push	ebx
603
	mcall	38, , <30, 30>, 0x007F7F7F
604
	mcall	, <5 + 25 * 1, 5 + 25 * 1>, <0, 30>
605
	mcall	, <10 + 25 * 3, 10 + 25 * 3>
606
	mcall	, <15 + 25 * 4, 15 + 25 * 4>
607
	pop	ebx
608
	sub	ebx, 25 * 5 + 10
609
	push	ebx
610
	imul	ebx, 10001h
611
	mcall
1004 diamond 612
 
613
	mcall	8, <5 + 25 * 0, 20>, <5, 20>, 'opn'+40000000h
1016 diamond 614
	mcall	, <10 + 25 * 1, 20>, , 'bck'+40000000h
615
	mcall	, <10 + 25 * 2, 20>, , 'fwd'+40000000h
616
	mcall	, <15 + 25 * 3, 20>, , 'bgr'+40000000h
617
	pop	ebx
618
	add	ebx, 5
619
	shl	ebx, 16
620
	mov	bl, 20
621
	mcall	, , , 'flh'+40000000h
622
	add	ebx, 25 * 65536
623
	mcall	, , , 'flv'+40000000h
624
	add	ebx, 30 * 65536
625
	mcall	, , , 'rtr'+40000000h
626
	add	ebx, 25 * 65536
627
	mcall	, , , 'rtl'+40000000h
628
	add	ebx, 25 * 65536
629
	mcall	, , , 'flb'+40000000h
1004 diamond 630
 
1016 diamond 631
	mov	ebp, (numimages-1)*20
1004 diamond 632
 
1016 diamond 633
	mcall	65, buttons+openbtn*20, <20, 20>, <5 + 25 * 0, 5>, 8, palette
634
	mcall	, buttons+backbtn*20, , <10 + 25 * 1, 5>
635
	mcall	, buttons+forwardbtn*20, , <10 + 25 * 2, 5>
636
	mcall	, buttons+bgrbtn*20, , <15 + 25 * 3, 5>
637
	mov	edx, [procinfo + 62]
638
	sub	edx, 25 * 5 + 4
639
	shl	edx, 16
640
	mov	dl, 5
641
	mcall	, buttons+fliphorzbtn*20
642
	add	edx, 25 * 65536
643
	mcall	, buttons+flipvertbtn*20
644
	add	edx, 30 * 65536
645
	mcall	, buttons+rotcwbtn*20
646
	add	edx, 25 * 65536
647
	mcall	, buttons+rotccwbtn*20
648
	add	edx, 25 * 65536
649
	mcall	, buttons+rot180btn*20
1004 diamond 650
 
651
	mov	ebx, [image]
1040 diamond 652
	mov	ecx, [procinfo+62]
653
	sub	ecx, 4
654
	mov	ebp, [ebx + Image.Width]
655
	cmp	ecx, ebp
656
	jb	@f
657
	mov	ecx, ebp
658
@@:
659
	sub	ebp, ecx
660
	mov	edx, [procinfo+66]
661
	sub	edx, 34
662
	cmp	edx, [ebx + Image.Height]
663
	jb	@f
664
	mov	edx, [ebx + Image.Height]
665
@@:
1004 diamond 666
	shl	ecx, 16
1040 diamond 667
	add	ecx, edx
1004 diamond 668
	__mov	edx, 5, 35
669
	mov	esi, 8
670
	cmp	[ebx + Image.Type], Image.bpp8
1040 diamond 671
	jz	.bpp8
1004 diamond 672
	cmp	[ebx + Image.Type], Image.bpp24
1040 diamond 673
	jz	.bpp24
1004 diamond 674
	mov	esi, 32
1040 diamond 675
	shl	ebp, 2
676
	jmp	@f
677
.bpp24:
678
	mov	esi, 24
679
	lea	ebp, [ebp*3]
680
.bpp8:
1004 diamond 681
@@:
682
	mov	edi, [ebx + Image.Palette]
683
	mov	ebx, [ebx + Image.Data]
684
	mcall	65
685
 
1040 diamond 686
	mcall	12, 2
687
 
688
.noredraw:
1004 diamond 689
	ret
690
 
691
; void* __stdcall mem.Alloc(unsigned size);
692
mem.Alloc:
693
	push	ebx ecx
694
	mov	ecx, [esp+12]
695
	mcall	68, 12
696
	pop	ecx ebx
697
	ret	4
698
 
699
; void* __stdcall mem.ReAlloc(void* mptr, unsigned size);
700
mem.ReAlloc:
701
	push	ebx ecx edx
702
	mov	edx, [esp+16]
703
	mov	ecx, [esp+20]
704
	mcall	68, 20
705
	pop	edx ecx ebx
706
	ret	8
707
 
708
; void __stdcall mem.Free(void* mptr);
709
mem.Free:
710
	push	ebx ecx
711
	mov	ecx, [esp+12]
712
	mcall	68, 13
713
	pop	ecx ebx
714
	ret	4
715
 
716
;-----------------------------------------------------------------------------
717
 
718
s_header db 'Kolibri Image Viewer', 0
719
 
720
;-----------------------------------------------------------------------------
721
 
722
opendialog:
723
;
724
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
725
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
726
;
727
 
728
;;    mov esi,path
729
    mov edi,path
730
    xor eax,eax
731
    mov ecx,(1024+16)/4
732
    rep stosd
733
 
734
;mov [get_loops],0
735
mov [dlg_pid_get],0
736
 
737
; Get my PID in dec format 4 bytes
738
    mov eax,9
739
    mov ebx,procinfo
740
    or  ecx,-1
741
    mcall
742
 
743
; convert eax bin to param dec
744
    mov eax,dword [procinfo+30]  ;offset of myPID
745
    mov edi,param+4-1		 ;offset to 4 bytes
746
    mov ecx,4
747
    mov ebx,10
748
new_d:
749
    xor edx,edx
750
    div ebx
751
    add dl,'0'
752
    mov [edi],dl
753
    dec edi
754
    loop new_d
755
 
756
; wirite 1 byte space to param
757
    mov [param+4],byte 32    ;Space for next parametr
758
; and 1 byte type of dialog to param
759
    mov [param+5],byte 'O'   ;Get Open dialog (Use 'S' for Save dialog)
760
 
761
;
762
; STEP2 prepare IPC area for get messages
763
;
764
 
765
; prepare IPC area
766
    mov [path],dword 0
767
    mov [path+4],dword 8
768
 
769
; define IPC memory
770
    mov eax,60
771
    mov ebx,1	     ; define IPC
772
    mov ecx,path     ; offset of area
773
    mov edx,1024+16  ; size
774
    mcall
775
 
776
; change wanted events list 7-bit IPC event
777
    mov eax,40
778
    mov ebx,01000111b
779
	cmp	[image], 0
780
	jnz	@f
781
	mov	bl, 01000110b
782
@@:
783
    mcall
784
 
785
;
786
; STEP 3 run SYSTEM XTREE with parameters
787
;
788
 
789
    mov eax,70
790
    mov ebx,run_fileinfo
791
    mcall
792
 
793
    mov [get_loops],0
794
getmesloop:
795
    mov eax,23
796
    mov ebx,50	   ;0.5 sec
797
    mcall
798
        dec     eax
799
        jz      mred
800
        dec     eax
801
        jz      mkey
802
        dec     eax
803
        jz      mbutton
804
        cmp     al, 7-3
805
        jz      mgetmes
806
 
807
; Get number of procces
808
    mov ebx,procinfo
809
    mov ecx,-1
810
    mov eax,9
811
    mcall
812
    mov ebp,eax
813
 
814
loox:
815
    mov eax,9
816
    mov ebx,procinfo
817
    mov ecx,ebp
818
    mcall
819
    mov eax,[DLGPID]
820
    cmp [procinfo+30],eax    ;IF Dialog find
821
    je	dlg_is_work	     ;jmp to dlg_is_work
822
    dec ebp
823
    jnz loox
824
 
825
    jmp erroff
826
 
827
dlg_is_work:
828
    cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
829
    je	erroff		       ;TESTODP2 terminated too
830
 
831
    cmp [dlg_pid_get],dword 1
832
    je	getmesloop
833
    inc [get_loops]
834
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
835
    jae erroff
836
    jmp getmesloop
837
 
838
mred:
839
	cmp	[image], 0
840
	jz	getmesloop
841
    call draw_window
842
    jmp  getmesloop
843
mkey:
844
    mov  eax,2
845
    mcall			; read (eax=2)
846
    jmp  getmesloop
847
mbutton:
848
    mov  eax,17 		; get id
849
    mcall
850
    cmp  ah,1			; button id=1 ?
851
    jne  getmesloop
852
    mov  eax,-1 		; close this program
853
    mcall
854
mgetmes:
855
 
856
; If dlg_pid_get then second message get jmp to still
857
    cmp  [dlg_pid_get],dword 1
858
    je	 ready
859
 
860
; First message is number of PID SYSXTREE dialog
861
 
862
; convert PID dec to PID bin
863
    movzx eax,byte [path+16]
864
    sub eax,48
865
    imul eax,10
866
    movzx ebx,byte [path+16+1]
867
    add eax,ebx
868
    sub eax,48
869
    imul eax,10
870
    movzx ebx,byte [path+16+2]
871
    add eax,ebx
872
    sub eax,48
873
    imul eax,10
874
    movzx ebx,byte [path+16+3]
875
    add eax,ebx
876
    sub eax,48
877
    mov [DLGPID],eax
878
 
879
; Claear and prepare IPC area for next message
880
    mov [path],dword 0
881
    mov [path+4],dword 8
882
    mov [path+8],dword 0
883
    mov [path+12],dword 0
884
    mov [path+16],dword 0
885
 
886
; Set dlg_pid_get for get next message
887
    mov [dlg_pid_get],dword 1
888
	cmp	[image], 0
889
	jz	getmesloop
890
    call draw_window
891
    jmp  getmesloop
892
 
893
ready:
894
;
895
; The second message get
896
; Second message is 100 bytes path to SAVE/OPEN file
897
; shl path string on 16 bytes
898
;
899
    mov esi,path+16
900
    mov edi,path
901
    mov ecx,1024/4
902
    rep movsd
903
    mov [edi],byte 0
904
 
905
openoff:
906
	mcall	40, 7
907
	clc
908
	ret
909
 
910
erroff:
911
	mcall	40, 7
912
	stc
913
	ret
914
 
915
;-----------------------------------------------------------------------------
916
 
917
align 4
918
@IMPORT:
919
 
920
library 			\
921
	libio  , 'libio.obj'  , \
922
	libgfx , 'libgfx.obj' , \
1016 diamond 923
	libimg , 'libimg.obj' , \
924
	sort   , 'sort.obj'
1004 diamond 925
 
926
import	libio			  , \
927
	libio.init , 'lib_init'   , \
928
	file.size  , 'file.size'  , \
929
	file.open  , 'file.open'  , \
930
	file.read  , 'file.read'  , \
931
	file.close , 'file.close'
932
 
933
import	libgfx				, \
934
	libgfx.init   , 'lib_init'	, \
935
	gfx.open      , 'gfx.open'	, \
936
	gfx.close     , 'gfx.close'	, \
937
	gfx.pen.color , 'gfx.pen.color' , \
938
	gfx.line      , 'gfx.line'
939
 
940
import	libimg			   , \
941
	libimg.init , 'lib_init'   , \
942
	img.is_img  , 'img.is_img' , \
943
	img.to_rgb2 , 'img.to_rgb2', \
944
	img.decode  , 'img.decode' , \
945
	img.flip    , 'img.flip'   , \
946
	img.rotate  , 'img.rotate' , \
947
	img.destroy , 'img.destroy'
948
 
1016 diamond 949
import  sort, sort.START, 'START', SortDir, 'SortDir', strcmpi, 'strcmpi'
950
 
1040 diamond 951
bFirstDraw	db	0
1004 diamond 952
;-----------------------------------------------------------------------------
953
 
1016 diamond 954
virtual at 0
955
file 'kivicons.bmp':0xA,4
956
load offbits dword from 0
957
end virtual
958
numimages = 9
959
openbtn = 0
960
backbtn = 1
961
forwardbtn = 2
962
bgrbtn = 3
963
fliphorzbtn = 4
964
flipvertbtn = 5
965
rotcwbtn = 6
966
rotccwbtn = 7
967
rot180btn = 8
968
 
1004 diamond 969
palette:
1016 diamond 970
	file 'kivicons.bmp':0x36,offbits-0x36
971
buttons:
972
	file 'kivicons.bmp':offbits
1004 diamond 973
repeat 10
974
y = % - 1
975
z = 20 - %
1016 diamond 976
repeat numimages*5
977
load a dword from $ - numimages*20*20 + numimages*20*y + (%-1)*4
978
load b dword from $ - numimages*20*20 + numimages*20*z + (%-1)*4
979
store dword a at $ - numimages*20*20 + numimages*20*z + (%-1)*4
980
store dword b at $ - numimages*20*20 + numimages*20*y + (%-1)*4
1004 diamond 981
end repeat
982
end repeat
983
 
984
; DATA AREA
985
get_loops   dd 0
986
dlg_pid_get dd 0
987
DLGPID	    dd 0
988
 
989
param:
990
   dd 0    ; My dec PID
991
   dd 0,0  ; Type of dialog
992
 
993
run_fileinfo:
994
 dd 7
995
 dd 0
996
 dd param
997
 dd 0
998
 dd 0
999
;run_filepath
1000
 db '/sys/SYSXTREE',0
1001
 
1016 diamond 1002
readdir_fileinfo:
1003
	dd	1
1004
	dd	0
1005
	dd	0
1006
readblocks dd	0
1007
directory_ptr	dd	0
1008
 
1004 diamond 1009
;-----------------------------------------------------------------------------
1010
 
1011
I_END:
1012
 
1016 diamond 1013
curdir		rb	1024
1014
 
1015
align 4
1004 diamond 1016
img_data     dd ?
1017
img_data_len dd ?
1018
fh	     dd ?
1019
image	     dd ?
1020
wnd_width	dd	?
1021
wnd_height	dd	?
1040 diamond 1022
draw_width	dd	?
1023
draw_height	dd	?
1016 diamond 1024
last_name_component	dd	?
1025
cur_file_idx	dd	?
1004 diamond 1026
 
1027
ctx dd ?
1028
 
1029
procinfo:	rb	1024
1030
path:		rb	1024+16
1031
 
1032
@PARAMS rb 512