Subversion Repositories Kolibri OS

Rev

Rev 109 | 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
3
;   Compile with FASM for Menuet
4
 
5
;******************************************************************************
6
    use32
7
    org    0x0
8
    db     'MENUET01'              ; 8 byte id
9
    dd     0x01                    ; header version
10
    dd     START                   ; start of code
11
    dd     IM_END                  ; size of image
12
    dd     0x300000                ; memory for app
13
    dd     0x300000                ; esp
14
    dd     temp_area , 0x0         ; I_Param , I_Icon
132 diamond 15
 
31 halyavin 16
include    'lang.inc'
17
include    'macros.inc'
18
;******************************************************************************
19
 
20
START:                          ; start of execution
21
 
22
; check for parameters
23
   cmp   dword [temp_area],'BOOT'
24
   jne   .no_boot
25
   call  load_image
26
   call  convert
27
   call  background
28
   or    eax,-1
29
   int   0x40
30
 .no_boot:
31
 
32
   cmp   byte [temp_area],0
33
   jz    .no_param
34
   mov   edi,string      ; clear string
35
   mov   ecx,43*3        ;   length of a string
36
   xor   eax,eax         ;   symbol <0>
132 diamond 37
   add   al,14h
31 halyavin 38
   cld
39
   rep   stosb
40
 
41
   mov   edi,temp_area   ; look for <0> in temp_area
42
   mov   ecx,43*3+1      ;   strlen
43
   repne scasb
44
   add   edi,-temp_area  ;   get length of the string
45
   dec   edi
46
 
47
   mov   ecx,edi
48
   mov   esi,temp_area
49
   mov   edi,string
50
   rep   movsb           ; copy string from temp_area to "string" (filename)
51
 
132 diamond 52
   call  load_image
53
   call  convert
54
 
31 halyavin 55
 .no_param:
56
 
57
 
58
   mov  ecx,-1           ; get information about me
59
   call getappinfo
60
 
61
   mov  edx,[process_info+30] ; теперь в edx наш идентификатор
62
   mov  ecx,eax
63
 
64
  @@:
65
   call getappinfo
66
   cmp  edx,[process_info+30]
67
   je   @f  ; если наш PID совпал с PID рассматриваемого процесса, мы нашли себя
68
   dec  ecx ; иначе смотрим следующий процесс
69
   jne  @b  ; возвращаемся, если не все процессы рассмотрены
70
  @@:
71
 
72
; теперь в ecx номер процесса
73
    mov  [process],ecx
74
 
75
    call draw_window
76
 
77
still:
78
 
79
    mov  eax,10                 ; wait here for event
80
    int  0x40
81
 
82
    cmp  eax,1                  ; redraw request ?
83
    je   red
84
    cmp  eax,2                  ; key in buffer ?
85
    je   key
86
    cmp  eax,3                  ; button in buffer ?
87
    je   button
88
 
89
    jmp  still
90
 
91
  red:
92
    bt   [status],2
93
    jnc  @f
94
    mov eax,18
95
    mov ebx,3
96
    mov ecx,[process]
97
    int 0x40
98
    btr [status],2
99
    jmp still
100
   @@:
101
    call draw_window
102
    jmp still
103
 
104
  key:                          ; key
105
    int  0x40
106
    cmp  ah,6
107
    je   kfile
108
    cmp  ah,15
109
    je   kopen
110
    cmp  ah,9
111
    je   kinfo
112
    cmp  ah,2
113
    je   kbgrd
114
    jmp  still
115
 
116
  button:                       ; button
117
    mov  eax,17                 ; get id
118
    int  0x40
119
 
120
    cmp  ah,1                   ; button id=1 ?
121
    jne  noclose
122
 
123
    mov  eax,-1                 ; close this program
124
    int  0x40
125
  noclose:
126
    cmp  ah,2
127
    jne  nofile
128
  kfile:
129
    bt   dword [status],0
130
    jc   still
131
    bts  dword [status],0
132
    mov  eax,51
133
    mov  ebx,1
134
    mov  ecx,thread1
135
    mov  edx,0x29fff0
136
    int  0x40
137
    jmp  still
138
  nofile:
139
    cmp  ah,3
140
    jne  noopen
141
 
142
 kopen:
143
    mov ecx,-1
144
    call getappinfo
145
    mov ebx,dword [I_END+42]
146
    mov ecx,dword [I_END+46]
