Subversion Repositories Kolibri OS

Rev

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