Subversion Repositories Kolibri OS

Rev

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