147
    add ebx,10*65536-15
148
    add ecx,50*65536-55
149
    mov edx,0xffffff
150
    mov eax,13
151
    int 0x40
152
 
153
    call load_image
154
 
155
  open1:
156
    cmp word [I_END],word 'BM'
157
    jne  still
158
    call convert
159
    call drawimage
160
    jmp  still
161
  noopen:
162
 
163
    cmp  ah,4
164
    jne  noinfo
165
  kinfo:
166
    bt   dword [status],1
167
    jc   still
168
    bts  dword [status],1
169
    mov  eax,51
170
    mov  ebx,1
171
    mov  ecx,thread2
172
    mov  edx,0x2afff0
173
    int  0x40
174
    jmp  still
175
  noinfo:
176
 
177
; УСТАНОВИТЬ ФОН
178
    cmp  ah,5
179
    jne  still
180
  kbgrd:
181
    bt dword [status],3
182
    jc   still
183
    bts dword [status],3
184
    mov  eax,51
185
    mov  ebx,1
186
    mov  ecx,thread3
187
    mov  edx,0x2bfff0
188
    int  0x40
189
    jmp  still
190
    ;call background
191
 
192
 getappinfo:
193
    mov  eax,9
132 diamond 194
    mov  ebx,process_info
31 halyavin 195
    int  0x40
196
    ret
197
 
198
 
199
load_image:
200
    mov  dword [fileinfo+8],1 ; how many blocks to read (1)
201
    mov  eax,58
202
    mov  ebx,fileinfo
203
    int  0x40
204
    cmp  [I_END+2],dword 512  ; размер файла (file size)
132 diamond 205
    jbe  @f
31 halyavin 206
    mov  eax,[I_END+2]
207
    shr  eax,9 ; поделим на 512 и прибавим 1 - получим число блоков
208
    inc  eax
209
 
210
    mov  dword [fileinfo+8],eax
211
    mov  eax,58
212
    mov  ebx,fileinfo
213
    int  0x40
132 diamond 214
@@:
215
    mov  eax,[I_END+18]
216
    mov  ebx,[I_END+22]
217
    add  eax,20
218
    cmp  eax,210
219
    jae  @f
220
    mov  eax,210
221
@@:
222
    add  ebx,58
223
    cmp  ebx,56
224
    jae  @f
225
    mov  ebx,56
226
@@:
227
    mov  [wnd_width],eax
228
    mov  [wnd_height],ebx
229
    test [bWasDraw],1
230
    jz   @f
231
    mov  esi,ebx
232
    mov  edx,eax
233
    mov  ecx,-1
234
    mov  ebx,-1
235
    mov  eax,67
236
    int  40h
237
@@:
238
    ret
31 halyavin 239
 
240
 
241
  drawimage:
242
    cmp  word [I_END],word 'BM'
243
    jne  nodrawimage
244
    mov  eax,7
245
    mov  ebx,[soi]
246
    mov  ecx,[I_END+18]
247
    shl  ecx,16
248
    add  ecx,[I_END+22]
249
    mov  edx,10*65536+50
250
    int  0x40
251
  nodrawimage:
252
    ret
253
 
254
; УСТАНОВИТЬ ФОН
255
  background:
256
    cmp  word [I_END],word 'BM'
257
    jne  @f
258
    mov  eax,15
259
    mov  ebx,1
260
    mov  ecx,[I_END+18] ; ширина
261
    mov  edx,[I_END+22] ; высота
262
    int  0x40
263
 
264
    mov  esi, ecx
265
    imul esi, edx
266
    imul esi, 3
267
    mov  ebx,5
268
    mov  ecx,[soi]
269
    xor  edx,edx
270
;;;    mov  esi, ;640*480*3
271
    int  0x40
272
 
273
    dec  ebx    ;tile/stretch
274
    mov  ecx,dword [bgrmode]
275
    int  0x40
276
 
277
    dec  ebx
278
    int  0x40
279
   @@:
280
    ret
281
 
282
  convert:
283
    movzx eax,word [I_END+28]
284
    mul dword [I_END+18]
285
    mov  ebx,32
286
    div  ebx
287
    test edx,edx
288
    je   noaddword
289
    inc  eax
290
  noaddword:
291
    mov  [dwps],eax  ;dwps-doublewords per string
292
    shl  eax,2
293
    mov  [bps],eax   ;bps-bytes per string
294
 
295
    cmp dword [I_END+34],0
296
    jne  yespicsize  ;if picture size is defined
297
    mul dword [I_END+22]
298
    mov dword [I_END+34],eax
299
 
300
  yespicsize:
301
    mov  eax,I_END
302
    push eax
303
    add  eax, [I_END+2];file size
304
    inc  eax
305
    mov  [soi],eax   ;soi-start of image area for drawing
306
    pop  eax
307
    add  eax, [I_END+10]
308
    mov  [sop],eax   ;sop-start of picture in file
309
    add  eax, [I_END+34]
310
    mov  [eop],eax   ;eop-end of picture in file
311
    mov  eax, [I_END+18]
312
    mov  ebx,3
313
    mul  ebx             ;3x pixels in eax
314
 
315
    mov  edi,[soi]   ;initializing
316
    mov  esi,[eop]
317
    sub  esi,[bps]
318
 
319
 
320
  nextstring:
321
    push edi
322
    cmp word [I_END+28],24
323
    jne  convertno32
324
 
325
    mov  ecx,[dwps]
326
    cld
327
    rep movsd
328
  convert1:
329
    pop  edi
330
    sub  esi,[bps]
331
    sub  esi,[bps]
332
    cmp  esi,[sop]
333
    jb   nomorestring
334
    add  edi,eax
335
    jmp  nextstring
336
 
337
  nomorestring:
338
    ret
339
 
340
  convertno32:
341
    mov  ebx,I_END
342
    add  ebx, [I_END+14]
343
    add  ebx,14          ;start of color table
344
    push esi
345
    add  esi,[bps]
346
    mov  [eos],esi
347
    pop  esi
348
  nextelem:
349
    push eax
350
    movzx eax,byte [esi]
351
    cmp word [I_END+28],4
352
    je   convert4bpp
353
    cmp word [I_END+28],1
354
    je   convert1bpp
355
    call converttable
356
  convert2:
357
    pop  eax
358
    inc  esi
359
    cmp  esi,[eos]
360
    jae  convert1
361
    add  edi,3
362
    jmp  nextelem
363
 
364
  convert4bpp:
365
    shl  ax,4
366
    shr  al,4
367
    push ax
368
    movzx eax,ah
369
    call converttable
370
    add  edi,3
371
    pop  ax
372
    movzx eax,al
373
    call converttable
374
    jmp  convert2
375
 
376
  convert1bpp:
377
    mov  ecx,eax
378
    mov  edx,7
379
  nextbit:
380
    xor  eax,eax
381
    bt   ecx,edx
382
    jnc  noaddelem
383
    inc  eax
384
  noaddelem:
385
    push edx
386
    call converttable
387
    pop  edx
388
    dec  edx
389
    cmp  edx,0xffffffff
390
    je   convert2
391
    add  edi,3
392
    jmp  nextbit
393
 
394
  converttable:
395
    shl  eax,2
396
    add  eax,ebx
397
    mov  edx, [eax]
398
    mov dword [edi],edx
399
    ret
400
 
401
;   *********************************************
402
;   *******  WINDOW DEFINITIONS AND DRAW ********
403
;   *********************************************
404
 
405
 
406
draw_window:
132 diamond 407
    or   [bWasDraw],1
31 halyavin 408
 
409
    mov  eax,12                    ; function 12:tell os about windowdraw
410
    mov  ebx,1                     ; 1, start of draw
411
    int  0x40
412
 
413
                                   ; DRAW WINDOW
414
    xor  eax,eax                   ; function 0 : define and draw window
132 diamond 415
;    mov  ebx,350                   ; [x start] *65536 + [x size]
416
;    mov  ecx,400                   ; [y start] *65536 + [y size]
417
    mov  ebx,100*65536
418
    mov  ecx,100*65536
419
    add  ebx,[wnd_width]
420
    add  ecx,[wnd_height]
31 halyavin 421
    mov  edx,0x03ffffff            ; color of work area RRGGBB,8->color gl
422
    int  0x40
423
 
424
    mov  eax,8
425
    mov  ebx,10*65536+46
426
    mov  ecx,25*65536+20
427
    mov  edx,2
428
    mov  esi,0x780078
429
  newbutton:
430
    int  0x40
431
    add  ebx,48*65536
432
    inc  edx
433
    cmp  edx,6
434
    jb   newbutton
435
 
436
                                   ; WINDOW LABEL
437
    mov  eax,4                     ; function 4 : write text to window
438
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
439
    mov  ecx,0x10ddeeff            ; font 1 & color ( 0xF0RRGGBB )
440
    mov  edx,labelt                ; pointer to text beginning
441
    mov  esi,12                    ; text length
442
    int  0x40
443
 
444
    mov  ebx,14*65536+32
445
    mov  edx,buttext
446
    mov  esi,26
447
    int  0x40
448
 
449
    call drawimage
450
 
451
    mov  eax,12                    ; function 12:tell os about windowdraw
452
    mov  ebx,2                     ; 2, end of draw
453
    int  0x40
454
 
455
    ret
456
 
457
 
458
; DATA AREA
459
 
460
labelt:
461
         db 'MeView v.0.3'
462
 
463
lsz buttext,\
464
    en,   ' FILE   OPEN   INFO   BGRD',\
465
    ru,   ' ФАЙЛ  ОТКР   ИНФО   ФОН  '
466
 
467
status   dd 0  ;bit0=1 if file thread is created
468
bps      dd 0
469
dwps     dd 0
470
soi      dd 0
471
sop      dd 0
472
eop      dd 0
473
eos      dd 0
474
process  dd 0
475
 
132 diamond 476
bWasDraw db 0
477
 
31 halyavin 478
thread1:                        ; start of thread1
479
 
480
     call draw_window1
481
 
482
still1:
483
 
484
    mov  eax,10                 ; wait here for event
485
    int  0x40
486
 
487
    cmp  eax,1                  ; redraw request ?
488
    je   thread1
489
    cmp  eax,2                  ; key in buffer ?
490
    je   key1
491
    cmp  eax,3                  ; button in buffer ?
492
    je   button1
493
 
494
    jmp  still1
495
 
496
  key1:                         ; key
497
    int  0x40
498
    cmp  ah,179
499
    jne  noright
500
    mov  eax,[pos]
501
    cmp  eax,41
502
    ja   still1
503
    inc  eax
504
    mov  [pos],eax
505
    call drawstring
506
    jmp  still1
507
  noright:
508
    cmp  ah,176
509
    jne  noleft
510
    mov  eax,[pos]
511
    test eax,eax
512
    je   still1
513
    dec  eax
514
    mov  [pos],eax
515
    call drawstring
516
    jmp  still1
517
  noleft:
518
    cmp  ah,182        ;del
519
    jne  nodelet
520
    call shiftback
521
    call drawstring
522
    jmp  still1
523
  nodelet:
524
    cmp  ah,8          ;zaboy
525
    jne  noback
526
    mov  eax,[pos]
527
    test eax,eax
528
    je   still1
529
    dec  eax
530
    mov  [pos],eax
531
    call shiftback
532
    call drawstring
533
    jmp  still1
534
  noback:
535
    cmp  ah,13
536
    jne  noenter
537
  enter1:
538
    mov  al,byte ' '
539
    mov  edi,string
540
    mov  ecx,43
541
    cld
542
    repne scasb
543
    dec  edi
544
    mov  byte [edi],0
545
    jmp  close1
546
  noenter:
547
    cmp  ah,27
548
    jne  noesc
549
    jmp  enter1
550
  noesc:
551
    cmp  dword [pos],42
552
    jae  still1
553
 
554
    mov  edi,string
555
    add  edi,42
556
    mov  esi,edi
557
    dec  esi
558
    mov  ecx,42
559
    sub  ecx,[pos]
560
    std
561
    rep  movsb
562
 
563
    shr  eax,8
564
    mov  esi,string
565
    add  esi,[pos]
566
    mov  byte [esi],al
567
    inc  dword [pos]
568
    call drawstring
569
 
570
    jmp  still1
571
 
572
  button1:                      ; button
573
    mov  eax,17                 ; get id
574
    int  0x40
575
 
576
    cmp  ah,1                   ; button id=1 ?
577
    jne  noclose1
578
    jmp  enter1
579
  close1:
580
    bts  dword [status],2
581
    btr  dword [status],0
582
    mov  eax,-1                 ; close this program
583
    int  0x40
584
  noclose1:
585
    cmp  ah,2
586
    jne  nosetcur
587
    mov  eax,37
588
    mov  ebx,1
589
    int  0x40
590
    shr  eax,16
591
    sub  eax,21
592
    xor  edx,edx
593
    mov  ebx,6
594
    div  ebx
595
    mov  [pos],eax
596
    call drawstring
597
    jmp  still1
598
  nosetcur:
599
    jmp  still1
600
 
601
 
602
  shiftback:
603
    mov  edi,string
604
    add  edi,[pos]
605
    mov  esi,edi
606
    inc  esi
607
    mov  ecx,43
608
    sub  ecx,[pos]
609
    cld
610
    rep movsb
611
    ret
612
 
613
;   *********************************************
614
;   *******  WINDOW DEFINITIONS AND DRAW ********
615
;   *********************************************
616
 
617
 
618
draw_window1:
619
 
620
 
621
    mov  eax,12                    ; function 12:tell os about windowdraw
622
    mov  ebx,1                     ; 1, start of draw
623
    int  0x40
624
 
625
                                   ; DRAW WINDOW
626
    xor  eax,eax                   ; function 0 : define and draw window
627
    mov  ebx,100*65536+300         ; [x start] *65536 + [x size]
628
    mov  ecx,100*65536+80          ; [y start] *65536 + [y size]
629
    mov  edx,0x03780078            ; color of work area RRGGBB,8->color gl
630
    int  0x40
631
 
632
                                   ; WINDOW LABEL
633
    mov  eax,4                     ; function 4 : write text to window
634
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
635
    mov  ecx,0x10ddeeff            ; font 1 & color ( 0xF0RRGGBB )
636
    mov  edx,labelt1               ; pointer to text beginning
637
    mov  esi,4                     ; text length
638
    int  0x40
639
 
640
    call drawstring
641
 
642
    mov  eax,12                    ; function 12:tell os about windowdraw
643
    mov  ebx,2                     ; 2, end of draw
644
    int  0x40
645
 
646
    ret
647
 
648
 drawstring:
649
    pusha
650
    mov  eax,8             ;invisible button
651
    mov  ebx,21*65536+258
652
    mov  ecx,40*65536+15
132 diamond 653
    mov  edx,0x60000002
31 halyavin 654
    int  0x40
655
 
656
    mov  eax,13             ;bar
657
    mov  edx,0xe0e0e0
658
    int  0x40
659
    push eax                ;cursor
660
    mov  eax,6*65536
661
    mul  dword [pos]
662
    add  eax,21*65536+6
663
    mov  ebx,eax
664
    pop  eax
665
    mov  edx,0x6a73d0
666
    int  0x40
667
    mov  eax,4              ;path
668
    mov  ebx,21*65536+44
669
    xor  ecx,ecx
670
    mov  edx,string
671
    mov  esi,43
672
    int  0x40
673
 
674
 
675
    popa
676
    ret
677
 
678
; DATA AREA
679
 
680
lsz labelt1,\
681
   en,  'File',\
682
   ru,  'Файл'
683
 
684
pos: dd 6
685
fileinfo:
686
     dd 0
687
     dd 0
688
     dd 1          ;number of blocks  of 512 bytes
689
     dd I_END
690
     dd temp_area
691
string:
692
; db '/HARDDISK/FIRST/1/DICK.BMP                  '
132 diamond 693
; db '/hd/1/menuet/pics/new.bmp                   '
694
  db '/rd/1/bgr.bmp                               '
31 halyavin 695
  db '                                            '
696
  db '                                            '
697
 
698
thread2:                          ; start of info thread
699
 
700
     call draw_window2
701
 
702
still2:
703
 
704
    mov  eax,10                 ; wait here for event
705
    int  0x40
706
 
707
    cmp  eax,1                  ; redraw request ?
708
    je   thread2
709
    cmp  eax,2                  ; key in buffer ?
710
    je   close2
711
    cmp  eax,3                  ; button in buffer ?
712
    je   button2
713
 
714
    jmp  still2
715
 
716
  button2:                       ; button
717
    mov  eax,17                 ; get id
718
    int  0x40
719
 
720
    cmp  ah,1                   ; button id=1 ?
721
    jne  noclose2
722
  close2:
723
    btr dword [status],1
724
    bts dword [status],2
725
    mov  eax,-1                 ; close this program
726
    int  0x40
727
  noclose2:
728
 
729
    jmp  still2
730
 
731
 
732
 
733
 
734
;   *********************************************
735
;   *******  WINDOW DEFINITIONS AND DRAW ********
736
;   *********************************************
737
 
738
 
739
draw_window2:
740
 
741
 
742
    mov  eax,12                    ; function 12:tell os about windowdraw
743
    mov  ebx,1                     ; 1, start of draw
744
    int  0x40
745
 
746
                                   ; DRAW WINDOW
747
    xor  eax,eax                   ; function 0 : define and draw window
748
    mov  ebx,100*65536+330         ; [x start] *65536 + [x size]
749
    mov  ecx,100*65536+90          ; [y start] *65536 + [y size]
750
    mov  edx,0x03780078            ; color of work area RRGGBB,8->color gl
751
    int  0x40
752
 
753
                                   ; WINDOW LABEL
754
    mov  eax,4                     ; function 4 : write text to window
755
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
756
    mov  ecx,0x10ddeeff            ; font 1 & color ( 0xF0RRGGBB )
757
    mov  edx,labelt2               ; pointer to text beginning
758
    mov  esi,labelt2.size          ; text length
759
    int  0x40
760
 
761
    mov  ebx,10*65536+30
762
    mov  edx,string
763
    mov  esi,43
764
    int  0x40
765
    mov  edx,fitext
766
    mov  esi,14
767
    add  ebx,70*65536+10
768
 followstring:
769
    int  0x40
770
    add  ebx,10
771
    add  edx,esi
772
    cmp  ebx,80*65536+70
773
    jbe  followstring
774
    mov  eax,47
775
    mov  edx,200*65536+40
776
    mov  esi,ecx
777
    mov  ecx, [I_END+2]
778
    call digitcorrect
779
    int  0x40
780
    add  edx,10
781
    mov  ecx, [I_END+18]
782
    call digitcorrect
783
    int  0x40
784
    add  edx,10
785
    mov  ecx, [I_END+22]
786
    call digitcorrect
787
    int  0x40
788
    add  edx,10
789
    movzx ecx,word [I_END+28]
790
    call digitcorrect
791
    int  0x40
792
 
793
    mov  eax,12                    ; function 12:tell os about windowdraw
794
    mov  ebx,2                     ; 2, end of draw
795
    int  0x40
796
 
797
    ret
798
 
799
 digitcorrect:
800
    xor  ebx,ebx
801
    mov  bh,6
802
    cmp  ecx,99999
803
    ja   c_end
804
    dec  bh
805
    cmp  ecx,9999
806
    ja   c_end
807
    dec  bh
808
    cmp  ecx,999
809
    ja   c_end
810
    dec  bh
811
    cmp  ecx,99
812
    ja   c_end
813
    dec  bh
814
    cmp  ecx,9
815
    ja   c_end
816
    dec  bh
817
 c_end:
818
    bswap ebx
819
    ret
820
 
821
 
822
; DATA AREA
823
 
824
lsz labelt2,\
825
    en,   'File info',\
826
    ru,   'Информация о файле'
827
 
828
lsz fitext,\
829
     en, 'FILE SIZE     ',\
830
     en, 'X SIZE        ',\
831
     en, 'Y SIZE        ',\
832
     en, 'BITS PER PIXEL',\
833
                          \
834
     ru, 'Размер файла  ',\
835
     ru, 'Ширина        ',\
836
     ru, 'Высота        ',\
837
     ru, 'Бит на пиксел '
838
 
839
thread3:                          ; start of bgrd thread
840
 
841
     call draw_window3
842
 
843
still3:
844
 
845
    mov  eax,10                 ; wait here for event
846
    int  0x40
847
 
848
    cmp  eax,1                  ; redraw request ?
849
    je   thread3
850
    cmp  eax,2                  ; key in buffer ?
851
    je   key3
852
    cmp  eax,3                  ; button in buffer ?
853
    je   button3
854
 
855
    jmp  still3
856
 
857
  key3:
858
    int  0x40
859
    cmp  ah,27
860
    je   close3
861
    cmp  ah,13
862
    je   kok
863
    cmp  ah,178 ;up
864
    jne  nofup
865
    cmp  dword [bgrmode],1
866
    je   fdn
867
  fup:
868
    dec dword [bgrmode]
869
    jmp  flagcont
870
  nofup:
871
    cmp  ah,177 ;down
872
    jne  still3
873
    cmp dword [bgrmode],2
874
    je   fup
875
  fdn:
876
    inc dword [bgrmode]
877
    jmp  flagcont
878
 
879
 
880
  button3:                       ; button
881
    mov  eax,17                 ; get id
882
    int  0x40
883
 
884
    cmp  ah,1                   ; button id=1 ?
885
    jne  noclose3
886
  close3:
887
    btr dword [status],3
888
    bts dword [status],2
889
    mov  eax,-1                 ; close this program
890
    int  0x40
891
  noclose3:
892
    cmp  ah,4
893
    jne  nook
894
   kok:
895
    call background
896
    jmp  close3
897
  nook:
898
    cmp  ah,2
899
    jb   still3
900
    cmp  ah,3
901
    ja   still3
902
    dec  ah
903
    mov byte [bgrmode],ah
904
   flagcont:
905
    call drawflags
906
    jmp  still3
907
 
908
 
909
 
910
 
911
;   *********************************************
912
;   *******  WINDOW DEFINITIONS AND DRAW ********
913
;   *********************************************
914
 
915
 
916
draw_window3:
917
 
918
 
919
    mov  eax,12                    ; function 12:tell os about windowdraw
920
    mov  ebx,1                     ; 1, start of draw
921
    int  0x40
922
 
923
                                   ; DRAW WINDOW
924
    xor  eax,eax                   ; function 0 : define and draw window
925
    mov  ebx,100*65536+200         ; [x start] *65536 + [x size]
926
    mov  ecx,100*65536+100         ; [y start] *65536 + [y size]
927
    mov  edx,0x03780078            ; color of work area RRGGBB,8->color gl
928
    int  0x40
929
 
930
    mov  eax,8
931
    mov  ebx,70*65536+40
932
    mov  ecx,70*65536+20
933
    mov  edx,4
934
    mov  esi,0xac0000
935
    int  0x40
936
 
937
                                   ; WINDOW LABEL
938
    mov  eax,4                     ; function 4 : write text to window
939
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
940
    mov  ecx,0x10ddeeff            ; font 1 & color ( 0xF0RRGGBB )
941
    mov  edx,labelt3               ; pointer to text beginning
942
    mov  esi,14                    ; text length
943
    int  0x40
944
    add  ebx,38*65536+20
945
    mov  ecx,0xddeeff
946
    mov  edx, bgrdtext
947
    mov  esi, bgrdtext.size
948
    int  0x40
949
    add  ebx,40*65536+15
950
    mov  edx, tiled
951
    mov  esi, tiled.size
952
    int  0x40
953
    add  ebx,15
954
    mov  edx, stretch
955
    mov  esi, stretch.size ;7
956
    int  0x40
957
    add  ebx,18
958
    mov  edx, ok_btn
959
    mov  esi, ok_btn.size ;2
960
    int  0x40
961
 
962
    call drawflags
963
 
964
    mov  eax,12                    ; function 12:tell os about windowdraw
965
    mov  ebx,2                     ; 2, end of draw
966
    int  0x40
967
 
968
    ret
969
 
970
 drawflags:
971
    mov  eax,8
972
    mov  ebx,70*65536+10
973
    mov  ecx,40*65536+10
974
    mov  edx,2
975
    mov  esi,0xe0e0e0
976
    int  0x40
977
    add  ecx,15*65536
978
    inc  edx
979
    int  0x40
980
    mov  eax,4
981
    mov  ebx,73*65536+42
982
    xor  ecx,ecx
983
    mov  edx,vflag
984
    mov  esi,1
985
    cmp  dword [bgrmode],1
986
    je   nodownflag
987
    add  ebx,15
988
 nodownflag:
989
    int  0x40
990
    ret
991
 
992
 
993
; DATA AREA
994
vflag: db 'x'
995
bgrmode: dd 1
996
 
132 diamond 997
wnd_width dd 210
998
wnd_height dd 53
999
 
31 halyavin 1000
lsz labelt3,\
1001
    en,   'Background set',\
1002
    ru,   "Установка фона"
1003
 
1004
lsz bgrdtext,\
1005
    en, 'SET AS BACKGROUND:',\
1006
    ru, 'Тип обоев:'
1007
 
1008
lsz tiled,\
1009
    en, 'TILED',\
1010
    ru, 'замостить'
1011
 
1012
lsz stretch,\
1013
    en, 'STRETCH',\
1014
    ru, 'растянуть'
1015
 
1016
lsz ok_btn,\
1017
    en, 'Ok',\
1018
    ru, 'Ok'
1019
 
1020
 
1021
 
1022
IM_END:
132 diamond 1023
process_info:
31 halyavin 1024
temp_area:
1025
rb 0x10000
1026
I_END: