Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
31 halyavin 1
;   Picture browser by lisovin@26.ru
2
;   Modified by Ivan Poddubny - v.0.3
190 diamond 3
;   Modified by Diamond - v.0.4
828 mario79 4
;   Modified by Mario79:
5
;      v.0.5  18.07.08 Dinamic Allocation Memory
6
;      v.0.6  20.07.08
7
;             1) Use Editbox (Author )
8
;             2) Draw window without fill working area (C = 1)
9
;             3) Open file with parameter in patch:
832 mario79 10
;                Size of parameter - 4 bytes. Parameter starts with the
11
;                character "\", the unused characters are filled
12
;                by a blank (ASCII 20h).
13
;                '\T  /hd0/1/1.bmp' - set background, mode: tile
14
;                '\S  /hd0/1/1.bmp' - set background, mode: stretch
15
;      v.0.65  23.07.08
16
;             1) Use new version Editbox (Thanks )
17
;                (mouse correctly works in secondary thread)
18
;             2) The memory used for storage of the file BMP
19
;                after conversion in RAW comes back to OS.
20
;             3) Usage of keys 1,2,3,4 for call of buttons of the application
21
;                without the mouse, before the key were defined incorrectly.
22
;             4) Deleting of the unnecessary procedure of clearing of
23
;                a background of a picture at pressing the button "Open".
31 halyavin 24
;   Compile with FASM for Menuet
25
 
26
;******************************************************************************
27
    use32
28
    org    0x0
825 mario79 29
    db	   'MENUET01'		   ; 8 byte id
30
    dd	   0x01 		   ; header version
31
    dd	   START		   ; start of code
32
    dd	   IM_END		   ; size of image
832 mario79 33
    dd	   I_END       ; memory for app
34
    dd	   I_END       ; esp
825 mario79 35
    dd	   temp_area , 0x0	   ; I_Param , I_Icon
132 diamond 36
 
31 halyavin 37
include    'lang.inc'
485 heavyiron 38
include    '..\..\..\macros.inc'
832 mario79 39
include    '..\..\..\develop\examples\editbox\trunk\editbox.inc'
825 mario79 40
;include    'macros.inc'
832 mario79 41
;include    'EDITBOX.INC'
42
use_edit_box
31 halyavin 43
;******************************************************************************
44
 
825 mario79 45
START:				; start of execution
46
	mcall	68, 11
832 mario79 47
	mcall	66, 1,1
31 halyavin 48
; check for parameters
825 mario79 49
   cmp	 dword [temp_area],'BOOT'
50
   jne	 .no_boot
828 mario79 51
.background:
31 halyavin 52
   call  load_image
53
   call  convert
828 mario79 54
 
31 halyavin 55
   call  background
828 mario79 56
.exit:
825 mario79 57
   or	 eax,-1
485 heavyiron 58
   mcall
31 halyavin 59
 .no_boot:
60
 
825 mario79 61
   cmp	 byte [temp_area],0
62
   jz	 .no_param
828 mario79 63
 
64
 
825 mario79 65
   mov	 edi,string	 ; clear string
66
   mov	 ecx,256/4	 ;   length of a string
67
   xor	 eax,eax	 ;   symbol <0>
68
   rep	 stosd
31 halyavin 69
 
828 mario79 70
 
825 mario79 71
   mov	 edi,temp_area	 ; look for <0> in temp_area
828 mario79 72
 
73
   cmp	 [edi],byte "\"
74
   jne	 .continue
75
   cmp	 [edi+1],byte "T"
76
   jne	 @f
77
   mov	 [bgrmode],dword 1
78
   jmp	 .continue_1
79
@@:
80
   cmp	 [edi+1],byte "S"
81
   jne	 START.exit
82
   mov	 [bgrmode],dword 2
83
.continue_1:
84
   add	 edi,4
85
.continue:
825 mario79 86
   mov	 esi,edi
87
   mov	 ecx,257	 ;   strlen
31 halyavin 88
   repne scasb
825 mario79 89
	lea	ecx, [edi-temp_area]
31 halyavin 90
 
825 mario79 91
   mov	 edi,string
92
   rep	 movsb		 ; copy string from temp_area to "string" (filename)
828 mario79 93
   cmp	 [temp_area],byte "\"
94
   je	 START.background
132 diamond 95
   call  load_image
96
   call  convert
97
 
31 halyavin 98
 .no_param:
99
 
100
 
825 mario79 101
   or  ecx,-1		; get information about me
31 halyavin 102
   call getappinfo
103
 
825 mario79 104
   mov	edx,[process_info+30] ; теперь в edx наш идентификатор
105
   mov	ecx,eax
31 halyavin 106
 
107
  @@:
108
   call getappinfo
825 mario79 109
   cmp	edx,[process_info+30]
110
   je	@f  ; если наш PID совпал с PID рассматриваемого процесса, мы нашли себя
111
   dec	ecx ; иначе смотрим следующий процесс
112
   jne	@b  ; возвращаемся, если не все процессы рассмотрены
31 halyavin 113
  @@:
114
 
115
; теперь в ecx номер процесса
116
    mov  [process],ecx
117
 
135 diamond 118
draw_still:
31 halyavin 119
    call draw_window
120
 
121
still:
122
 
825 mario79 123
    mov  eax,10 		; wait here for event
485 heavyiron 124
    mcall
31 halyavin 125
 
825 mario79 126
	dec	eax
127
	jz	red
128
	dec	eax
129
	jnz	button
31 halyavin 130
 
825 mario79 131
  key:				; key
135 diamond 132
    mov  al,2
485 heavyiron 133
    mcall
135 diamond 134
    mov  al,ah
832 mario79 135
    cmp  al,130  ; 1
825 mario79 136
    je	 kfile
832 mario79 137
    cmp  al,131  ; 2
825 mario79 138
    je	 kopen
832 mario79 139
    cmp  al,132  ; 3
825 mario79 140
    je	 kinfo
832 mario79 141
    cmp  al,133  ; 4
825 mario79 142
    je	 kbgrd
31 halyavin 143
    jmp  still
144
 
135 diamond 145
  red:
825 mario79 146
	test	byte [status], 4
147
	jz	draw_still
148
	mov	al, 18
149
	mov	ebx, 3
150
	mov	ecx, [process]
151
	mcall
152
	and	byte [status], not 4
153
	jmp	still
135 diamond 154
 
825 mario79 155
  button:			; button
156
    mov  eax,17 		; get id
485 heavyiron 157
    mcall
31 halyavin 158
 
825 mario79 159
    cmp  ah,1			; button id=1 ?
31 halyavin 160
    jne  noclose
161
 
825 mario79 162
    mov  eax,-1 		; close this program
485 heavyiron 163
    mcall
31 halyavin 164
  noclose:
165
    cmp  ah,2
166
    jne  nofile
167
  kfile:
825 mario79 168
	test	byte [status], 1
169
	jnz	still
170
	or	byte [status], 1
31 halyavin 171
    mov  eax,51
172
    mov  ebx,1
173
    mov  ecx,thread1
825 mario79 174
    mov  edx,thread   ;0x29fff0
485 heavyiron 175
    mcall
31 halyavin 176
    jmp  still
177
  nofile:
178
    cmp  ah,3
179
    jne  noopen
180
 
181
 kopen:
182
    mov ecx,-1
183
    call getappinfo
184
 
185
    call load_image
186
 
187
  open1:
825 mario79 188
    mov eax,[image_file]
189
    cmp [eax],word 'BM'
31 halyavin 190
    jne  still
191
    call convert
832 mario79 192
    jmp  draw_still
31 halyavin 193
  noopen:
194
 
195
    cmp  ah,4
196
    jne  noinfo
197
  kinfo:
825 mario79 198
	test	byte [status], 2
199
	jnz	still
200
	or	byte [status], 2
31 halyavin 201
    mov  eax,51
202
    mov  ebx,1
203
    mov  ecx,thread2
832 mario79 204
    mov  edx,thread-512
485 heavyiron 205
    mcall
31 halyavin 206
    jmp  still
207
  noinfo:
208
 
209
; УСТАНОВИТЬ ФОН
210
    cmp  ah,5
211
    jne  still
212
  kbgrd:
825 mario79 213
	test	byte [status], 8
214
	jnz	still
215
	or	byte [status], 8
31 halyavin 216
    mov  eax,51
217
    mov  ebx,1
218
    mov  ecx,thread3
832 mario79 219
    mov  edx,thread-512*2
485 heavyiron 220
    mcall
31 halyavin 221
    jmp  still
222
    ;call background
223
 
224
 getappinfo:
225
    mov  eax,9
132 diamond 226
    mov  ebx,process_info
485 heavyiron 227
    mcall
31 halyavin 228
    ret
229
 
230
 
231
load_image:
828 mario79 232
 
825 mario79 233
	  mov	[fileinfo+0],dword 5
234
	  mov	[fileinfo+12],dword 0
235
	  mov	[fileinfo+16],dword process_info
236
 
237
    cmp  [image_file],0
238
    je	  @f
239
    mov   ecx,[image_file]
240
     mcall 68, 13,
241
 
190 diamond 242
@@:
825 mario79 243
	  mcall 70, fileinfo
244
 
245
	  mov	[fileinfo+0],dword 0
246
	  mov	[fileinfo+12],dword 512
247
	  mov	[fileinfo+16],dword process_info+40
248
 
249
	  mcall 70, fileinfo
250
 
251
	  mov	ecx,[process_info+32]
252
	  mov	[fileinfo+12],ecx
253
 
832 mario79 254
	  mcall 68, 12
255
 
256
 
257
	  mov	[fileinfo+16],eax
258
	  mov	[image_file_1],eax
259
 
825 mario79 260
    mov  eax,[process_info+40+28]
261
 
262
	cmp	eax, 24
263
	jz	.convert24
264
	cmp	eax, 8
265
	jz	.convert8
266
	cmp	eax, 4
267
	jz	.convert4
268
     shl  ecx,2
269
.convert4:
270
     shl  ecx,1
271
.convert8:
272
     lea  ecx,[ecx*3]
273
.convert24:
274
 
832 mario79 275
;@@:
276
 
277
    add   ecx,512
825 mario79 278
	  mcall 68, 12
279
 
280
	  mov	[image_file],eax
281
 
282
	  mcall 70, fileinfo
283
 
832 mario79 284
    mov   esi,[image_file_1]
285
    mov   edi,[image_file]
286
    mov   ecx,512/4
287
    cld
288
    rep  movsd
289
 
825 mario79 290
    mov  eax,[image_file]
291
    mov  ebx,[eax+22]
292
    mov  eax,[eax+18]
293
	test	ebx, ebx
294
	jns	@f
295
	neg	ebx
296
@@:
832 mario79 297
    add  eax,9
132 diamond 298
    cmp  eax,210
299
    jae  @f
300
    mov  eax,210
301
@@:
832 mario79 302
    add  ebx,54
132 diamond 303
    cmp  ebx,56
304
    jae  @f
305
    mov  ebx,56
306
@@:
307
    mov  [wnd_width],eax
308
    mov  [wnd_height],ebx
309
    test [bWasDraw],1
825 mario79 310
    jz	 @f
132 diamond 311
    mov  esi,ebx
312
    mov  edx,eax
825 mario79 313
    mcall 67,-1,-1
132 diamond 314
@@:
315
    ret
31 halyavin 316
 
317
 
318
  drawimage:
825 mario79 319
    mov  eax,[image_file]
320
    cmp  [eax],word 'BM'
31 halyavin 321
    jne  nodrawimage
825 mario79 322
	mov	ecx, dword [eax+18-2]
323
	mov	cx, [eax+22]
324
	test	cx, cx
325
	jns	@f
326
	neg	cx
190 diamond 327
@@:
828 mario79 328
    mov  edx,5*65536+50
825 mario79 329
    mcall 7,[soi]
31 halyavin 330
  nodrawimage:
331
    ret
332
 
333
; УСТАНОВИТЬ ФОН
334
  background:
825 mario79 335
    mov  eax,[image_file]
336
    cmp  [eax],word 'BM'
31 halyavin 337
    jne  @f
825 mario79 338
    mov  ecx,[eax+18] ; ширина
339
    mov  edx,[eax+22] ; высота
340
    mcall 15,1
31 halyavin 341
 
342
    mov  esi, ecx
343
    imul esi, edx
825 mario79 344
	lea	esi, [esi+esi*2]
31 halyavin 345
    mov  ebx,5
346
    mov  ecx,[soi]
347
    xor  edx,edx
348
;;;    mov  esi, ;640*480*3
485 heavyiron 349
    mcall
31 halyavin 350
 
825 mario79 351
    dec  ebx	;tile/stretch
31 halyavin 352
    mov  ecx,dword [bgrmode]
485 heavyiron 353
    mcall
31 halyavin 354
 
355
    dec  ebx
485 heavyiron 356
    mcall
31 halyavin 357
   @@:
358
    ret
359
 
190 diamond 360
convert:
832 mario79 361
    call  convert_1
362
    mov   ecx,[image_file_1]
363
    mcall 68, 13,
364
    ret
365
convert_1:
366
	mov	ecx, [image_file]
367
  add ecx,512
825 mario79 368
	mov	[soi], ecx
832 mario79 369
	mov	eax,[image_file_1]
825 mario79 370
	mov	ebp, [eax+18]
371
	lea	ebp, [ebp*3]	; ebp = size of output scanline
372
	mov	eax, [eax+22]
373
	dec	eax
374
	mul	ebp
375
	add	eax, ecx
376
	mov	edi, eax	; edi points to last scanline
832 mario79 377
	mov	esi, [image_file_1]
825 mario79 378
	add	esi, [esi+10]
832 mario79 379
	mov	ebx,[image_file_1]
825 mario79 380
	mov	edx, [ebx+22]
381
	add	ebx,54
382
	lea	eax, [ebp*2]
383
	mov	[delta], eax
384
	test	edx, edx
385
	jz	.ret
386
	jns	@f
387
	neg	edx
388
	and	[delta], 0
389
	mov	edi, ecx
190 diamond 390
@@:
832 mario79 391
	mov	eax,[image_file_1]
825 mario79 392
	movzx	eax,word [eax+28]
393
	cmp	eax, 24
394
	jz	convert24
395
	cmp	eax, 8
396
	jz	convert8
397
	cmp	eax, 4
398
	jz	convert4
399
	dec	eax
400
	jz	convert1
190 diamond 401
.ret:
825 mario79 402
	ret
190 diamond 403
convert24:
825 mario79 404
	mov	ecx, ebp
405
	rep	movsb
406
	sub	edi, [delta]
407
	mov	eax, ebp
408
	neg	eax
409
	and	eax, 3
410
	add	esi, eax
411
	dec	edx
412
	jnz	convert24
413
	ret
190 diamond 414
convert8:
825 mario79 415
	push	edi
416
	add	[esp], ebp
190 diamond 417
.loopi:
825 mario79 418
	xor	eax, eax
419
	lodsb
420
	push	eax
832 mario79 421
	mov	eax,[image_file_1]
825 mario79 422
	cmp	dword [eax+30],1
423
	pop	eax
424
	jnz	.nocompressed
190 diamond 425
.compressed:
825 mario79 426
	mov	ecx, eax
427
	jecxz	.special
428
	lodsb
429
	mov	eax, [ebx+eax*4]
190 diamond 430
@@:
825 mario79 431
	call	putpixel
432
	loop	@b
433
	jmp	.loopi
190 diamond 434
.nocompressed:
825 mario79 435
	mov	eax, [ebx+eax*4]
436
	call	putpixel
190 diamond 437
.loopicont:
825 mario79 438
	cmp	edi, [esp]
439
	jnz	.loopi
190 diamond 440
.next:
825 mario79 441
	pop	edi
442
	sub	edi, [delta]
443
	mov	eax, ebp
444
	and	eax, 3
445
	add	esi, eax
446
	dec	edx
447
	jnz	convert8
448
	ret
190 diamond 449
.special:
825 mario79 450
	lodsb
451
	test	al, al
452
	jz	.next
453
	cmp	al, 2
454
	jbe	.end
455
	mov	ecx, eax
456
	push	ecx
190 diamond 457
@@:
825 mario79 458
	xor	eax, eax
459
	lodsb
460
	mov	eax, [ebx+eax*4]
461
	call	putpixel
462
	loop	@b
463
	pop	ecx
464
	and	ecx, 1
465
	add	esi, ecx
466
	jmp	.loopi
190 diamond 467
.end:
825 mario79 468
	pop	edi
469
	ret
190 diamond 470
convert4:
825 mario79 471
	push	edi
472
	add	[esp], ebp
190 diamond 473
.loopi:
825 mario79 474
	xor	eax, eax
475
	lodsb
476
	shr	eax, 4
477
	mov	eax, [ebx+eax*4]
478
	call	putpixel
479
	cmp	edi, [esp]
480
	jz	.loopidone
481
	mov	al, [esi-1]
482
	and	eax, 0xF
483
	mov	eax, [ebx+eax*4]
484
	stosd
485
	dec	edi
486
	cmp	edi, [esp]
487
	jnz	.loopi
190 diamond 488
.loopidone:
825 mario79 489
	pop	edi
490
	sub	edi, [delta]
491
	call	align_input
492
	dec	edx
493
	jnz	convert4
494
	ret
190 diamond 495
convert1:
825 mario79 496
	push	edi
497
	add	[esp], ebp
190 diamond 498
.loopi:
825 mario79 499
	lodsb
500
	mov	ecx, 8
190 diamond 501
.loopii:
825 mario79 502
	add	al, al
503
	push	eax
504
	setc	al
505
	movzx	eax, al
506
	mov	eax, [ebx+eax*4]
507
	call	putpixel
508
	pop	eax
509
	cmp	edi, [esp]
510
	loopnz	.loopii
511
	jnz	.loopi
512
	pop	edi
513
	sub	edi, [delta]
514
	call	align_input
515
	dec	edx
516
	jnz	convert1
517
	ret
31 halyavin 518
 
190 diamond 519
align_input:
825 mario79 520
	push	esi
521
	push	eax
832 mario79 522
	mov	eax,[image_file_1]
523
	sub	esi,eax
825 mario79 524
	sub	esi,[eax+10]
525
	pop	eax
526
	neg	esi
527
	and	esi, 3
528
	add	[esp], esi
529
	pop	esi
530
	ret
31 halyavin 531
 
190 diamond 532
putpixel:
825 mario79 533
	push	eax
534
	stosw
535
	shr	eax, 16
536
	stosb
537
	pop	eax
538
	ret
31 halyavin 539
 
828 mario79 540
;---------------------------------------------------------------------
541
get_window_param:
542
    mcall 9, procinfo, -1
543
    mov   eax,[ebx+46]
544
    mov   [window_high],eax
545
    mov   eax,[ebx+42]
546
    mov   [window_width],eax
547
    mcall 48,4
548
    mov   [skin_high],eax
549
    ret
550
;---------------------------------------------------------------------
551
 
31 halyavin 552
;   *********************************************
553
;   *******  WINDOW DEFINITIONS AND DRAW ********
554
;   *********************************************
555
 
556
 
557
draw_window:
825 mario79 558
    or	 [bWasDraw],1
31 halyavin 559
 
825 mario79 560
    mov  eax,12 		   ; function 12:tell os about windowdraw
561
    mov  ebx,1			   ; 1, start of draw
485 heavyiron 562
    mcall
31 halyavin 563
 
825 mario79 564
				   ; DRAW WINDOW
565
    xor  eax,eax		   ; function 0 : define and draw window
132 diamond 566
;    mov  ebx,350                   ; [x start] *65536 + [x size]
567
;    mov  ecx,400                   ; [y start] *65536 + [y size]
825 mario79 568
    mov  ebx,0*65536
569
    mov  ecx,0*65536
132 diamond 570
    add  ebx,[wnd_width]
571
    add  ecx,[wnd_height]
832 mario79 572
    cmp  cx,55
573
    ja	 @f
574
    mov  cx,55
575
@@:
828 mario79 576
    mov  edx,0x43ffffff 	   ; color of work area RRGGBB,8->color gl
485 heavyiron 577
    mcall
31 halyavin 578
 
828 mario79 579
    call get_window_param
580
 
581
    mov   ebx,5
582
    shl   ebx,16
583
    add   ebx,[window_width]
584
    sub   ebx,9
585
    push  ebx
586
    mov   ecx,[skin_high]
587
    shl   ecx,16
588
    add   ecx,50
589
    sub   ecx,[skin_high]
590
    mcall 13, , ,0xffffff
591
    mov  eax,[image_file]
592
    mov  ecx,[eax+22]
593
    mov  ebx,[eax+18]
594
    push ecx
595
    add  ebx,5
596
    mov  ax,bx
597
    shl  ebx,16
598
    add  ebx,[window_width]
599
    sub  ebx,4
600
    sub  bx,ax
601
    cmp  bx,0
832 mario79 602
    jbe  @f
828 mario79 603
    add  ecx,50 shl 16
604
    mcall 13, , ,0xffffff
605
@@:
606
    pop  ecx
607
    pop  ebx
608
    add  ecx,50
609
    mov  ax,cx
610
    shl  ecx,16
611
    add  ecx,[window_high]
612
    sub  cx,ax
613
    sub  ecx,4
832 mario79 614
    cmp  cx,0
615
    jbe  @f
828 mario79 616
    mcall 13, , ,0xffffff
617
@@:
31 halyavin 618
    mov  eax,8
619
    mov  ebx,10*65536+46
620
    mov  ecx,25*65536+20
621
    mov  edx,2
622
    mov  esi,0x780078
623
  newbutton:
485 heavyiron 624
    mcall
31 halyavin 625
    add  ebx,48*65536
626
    inc  edx
627
    cmp  edx,6
825 mario79 628
    jb	 newbutton
31 halyavin 629
 
825 mario79 630
				   ; WINDOW LABEL
631
    mov  eax,4			   ; function 4 : write text to window
632
    mov  ebx,8*65536+8		   ; [x start] *65536 + [y start]
633
    mov  ecx,0x10ddeeff 	   ; font 1 & color ( 0xF0RRGGBB )
634
    mov  edx,labelt		   ; pointer to text beginning
635
    mov  esi,12 		   ; text length
485 heavyiron 636
    mcall
31 halyavin 637
 
638
    mov  ebx,14*65536+32
639
    mov  edx,buttext
640
    mov  esi,26
485 heavyiron 641
    mcall
31 halyavin 642
 
643
    call drawimage
644
 
825 mario79 645
    mov  eax,12 		   ; function 12:tell os about windowdraw
646
    mov  ebx,2			   ; 2, end of draw
485 heavyiron 647
    mcall
31 halyavin 648
 
649
    ret
650
 
651
 
652
; DATA AREA
653
 
654
labelt:
825 mario79 655
	 db 'MeView v.0.4'
31 halyavin 656
 
657
lsz buttext,\
658
    en,   ' FILE   OPEN   INFO   BGRD',\
135 diamond 659
    ru,   ' ФАЙЛ  ОТКР   ИНФО   ФОН  ',\
660
    de,   'DATEI OEFNEN  INFO   HGRD'
31 halyavin 661
 
825 mario79 662
thread1:			; start of thread1
31 halyavin 663
 
828 mario79 664
	  mcall 40, 0x27
31 halyavin 665
 
832 mario79 666
   or  ecx,-1		; get information about me
667
   call getappinfo
668
 
828 mario79 669
    mov  esi,string
670
@@:
671
    cld
672
    lodsb
673
    test al,al
674
    jne  @r
675
    sub  esi,string
676
    mov  eax,esi
677
    dec  eax
678
    mov edi, edit1
679
    mov ed_size, eax
680
    mov ed_pos, eax
681
red1:
682
    call draw_window1
683
 
31 halyavin 684
still1:
685
 
832 mario79 686
    mcall 10		; wait here for event
31 halyavin 687
 
825 mario79 688
    cmp  eax,1			; redraw request ?
828 mario79 689
    je	 red1
825 mario79 690
    cmp  eax,2			; key in buffer ?
691
    je	 key1
692
    cmp  eax,3			; button in buffer ?
693
    je	 button1
832 mario79 694
 
828 mario79 695
	  mouse_edit_box name_editboxes
31 halyavin 696
    jmp  still1
697
 
825 mario79 698
  key1: 			; key
828 mario79 699
    mcall 2
700
    cmp ah,13
701
    je	close1
702
    cmp ah,27
703
    je	close1
832 mario79 704
 
828 mario79 705
    key_edit_box name_editboxes
31 halyavin 706
    jmp  still1
707
 
825 mario79 708
  button1:			; button
709
    mov  eax,17 		; get id
485 heavyiron 710
    mcall
31 halyavin 711
 
825 mario79 712
    cmp  ah,1			; button id=1 ?
828 mario79 713
    jne  still1
31 halyavin 714
  close1:
715
    bts  dword [status],2
716
    btr  dword [status],0
825 mario79 717
    mov  eax,-1 		; close this program
485 heavyiron 718
    mcall
828 mario79 719
 
31 halyavin 720
    jmp  still1
721
 
722
;   *********************************************
723
;   *******  WINDOW DEFINITIONS AND DRAW ********
724
;   *********************************************
725
 
726
 
727
draw_window1:
728
 
729
 
825 mario79 730
    mov  eax,12 		   ; function 12:tell os about windowdraw
731
    mov  ebx,1			   ; 1, start of draw
485 heavyiron 732
    mcall
31 halyavin 733
 
825 mario79 734
				   ; DRAW WINDOW
735
    xor  eax,eax		   ; function 0 : define and draw window
736
    mov  ebx,100*65536+300	   ; [x start] *65536 + [x size]
737
    mov  ecx,100*65536+80	   ; [y start] *65536 + [y size]
738
    mov  edx,0x03780078 	   ; color of work area RRGGBB,8->color gl
485 heavyiron 739
    mcall
31 halyavin 740
 
825 mario79 741
				   ; WINDOW LABEL
742
    mov  eax,4			   ; function 4 : write text to window
743
    mov  ebx,8*65536+8		   ; [x start] *65536 + [y start]
744
    mov  ecx,0x10ddeeff 	   ; font 1 & color ( 0xF0RRGGBB )
745
    mov  edx,labelt1		   ; pointer to text beginning
746
    mov  esi,labelt1.size	   ; text length
485 heavyiron 747
    mcall
31 halyavin 748
 
828 mario79 749
;    call drawstring
750
	draw_edit_box name_editboxes
31 halyavin 751
 
825 mario79 752
    mov  eax,12 		   ; function 12:tell os about windowdraw
753
    mov  ebx,2			   ; 2, end of draw
485 heavyiron 754
    mcall
31 halyavin 755
 
756
    ret
757
 
758
 drawstring:
759
    pusha
825 mario79 760
    mov  eax,8		   ;invisible button
31 halyavin 761
    mov  ebx,21*65536+258
762
    mov  ecx,40*65536+15
132 diamond 763
    mov  edx,0x60000002
485 heavyiron 764
    mcall
31 halyavin 765
 
825 mario79 766
    mov  eax,13 	    ;bar
31 halyavin 767
    mov  edx,0xe0e0e0
485 heavyiron 768
    mcall
825 mario79 769
    push eax		    ;cursor
31 halyavin 770
    mov  eax,6*65536
771
    mul  dword [pos]
772
    add  eax,21*65536+6
773
    mov  ebx,eax
774
    pop  eax
775
    mov  edx,0x6a73d0
485 heavyiron 776
    mcall
825 mario79 777
    mov  eax,4		    ;path
31 halyavin 778
    mov  ebx,21*65536+44
779
    xor  ecx,ecx
780
    mov  edx,string
781
    mov  esi,43
485 heavyiron 782
    mcall
31 halyavin 783
 
784
 
785
    popa
786
    ret
787
 
788
; DATA AREA
789
 
790
lsz labelt1,\
825 mario79 791
   en,	'File',\
792
   ru,	'Файл',\
793
   de,	'Datei'
31 halyavin 794
 
825 mario79 795
thread2:			  ; start of info thread
31 halyavin 796
 
797
     call draw_window2
798
 
799
still2:
800
 
825 mario79 801
    mov  eax,10 		; wait here for event
485 heavyiron 802
    mcall
31 halyavin 803
 
825 mario79 804
    cmp  eax,1			; redraw request ?
805
    je	 thread2
806
    cmp  eax,2			; key in buffer ?
807
    je	 close2
808
    cmp  eax,3			; button in buffer ?
809
    je	 button2
31 halyavin 810
 
811
    jmp  still2
812
 
825 mario79 813
  button2:			 ; button
814
    mov  eax,17 		; get id
485 heavyiron 815
    mcall
31 halyavin 816
 
825 mario79 817
    cmp  ah,1			; button id=1 ?
31 halyavin 818
    jne  noclose2
819
  close2:
820
    btr dword [status],1
821
    bts dword [status],2
825 mario79 822
    mov  eax,-1 		; close this program
485 heavyiron 823
    mcall
31 halyavin 824
  noclose2:
825
 
826
    jmp  still2
827
 
828
 
829
 
830
 
831
;   *********************************************
832
;   *******  WINDOW DEFINITIONS AND DRAW ********
833
;   *********************************************
834
 
835
 
836
draw_window2:
837
 
838
 
825 mario79 839
    mov  eax,12 		   ; function 12:tell os about windowdraw
840
    mov  ebx,1			   ; 1, start of draw
485 heavyiron 841
    mcall
31 halyavin 842
 
825 mario79 843
				   ; DRAW WINDOW
844
    xor  eax,eax		   ; function 0 : define and draw window
845
    mov  ebx,100*65536+330	   ; [x start] *65536 + [x size]
846
    mov  ecx,100*65536+90	   ; [y start] *65536 + [y size]
847
    mov  edx,0x03780078 	   ; color of work area RRGGBB,8->color gl
485 heavyiron 848
    mcall
31 halyavin 849
 
825 mario79 850
				   ; WINDOW LABEL
851
    mov  eax,4			   ; function 4 : write text to window
852
    mov  ebx,8*65536+8		   ; [x start] *65536 + [y start]
853
    mov  ecx,0x10ddeeff 	   ; font 1 & color ( 0xF0RRGGBB )
854
    mov  edx,labelt2		   ; pointer to text beginning
855
    mov  esi,labelt2.size	   ; text length
485 heavyiron 856
    mcall
31 halyavin 857
 
858
    mov  ebx,10*65536+30
859
    mov  edx,string
860
    mov  esi,43
485 heavyiron 861
    mcall
31 halyavin 862
    mov  edx,fitext
863
    mov  esi,14
864
    add  ebx,70*65536+10
865
 followstring:
485 heavyiron 866
    mcall
31 halyavin 867
    add  ebx,10
868
    add  edx,esi
869
    cmp  ebx,80*65536+70
870
    jbe  followstring
871
    mov  eax,47
872
    mov  edx,200*65536+40
873
    mov  esi,ecx
825 mario79 874
    mov  ecx,[image_file]
875
    push ecx
876
    mov  ecx, [ecx+2]
31 halyavin 877
    call digitcorrect
485 heavyiron 878
    mcall
31 halyavin 879
    add  edx,10
825 mario79 880
    pop  ecx
881
    push ecx
882
    mov  ecx, [ecx+18]
31 halyavin 883
    call digitcorrect
485 heavyiron 884
    mcall
31 halyavin 885
    add  edx,10
825 mario79 886
    pop  ecx
887
    push ecx
888
    mov  ecx, [ecx+22]
31 halyavin 889
    call digitcorrect
485 heavyiron 890
    mcall
31 halyavin 891
    add  edx,10
825 mario79 892
    pop  ecx
893
    movzx ecx,word [ecx+28]
31 halyavin 894
    call digitcorrect
485 heavyiron 895
    mcall
31 halyavin 896
 
825 mario79 897
    mov  eax,12 		   ; function 12:tell os about windowdraw
898
    mov  ebx,2			   ; 2, end of draw
485 heavyiron 899
    mcall
31 halyavin 900
 
901
    ret
902
 
903
 digitcorrect:
904
    xor  ebx,ebx
905
    mov  bh,6
906
    cmp  ecx,99999
825 mario79 907
    ja	 c_end
31 halyavin 908
    dec  bh
909
    cmp  ecx,9999
825 mario79 910
    ja	 c_end
31 halyavin 911
    dec  bh
912
    cmp  ecx,999
825 mario79 913
    ja	 c_end
31 halyavin 914
    dec  bh
915
    cmp  ecx,99
825 mario79 916
    ja	 c_end
31 halyavin 917
    dec  bh
918
    cmp  ecx,9
825 mario79 919
    ja	 c_end
31 halyavin 920
    dec  bh
921
 c_end:
922
    bswap ebx
923
    ret
924
 
925
 
926
; DATA AREA
927
 
928
lsz labelt2,\
929
    en,   'File info',\
135 diamond 930
    ru,   'Информация о файле',\
931
    de,   'Dateiinfo'
31 halyavin 932
 
933
lsz fitext,\
934
     en, 'FILE SIZE     ',\
935
     en, 'X SIZE        ',\
936
     en, 'Y SIZE        ',\
937
     en, 'BITS PER PIXEL',\
825 mario79 938
			  \
31 halyavin 939
     ru, 'Размер файла  ',\
940
     ru, 'Ширина        ',\
941
     ru, 'Высота        ',\
135 diamond 942
     ru, 'Бит на пиксел ',\
825 mario79 943
			  \
135 diamond 944
     de, 'FATEIGROESSE  ',\
945
     de, 'X GROESSE     ',\
946
     de, 'Y GROESSE     ',\
947
     de, 'BITS PER PIXEL'
31 halyavin 948
 
825 mario79 949
thread3:			  ; start of bgrd thread
31 halyavin 950
 
951
     call draw_window3
952
 
953
still3:
954
 
825 mario79 955
    mov  eax,10 		; wait here for event
485 heavyiron 956
    mcall
31 halyavin 957
 
825 mario79 958
    cmp  eax,1			; redraw request ?
959
    je	 thread3
960
    cmp  eax,2			; key in buffer ?
961
    je	 key3
962
    cmp  eax,3			; button in buffer ?
963
    je	 button3
31 halyavin 964
 
965
    jmp  still3
966
 
967
  key3:
485 heavyiron 968
    mcall
31 halyavin 969
    cmp  ah,27
825 mario79 970
    je	 close3
31 halyavin 971
    cmp  ah,13
825 mario79 972
    je	 kok
31 halyavin 973
    cmp  ah,178 ;up
974
    jne  nofup
975
    cmp  dword [bgrmode],1
825 mario79 976
    je	 fdn
31 halyavin 977
  fup:
978
    dec dword [bgrmode]
979
    jmp  flagcont
980
  nofup:
981
    cmp  ah,177 ;down
982
    jne  still3
983
    cmp dword [bgrmode],2
825 mario79 984
    je	 fup
31 halyavin 985
  fdn:
986
    inc dword [bgrmode]
987
    jmp  flagcont
988
 
989
 
825 mario79 990
  button3:			 ; button
991
    mov  eax,17 		; get id
485 heavyiron 992
    mcall
31 halyavin 993
 
825 mario79 994
    cmp  ah,1			; button id=1 ?
31 halyavin 995
    jne  noclose3
996
  close3:
997
    btr dword [status],3
998
    bts dword [status],2
825 mario79 999
    mov  eax,-1 		; close this program
485 heavyiron 1000
    mcall
31 halyavin 1001
  noclose3:
1002
    cmp  ah,4
1003
    jne  nook
1004
   kok:
1005
    call background
1006
    jmp  close3
1007
  nook:
1008
    cmp  ah,2
825 mario79 1009
    jb	 still3
31 halyavin 1010
    cmp  ah,3
825 mario79 1011
    ja	 still3
31 halyavin 1012
    dec  ah
1013
    mov byte [bgrmode],ah
1014
   flagcont:
1015
    call drawflags
1016
    jmp  still3
1017
 
1018
 
1019
 
1020
 
1021
;   *********************************************
1022
;   *******  WINDOW DEFINITIONS AND DRAW ********
1023
;   *********************************************
1024
 
1025
 
1026
draw_window3:
1027
 
1028
 
825 mario79 1029
    mov  eax,12 		   ; function 12:tell os about windowdraw
1030
    mov  ebx,1			   ; 1, start of draw
485 heavyiron 1031
    mcall
31 halyavin 1032
 
825 mario79 1033
				   ; DRAW WINDOW
1034
    xor  eax,eax		   ; function 0 : define and draw window
1035
    mov  ebx,100*65536+200	   ; [x start] *65536 + [x size]
1036
    mov  ecx,100*65536+100	   ; [y start] *65536 + [y size]
1037
    mov  edx,0x03780078 	   ; color of work area RRGGBB,8->color gl
485 heavyiron 1038
    mcall
31 halyavin 1039
 
1040
    mov  eax,8
1041
    mov  ebx,70*65536+40
1042
    mov  ecx,70*65536+20
1043
    mov  edx,4
1044
    mov  esi,0xac0000
485 heavyiron 1045
    mcall
31 halyavin 1046
 
825 mario79 1047
				   ; WINDOW LABEL
1048
    mov  eax,4			   ; function 4 : write text to window
1049
    mov  ebx,8*65536+8		   ; [x start] *65536 + [y start]
1050
    mov  ecx,0x10ddeeff 	   ; font 1 & color ( 0xF0RRGGBB )
1051
    mov  edx,labelt3		   ; pointer to text beginning
1052
    mov  esi,labelt3.size	   ; text length
485 heavyiron 1053
    mcall
31 halyavin 1054
    add  ebx,38*65536+20
1055
    mov  ecx,0xddeeff
1056
    mov  edx, bgrdtext
1057
    mov  esi, bgrdtext.size
485 heavyiron 1058
    mcall
31 halyavin 1059
    add  ebx,40*65536+15
1060
    mov  edx, tiled
1061
    mov  esi, tiled.size
485 heavyiron 1062
    mcall
31 halyavin 1063
    add  ebx,15
1064
    mov  edx, stretch
1065
    mov  esi, stretch.size ;7
485 heavyiron 1066
    mcall
31 halyavin 1067
    add  ebx,18
1068
    mov  edx, ok_btn
1069
    mov  esi, ok_btn.size ;2
485 heavyiron 1070
    mcall
31 halyavin 1071
 
1072
    call drawflags
1073
 
825 mario79 1074
    mov  eax,12 		   ; function 12:tell os about windowdraw
1075
    mov  ebx,2			   ; 2, end of draw
485 heavyiron 1076
    mcall
31 halyavin 1077
 
1078
    ret
1079
 
1080
 drawflags:
1081
    mov  eax,8
1082
    mov  ebx,70*65536+10
1083
    mov  ecx,40*65536+10
1084
    mov  edx,2
1085
    mov  esi,0xe0e0e0
485 heavyiron 1086
    mcall
31 halyavin 1087
    add  ecx,15*65536
1088
    inc  edx
485 heavyiron 1089
    mcall
31 halyavin 1090
    mov  eax,4
1091
    mov  ebx,73*65536+42
1092
    xor  ecx,ecx
1093
    mov  edx,vflag
1094
    mov  esi,1
1095
    cmp  dword [bgrmode],1
825 mario79 1096
    je	 nodownflag
31 halyavin 1097
    add  ebx,15
1098
 nodownflag:
485 heavyiron 1099
    mcall
31 halyavin 1100
    ret
1101
 
1102
 
1103
; DATA AREA
825 mario79 1104
status	 dd 0  ;bit0=1 if file thread is created
1105
soi	 dd 0
1106
delta	dd	0
190 diamond 1107
process  dd 0
1108
 
1109
bWasDraw db 0
31 halyavin 1110
vflag: db 'x'
1111
bgrmode: dd 1
1112
 
132 diamond 1113
wnd_width dd 210
1114
wnd_height dd 53
1115
 
31 halyavin 1116
lsz labelt3,\
1117
    en,   'Background set',\
135 diamond 1118
    ru,   "Установка фона",\
1119
    de,   'Hintergrund gesetzt'
31 halyavin 1120
 
1121
lsz bgrdtext,\
1122
    en, 'SET AS BACKGROUND:',\
135 diamond 1123
    ru, 'Тип обоев:',\
1124
    de, 'ALS HINTERGRUND'
31 halyavin 1125
 
1126
lsz tiled,\
1127
    en, 'TILED',\
135 diamond 1128
    ru, 'замостить',\
1129
    de, 'GEKACHELT'
31 halyavin 1130
 
1131
lsz stretch,\
1132
    en, 'STRETCH',\
135 diamond 1133
    ru, 'растянуть',\
1134
    de, 'GESTRECKT'
31 halyavin 1135
 
1136
lsz ok_btn,\
1137
    en, 'Ok',\
135 diamond 1138
    ru, 'Ok',\
1139
    de, 'Ok'
31 halyavin 1140
 
825 mario79 1141
image_file dd 0
832 mario79 1142
image_file_1 dd 0
825 mario79 1143
 
135 diamond 1144
pos: dd 6
825 mario79 1145
 
828 mario79 1146
window_high dd 0
1147
window_width dd 0
1148
skin_high dd 0
1149
;---------------------------------------------------------------------
1150
; for EDITBOX
1151
name_editboxes:
1152
edit1 edit_box 200,10,30,0xffffff,0xbbddff,0,0,0,255,string,ed_focus+ed_always_focus,0
1153
name_editboxes_end:
825 mario79 1154
 
828 mario79 1155
mouse_flag: dd 0x0
1156
;---------------------------------------------------------------------
135 diamond 1157
fileinfo:
825 mario79 1158
     dd 5
135 diamond 1159
     dd 0
1160
     dd 0
832 mario79 1161
     dd 0
1162
     dd process_info
135 diamond 1163
string:
825 mario79 1164
	db	'/sys/bgr.bmp',0
31 halyavin 1165
 
135 diamond 1166
IM_END:
825 mario79 1167
	rb	string+257-$
31 halyavin 1168
 
828 mario79 1169
temp_area:
1170
procinfo:
132 diamond 1171
process_info:
825 mario79 1172
rb 1024*4
1173
rb 1024*2
1174
thread:
1175
rb 512
31 halyavin 1176
I_END: