Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1 ha 1
setwindowdefaults:
2
        pushad
3
 
4
        xor   eax,eax
5
        mov   ecx,0xc000
6
       @@:
7
        inc   eax
8
        add   ecx,2
9
        mov   [ecx+0x000],ax          ; process no
10
        mov   [ecx+0x400],ax          ; positions in stack
11
        cmp   ecx,0xc400-2            ; the more high, the more surface
12
        jnz   @b
13
 
14
        popad
15
        ret
16
 
17
 
18
 
19
; eax = cx
20
; ebx = cy
21
; ecx = ex
22
; edx = ey
23
; идея: перебрать все окна, начиная с самого нижнего,
24
;       и для каждого вызвать setscreen
25
align 4
26
calculatescreen:
27
        pushad
28
        cli
29
 
30
        mov   esi, 1
31
        xor   eax, eax
32
        xor   ebx, ebx
33
        mov   ecx, [0xFE00]
34
        mov   edx, [0xFE04]
35
        call  setscreen
36
 
37
        mov   ebp, [0x3004]        ; number of processes
38
        cmp   ebp, 1
39
        jbe   .finish
40
        align 4
41
      .new_wnd:
42
        movzx edi, word [0xC400 + esi * 2]
43
        shl   edi, 5
44
        add   edi, window_data
45
        mov   eax, [edi+0]
46
        mov   ebx, [edi+4]
47
        mov   ecx, [edi+8]
48
        test  ecx, ecx
49
        jz    .not_wnd
50
        add   ecx, eax
51
        mov   edx, [edi+12]
52
        add   edx, ebx
53
        push  esi
54
        movzx esi, word [0xC400 + esi * 2]
55
        call  setscreen
56
        pop   esi
57
      .not_wnd:
58
        inc   esi
59
        dec   ebp
60
        jnz   .new_wnd
61
      .finish:
62
        sti
63
        popad
64
ret
65
 
66
 
67
 
68
virtual at esp
69
  ff_xsz   dd ?
70
  ff_ysz   dd ?
71
  ff_scale dd ?
72
end virtual
73
 
74
align 4
75
; резервирует место под окно заданного процесса
76
setscreen:
77
;  eax  x start
78
;  ebx  y start
79
;  ecx  x end
80
;  edx  y end
81
;  esi  process number
82
pushad
83
        mov edi, esi ;;;word [esi*2+0xc400]
84
        shl   edi, 8
85
        add   edi, 0x80000+0x80  ; address of random shaped window area
86
        cmp   [edi], dword 0
87
        jne   .free_form
88
 
89
        ; get x&y size
90
        sub   ecx, eax
91
        sub   edx, ebx
92
        inc   ecx
93
        inc   edx
94
 
95
        ; get WinMap start
96
        mov   edi, [0xFE00] ; screen_sx
97
        inc   edi
98
        imul  edi, ebx
99
        add   edi, eax
100
        add   edi, WinMapAddress
101
 
102
  .new_y:
103
        push  ecx ; sx
104
        push  edx
105
 
106
        mov   edx, esi
107
        align 4
108
  .new_x:
109
        mov   byte [edi], dl
110
        inc   edi
111
        dec   ecx
112
        jnz   .new_x
113
 
114
        pop   edx
115
        pop   ecx
116
        add   edi, [0xFE00]
117
        inc   edi
118
        sub   edi, ecx
119
        dec   edx
120
        jnz   .new_y
121
 popad
122
 ret
123
  .read_byte:
124
   ;eax - address
125
   ;esi - slot
126
        push  eax
127
        push  ebx
128
        push  ecx
129
        push  edx
130
        mov   edx,eax
131
        mov   eax,esi
132
        lea   ebx,[esp+12]
133
        mov   ecx,1
134
        call  read_process_memory
135
        pop   edx
136
        pop   ecx
137
        pop   ebx
138
        pop   eax
139
        ret
140
  .free_form:
141
 
142
        ;  for (y=0; y <= x_size; y++)
143
        ;      for (x=0; x <= x_size; x++)
144
        ;          if (shape[coord(x,y,scale)]==1)
145
        ;             set_pixel(x, y, process_number);
146
 
147
        sub  ecx, eax
148
        sub  edx, ebx
149
        inc  ecx
150
        inc  edx
151
 
152
        push  dword [edi+4]  ; push scale first -> for loop
153
 
154
        ; get WinMap start  -> ebp
155
        push  eax
156
        mov   eax, [0xFE00] ; screen_sx
157
        inc   eax
158
        imul  eax, ebx   ;ebx
159
        add   eax, [esp] ;eax
160
        add   eax, WinMapAddress
161
        mov   ebp, eax
162
 
163
        mov   edi, [edi]
164
;        mov   eax, esi
165
;        shl   eax, 5
166
;        add   edi, [eax+0x3000+0x10]
167
        pop   eax
168
 
169
        ; eax = x_start
170
        ; ebx = y_start
171
        ; ecx = x_size
172
        ; edx = y_size
173
        ; esi = process_number
174
        ; edi = &shape
175
        ;       [scale]
176
        push edx ecx ;ebx eax
177
        xor  ebx, ebx
178
        align 4
179
      .ff_new_y:
180
        xor  edx, edx
181
        align 4
182
      .ff_new_x:
183
        ; -- body --
184
        mov  ecx, [ff_scale]
185
        mov  eax, [ff_xsz]
186
        shr  eax, cl
187
        push ebx edx
188
        shr  ebx, cl
189
        shr  edx, cl
190
        imul eax, ebx
191
        add  eax, edx
192
        pop  edx ebx
193
        add  eax, edi ;[ff_shape]
194
        call .read_byte
195
;        cmp  byte [eax], 1
196
;        jne  @f
197
        test al,al
198
        jz   @f
199
        mov  eax, esi  ; [ff_proc]
200
        mov  [ebp], al
201
       @@:
202
        ; -- end body --
203
        inc  ebp
204
        inc  edx
205
        cmp  edx, [ff_xsz]
206
        jb   .ff_new_x
207
        sub  ebp, [ff_xsz]
208
        add  ebp, [0xFE00]  ; screen.x
209
        inc  ebp
210
        inc  ebx
211
        cmp  ebx, [ff_ysz]
212
        jb   .ff_new_y
213
 
214
        pop  ecx edx   ; eax ebx first
215
        add  esp, 4
216
popad
217
ret
218
 
219
 
220
display_settings:
221
 
222
;    eax = 0         ; DISPLAY redraw
223
;          ebx = 0   ; all
224
;
225
;    eax = 1         ; BUTTON type
226
;          ebx = 0   ; flat
227
;          ebx = 1   ; 3D
228
;    eax = 2         ; set WINDOW colours
229
;          ebx = pointer to table
230
;          ecx = number of bytes define
231
;    eax = 3         ; get WINDOW colours
232
;          ebx = pointer to table
233
;          ecx = number of bytes wanted
234
;    eax = 4         ; get skin height
235
;          input  : nothing
236
;          output : eax = skin height in pixel
237
 
238
 
239
     pushad
240
 
241
     test eax, eax      ; redraw display
242
     jnz  dspl0
243
     test ebx, ebx
244
     jnz  dspl0
245
     cmp  [windowtypechanged],dword 1
246
     jne  dspl00
247
     mov  [windowtypechanged],dword 0
248
     mov  [dlx],dword 0
249
     mov  [dly],dword 0
250
     mov  eax,[0xfe00]
251
     mov  [dlxe],eax
252
     mov  eax,[0xfe04]
253
     mov  [dlye],eax
254
     mov  eax,window_data
255
     call redrawscreen
256
   dspl00:
257
     popad
258
     ret
259
   dspl0:
260
 
261
     cmp  eax,1       ; button type
262
     jne  dspl1
263
     and  ebx,1
264
     cmp  ebx,[buttontype]
265
     je   dspl9
266
     mov  [buttontype],ebx
267
     mov  [windowtypechanged],dword 1
268
    dspl9:
269
     popad
270
     ret
271
   dspl1:
272
 
273
     cmp  eax,2       ; set common window colours
274
     jne  no_com_colours
275
     mov  [windowtypechanged],dword 1
276
     mov  esi,[0x3010]
277
     add  esi,0x10
278
     add  ebx,[esi]
279
     mov  esi,ebx
280
     mov  edi,common_colours
281
     and  ecx,127
282
     cld
283
     rep  movsb
284
     popad
285
     ret
286
   no_com_colours:
287
 
288
     cmp  eax,3       ; get common window colours
289
     jne  no_get_com
290
     mov  esi,[0x3010]
291
     add  esi,0x10
292
     add  ebx,[esi]
293
     mov  edi,ebx
294
     mov  esi,common_colours
295
     and  ecx,127
296
     cld
297
     rep  movsb
298
     popad
299
     ret
300
   no_get_com:
301
 
302
     cmp  eax,4       ; get skin height
303
     jne  no_skin_height
304
     popad
305
     mov  eax,[_skinh]
306
     mov  [esp+36],eax
307
     ret
308
   no_skin_height:
309
 
310
     popad
311
     ret
312
 
313
uglobal
314
  common_colours:
315
     times 128 db 0x0
316
endg
317
 
318
check_window_move_request:
319
 
320
        pushad
321
 
322
        mov   edi,[window_move_pr]    ; requestor process base
323
 
324
        cmp   edi,0
325
        je    window_move_return
326
 
327
        shl   edi,5
328
        add   edi,window_data
329
 
330
        push  dword [edi+0]           ; save old coordinates
331
        push  dword [edi+4]
332
        push  dword [edi+8]
333
        push  dword [edi+12]
334
 
335
        mov   eax,[window_move_eax]
336
        mov   ebx,[window_move_ebx]
337
        mov   ecx,[window_move_ecx]
338
        mov   edx,[window_move_edx]
339
 
340
        cmp   eax,-1                  ; set new position and size
341
        je    no_x_reposition
342
        mov   [edi+0],eax
343
      no_x_reposition:
344
        cmp   ebx,-1
345
        je    no_y_reposition
346
        mov   [edi+4],ebx
347
      no_y_reposition:
348
        cmp   ecx,-1
349
        je    no_x_resizing
350
        mov   [edi+8],ecx
351
      no_x_resizing:
352
        cmp   edx,-1
353
        je    no_y_resizing
354
        mov   [edi+12],edx
355
      no_y_resizing:
356
 
357
        call  check_window_position
358
 
359
        pushad                       ; save for window fullscreen/resize
360
        mov   esi,edi
361
        sub   edi,window_data
362
        shr   edi,5
363
        shl   edi,8
364
        add   edi,0x80000+0x90
365
        mov   ecx,4
366
        cld
367
        rep   movsd
368
        popad
369
 
370
        pushad                       ; calculcate screen at new position
371
        mov   eax,[edi+00]
372
        mov   ebx,[edi+04]
373
        mov   ecx,[edi+8]
374
        mov   edx,[edi+12]
375
        add   ecx,eax
376
        add   edx,ebx
377
        call  calculatescreen
378
        popad
379
 
380
        pop   edx                   ; calculcate screen at old position
381
        pop   ecx
382
        pop   ebx
383
        pop   eax
384
        add   ecx,eax
385
        add   edx,ebx
386
        mov   [dlx],eax             ; save for drawlimits
387
        mov   [dly],ebx
388
        mov   [dlxe],ecx
389
        mov   [dlye],edx
390
        call  calculatescreen
391
 
392
        mov   [edi+31],byte 1       ; flag the process as redraw
393
 
394
        mov   eax,edi               ; redraw screen at old position
395
        xor   esi,esi
396
        call  redrawscreen
397
 
398
        mov   [0xfff5],byte 0 ; mouse pointer
399
        mov   [0xfff4],byte 0 ; no mouse under
400
        mov   [0xfb44],byte 0 ; react to mouse up/down
401
 
402
        mov   ecx,10          ; wait 1/10 second
403
      wmrl3:
404
        call  [draw_pointer]
405
        mov   eax,1
406
        call  delay_hs
407
        loop  wmrl3
408
 
409
        mov   [window_move_pr],0
410
 
411
      window_move_return:
412
 
413
        popad
414
 
415
        ret
416
 
417
 
418
 
419
 
420
check_window_position:
421
 
422
    pushad                           ; window inside screen ?
423
 
424
    movzx eax,word [edi+0]
425
    movzx ebx,word [edi+4]
426
    movzx ecx,word [edi+8]
427
    movzx edx,word [edi+12]
428
 
429
    mov   esi,ecx             ; check x pos
430
    add   esi,eax
431
    cmp   esi,[0xfe00]
432
    jbe   x_pos_ok
433
    mov   [edi+0],dword 0
434
    xor   eax, eax
435
  x_pos_ok:
436
 
437
    mov   esi,edx             ; check y pos
438
    add   esi,ebx
439
    cmp   esi,[0xfe04]
440
    jbe   y_pos_ok
441
    mov   [edi+4],dword 0
442
    mov   ebx,0
443
  y_pos_ok:
444
 
445
    mov   esi,ecx             ; check x size
446
    add   esi,eax
447
    cmp   esi,[0xfe00]
448
    jbe   x_size_ok
449
    mov   ecx,[0xfe00]
450
    mov   [edi+8],ecx
451
  x_size_ok:
452
 
453
    mov   esi,edx             ; check y size
454
    add   esi,ebx
455
    cmp   esi,[0xfe04]
456
    jbe   y_size_ok
457
    mov   edx,[0xfe04]
458
    mov   [edi+12],edx
459
  y_size_ok:
460
 
461
    popad
462
 
463
    ret
464
 
465
 
466
uglobal
467
  new_window_starting dd 0
468
endg
469
 
470
 
471
sys_window_mouse:
472
 
473
    push  eax
474
 
475
    mov   eax,[timer_ticks] ;[0xfdf0]
476
    cmp   [new_window_starting],eax
477
    jb    swml1
478
 
479
    mov   [0xfff4],byte 0  ; no mouse background
480
    mov   [0xfff5],byte 0  ; draw mouse
481
 
482
    mov   [new_window_starting],eax
483
 
484
  swml1:
485
 
486
    pop   eax
487
 
488
    ret
489
 
490
drawwindow_I:
491
 
492
        pushad
493
 
494
        mov   esi,[edx+24]   ; rectangle
495
        mov   eax,[edx+0]
496
        shl   eax,16
497
        add   eax,[edx+0]
498
        add   eax,[edx+8]
499
        mov   ebx,[edx+04]
500
        shl   ebx,16
501
        add   ebx,[edx+4]
502
        add   ebx,[edx+12]
503
        call  draw_rectangle
504
 
505
        mov   ecx,[edx+20]   ; grab bar
506
        push  ecx
507
        mov   esi,edx
508
        mov   edx,[esi+04]
509
        add   edx,1
510
        mov   ebx,[esi+04]
511
        add   ebx,25
512
        mov   eax,[esi+04]
513
        add   eax,[esi+12]
514
        cmp   ebx,eax
515
        jb    wdsizeok
516
        mov   ebx,eax
517
      wdsizeok:
518
        push  ebx
519
      drwi:
520
        mov   ebx,edx
521
        shl   ebx,16
522
        add   ebx,edx
523
        mov   eax,[esi+00]
524
        inc   eax
525
        shl   eax,16
526
        add   eax,[esi+00]
527
        add   eax,[esi+8]
528
        sub   eax,1
529
        push  edx
530
        mov   edx,0x80000000
531
        mov   ecx,[esi+20]
532
        and   ecx,edx
533
        cmp   ecx,edx
534
        jnz   nofa
535
        mov   ecx,[esi+20]
536
        sub   ecx,0x00040404
537
        mov   [esi+20],ecx
538
        and   ecx,0x00ffffff
539
        jmp   faj
540
      nofa:
541
        mov   ecx,[esi+20]
542
        and   ecx,0x00ffffff
543
      faj:
544
        pop   edx
545
        mov   edi,0
546
        call  [draw_line]
547
        inc   edx
548
        cmp   edx,[esp]
549
        jb    drwi
550
        add   esp,4
551
        pop   ecx
552
        mov   [esi+20],ecx
553
 
554
        mov   edx,[esi+04]      ; inside work area
555
        add   edx,21+5
556
        mov   ebx,[esi+04]
557
        add   ebx,[esi+12]
558
        cmp   edx,ebx
559
        jg    noinside
560
        mov   eax,1
561
        mov   ebx,21
562
        mov   ecx,[esi+8]
563
        mov   edx,[esi+12]
564
        mov   edi,[esi+16]
565
        call  [drawbar]
566
      noinside:
567
 
568
        popad
569
 
570
        ret
571
 
572
 
573
draw_rectangle:
574
 
575
r_eax equ [esp+28]   ; x start
576
r_ax  equ [esp+30]   ; x end
577
r_ebx equ [esp+16]   ; y start
578
r_bx  equ [esp+18]   ; y end
579
;esi                 ; color
580
 
581
        pushad
582
 
583
        mov   ecx,esi          ; yb,xb -> yb,xe
584
     ;<<< 14.11.2004 Ivan Poddubny  
585
;        mov   eax,r_eax
586
;        shl   eax,16
587
;        mov   ax,r_ax
588
        mov   eax, r_eax
589
        rol   eax, 16
590
     ;>>> 14.11.2004 Ivan Poddubny  
591
        mov   ebx,r_ebx
592
        shl   ebx,16
593
        mov   bx,r_ebx
594
        xor   edi, edi
595
        call  [draw_line]
596
 
597
        mov   ebx,r_bx         ; ye,xb -> ye,xe
598
        shl   ebx,16
599
        mov   bx,r_bx
600
        call  [draw_line]
601
 
602
        mov   ecx,esi          ; ya,xa -> ye,xa
603
        mov   eax,r_eax
604
        shl   eax,16
605
        mov   ax,r_eax
606
        mov   ebx,r_ebx
607
        shl   ebx,16
608
        mov   bx,r_bx
609
        mov   edi,0
610
        call  [draw_line]
611
 
612
        mov   eax,r_ax       ; ya,xe -> ye,xe
613
        shl   eax,16
614
        mov   ax,r_ax
615
        call  [draw_line]
616
 
617
        popad
618
        ret
619
 
620
 
621
drawwindow_III:
622
 
623
        pushad
624
 
625
        mov   edi,edx                              ; RECTANGLE
626
        mov   eax,[edi+0]
627
        shl   eax,16
628
        mov   ax,[edi+0]
629
        add   ax,[edi+8]
630
        mov   ebx,[edi+4]
631
        shl   ebx,16
632
        mov   bx,[edi+4]
633
        add   bx,[edi+12]
634
        mov   esi,[edi+24]
635
        shr   esi,1
636
        and   esi,0x007f7f7f
637
        push  esi
638
        call  draw_rectangle
639
        mov   ecx,3
640
      dw3l:
641
        add   eax,1*65536-1
642
        add   ebx,1*65536-1
643
        mov   esi,[edi+24]
644
        call  draw_rectangle
645
        dec   ecx
646
        jnz   dw3l
647
        pop   esi
648
        add   eax,1*65536-1
649
        add   ebx,1*65536-1
650
        call  draw_rectangle
651
 
652
        mov   ecx,[edx+20]                       ; GRAB BAR
653
        push  ecx
654
        mov   esi,edx
655
        mov   edx,[esi+04]
656
        add   edx,4
657
        mov   ebx,[esi+04]
658
        add   ebx,20
659
        mov   eax,[esi+04]
660
        add   eax,[esi+12]
661
        cmp   ebx,eax
662
        jb    wdsizeok2
663
        mov   ebx,eax
664
      wdsizeok2:
665
        push  ebx
666
      drwi2:
667
        mov   ebx,edx
668
        shl   ebx,16
669
        add   ebx,edx
670
        mov   eax,[esi+00]
671
        shl   eax,16
672
        add   eax,[esi+00]
673
        add   eax,[esi+8]
674
        add   eax,4*65536-4
675
        mov   ecx,[esi+20]
676
        test  ecx,0x40000000
677
        jz    nofa3
678
        add   ecx,0x040404
679
      nofa3:
680
        test  ecx,0x80000000
681
        jz    nofa2
682
        sub   ecx,0x040404
683
      nofa2:
684
        mov   [esi+20],ecx
685
        and   ecx,0xffffff
686
        xor   edi, edi
687
        call  [draw_line]
688
        inc   edx
689
        cmp   edx,[esp]
690
        jb    drwi2
691
        add   esp,4
692
        pop   ecx
693
        mov   [esi+20],ecx
694
 
695
        mov   edx,[esi+04]                       ; WORK AREA
696
        add   edx,21+5
697
        mov   ebx,[esi+04]
698
        add   ebx,[esi+12]
699
        cmp   edx,ebx
700
        jg    noinside2
701
        mov   eax,5
702
        mov   ebx,20
703
        mov   ecx,[esi+8]
704
        mov   edx,[esi+12]
705
        sub   ecx,4
706
        sub   edx,4
707
        mov   edi,[esi+16]
708
        call  [drawbar]
709
      noinside2:
710
 
711
        popad
712
 
713
        ret
714
 
715
 
716
 
717
; activate window
718
align 4
719
windowactivate:
720
 
721
        ; esi = abs mem position in stack 0xC400+
722
 
723
        pushad
33 mario79 724
        push   esi
1 ha 725
      movzx   eax, word [esi] ; ax <- process no
726
      movzx   eax, word [0xC000+eax*2] ; ax <- position in window stack
727
 
728
        xor   esi, esi        ; drop others
729
      waloop:
730
        cmp   esi, dword [0x3004]
731
        jae   wacont
732
        inc   esi
733
        lea   edi, [0xC000 + esi*2]
734
        mov   bx, [edi] ; position of the current process
735
        cmp   bx, ax
736
        jbe   @f
737
        dec   bx       ; upper? => drop!
738
        mov   [edi], bx
739
      @@:
740
        jmp   waloop
741
      wacont:
742
                            ; set to no 1
743
        pop   esi           ;   esi = pointer at 0xC400
744
 
745
      movzx   eax, word [esi]
746
        mov   bx, [0x3004]  ; number of processes
747
        mov   [0xC000+eax*2], bx     ; this is the last (and the upper)
748
 
749
;* start code - get active process (4) - Mario79
33 mario79 750
        cli
751
        cmp  [active_process_flag],1
752
        jne  @f
753
        mov   [active_process_flag],0
754
        jmp   end_save_active_process
755
    @@:
756
        call save_active_process_stack
757
    end_save_active_process:
758
        mov  [active_process],eax
759
        push  eax
760
        mov   eax,[active_process]
761
        shl   eax,5
762
        add   eax,0x3000
763
        mov   [eax-twdw+31],byte 1
764
        pop   eax
765
        sti
1 ha 766
;* end code - get active process (4) - Mario79
767
 
768
        ; update on screen -window stack
769
        xor   esi, esi
770
      waloop2:
771
        mov   edi, [0x3004]
772
        cmp   esi, edi
773
        jae   wacont2
774
        inc   esi
775
        movzx ebx, word [esi*2 + 0xC000]
776
        mov   [ebx*2 + 0xC400], si
777
        jmp   waloop2
778
      wacont2:
779
        mov   [0xf400], byte 0           ; empty keyboard buffer
780
        mov   [0xf500], byte 0           ; empty button buffer
781
        popad
782
        ret
783
 
784
 
785
; check if window is necessary to draw
786
 
787
checkwindowdraw:
788
 
789
        ; edi = position in window_data+
790
 
791
        mov   esi, edi
792
        sub   esi, window_data
793
        shr   esi, 5
794
 
795
        ; esi = process number
796
 
797
; 
798
        movzx eax, word [0xC000 + esi * 2] ; get value of the curr process
799
        lea   esi, [0xC400 + eax * 2]      ; get address of this process at 0xC400
800
; 
801
 
802
        push  esi
803
 
804
      .new_check:
805
 
806
        pop   esi
807
        add   esi, 2
808
        push  esi
809
 
810
        mov   eax, [0x3004]
811
        lea   eax, word [0xC400 + eax * 2] ; number of the upper window
812
 
813
        cmp   esi, eax
814
        ja    .all_wnds_to_top
815
 
816
        movzx eax, word [esi]
817
        shl   eax, 5
818
        add   eax, window_data
819
        mov   esi, eax
820
 
821
        mov   ebx, [edi+4]
822
        mov   edx, [edi+12]
823
        add   edx, ebx
824
 
825
        mov   ecx, [esi+4]    ; y check
826
        cmp   ecx, edx
827
        jae   .new_check
828
        mov   eax, [esi+12]
829
        add   ecx, eax
830
        cmp   ebx, ecx
831
        ja    .new_check
832
 
833
        mov   eax, [edi+0]
834
        mov   ecx, [edi+8]
835
        add   ecx, eax
836
 
837
        mov   edx, [esi+0]    ; x check
838
        cmp   edx, ecx
839
        jae   .new_check
840
        mov   ecx, [esi+8]
841
        add   edx, ecx
842
        cmp   eax, edx
843
        ja    .new_check
844
 
845
        pop   esi
846
        mov   ecx,1   ; overlap some window
847
        ret
848
 
849
  .all_wnds_to_top:
850
 
851
        pop   esi
852
 
853
        xor   ecx, ecx       ; passed all windows to top
854
        ret
855
 
856
 
857
 
858
 
859
waredraw:     ; if redraw necessary at activate
860
 
861
        pushad
862
 
863
        call  checkwindowdraw      ; draw window on activation ?
864
        test  ecx, ecx
865
        jz    .do_not_draw
866
 
867
        popad
868
        mov   [0xfb44], byte 1     ; do draw mouse
869
        call  windowactivate
870
 
871
        ; update screen info
872
        pushad
873
        mov   edi, [0x3004] ; the last process (number)
874
        movzx esi, word [0xC400 + edi * 2]
875
        shl   esi, 5
876
        add   esi, window_data
877
 
878
        ; coordinates of the upper window
879
        mov   eax, [esi+00] ; cx
880
        mov   ebx, [esi+04] ; cy
881
        mov   ecx, [esi+08] ; sx
882
        mov   edx, [esi+12] ; sy
883
 
884
        add   ecx, eax       ; ecx = x_end
885
        add   edx, ebx       ; edx = y_end
886
 
887
        mov   edi, [0x3004]
888
        movzx esi, word [0xC400 + edi * 2]
889
        shl   esi, 5
890
        movzx esi, byte [esi + 0x3000 + 0xE]
891
        call  setscreen ;;;calculatescreen ; setscreen
892
        popad
893
 
894
        cmp   [0xff01], dword 1 ; if > 1 then activate process
895
        jbe   .not_activate
896
 
897
;;;        mov   eax, 10            ; wait for putimages to finish
898
;;;        call  delay_hs
899
 
900
        mov   [edi+31],byte 1  ; redraw flag for app
901
        mov   [0xfb44],byte 0  ; mouse down checks
902
 
903
        ret
904
 
905
     .not_activate:
906
 
907
;        mov   eax,5            ; wait for putimages to finish
908
;        call  delay_hs
909
 
910
        mov   [edi+31],byte 1  ; redraw flag for app
911
 
912
        mov   ecx, 25 ;100
913
     .waitflagdown:
914
        dec   ecx
915
        jz    .nowait
33 mario79 916
;        mov   eax, 2
917
;        call  delay_hs
1 ha 918
        cmp   [edi+31], byte 0 ; wait flag to drop
919
        jnz   .waitflagdown
920
      .nowait:
921
 
922
;        mov   ecx,10
923
;      .wait:
924
;        mov   eax,1           ; wait for draw to finish
925
;        call  delay_hs
926
;        loop  .wait
927
 
928
        mov   [0xfb44],byte 0
929
 
930
        ret
931
 
932
     .do_not_draw:
933
 
934
        popad
935
 
936
        call  windowactivate
937
        mov   [0xfb44],byte 0  ; mouse down checks
938
        mov   [0xfff4],byte 0  ; no mouse background
939
        mov   [0xfff5],byte 0  ; draw mouse
940
        ret
941
 
942
 
943
iglobal
944
  window_moving   db 'K : Window - move/resize',13,10,0
945
  window_moved    db 'K : Window - done',13,10,0
946
endg
947
 
948
; check window touch
949
align 4
950
checkwindows:
951
        pushad
952
 
953
        cmp  [0xff01],dword 1  ; activate request from app ?
954
        jbe  .no_activate_request
955
        mov  edi,[0xff01]     ; process number
956
        shl  edi,5
957
        add  edi,window_data
958
        mov  ebx,[0xff01]
959
        movzx esi, word [0xC000 + ebx * 2]
960
        lea  esi, [0xC400 + esi * 2]
961
        call waredraw
962
 
963
;* start code - get active process (2) - Mario79
33 mario79 964
;        mov  eax,[0xff01]
965
;        mov  [active_process],eax
1 ha 966
;* end code - get active process  (2) - Mario79
967
 
968
        mov  [0xff01],dword 0  ; activated
969
 
970
        popad
971
        ret
972
 
973
    .no_activate_request:
974
 
975
        cmp   [0xfb40],byte 0    ; mouse buttons pressed ?
976
        jne   .mouse_buttons_pressed
977
;        cmp   [window_minimize],2
978
;        jne   .no_activate_request_1
979
        cmp   [window_minimize],0
980
        je   .no_activate_request_2
981
        cmp   [window_minimize],1
982
        je    .mouse_buttons_pressed
983
        mov   esi,[0x3004]
984
        movzx edi, word [0xC400 + esi * 2]
985
        shl   edi, 5
986
        add   edi, window_data
987
        cmp   [edi+12],dword 0
988
        je    .mouse_buttons_pressed
989
;        jne   .no_activate_request_2
990
;    .no_activate_request_1:
991
;        cmp   [window_minimize],1
992
;        jge   .mouse_buttons_pressed
993
;        jmp   .mouse_buttons_pressed
994
    .no_activate_request_2:
995
        mov   [window_minimize],0
996
        popad
997
        ret
998
 
999
    .mouse_buttons_pressed:
1000
 
1001
        mov   esi,[0x3004]
1002
        inc   esi
1003
 
1004
      cwloop:
1005
        cmp   esi,2
1006
        jb   .exit
1007
        .temp_window_minimize_1:
1008
        dec   esi
1009
        movzx edi, word [0xC400 + esi * 2] ; ebx
1010
        shl   edi, 5
1011
        add   edi, window_data
1012
;        mov   edi, ebx
1013
        mov   ecx, [edi+0]
1014
        mov   edx, [edi+4]
1015
 
1016
        mov   eax,ecx
1017
        mov   ebx,edx
1018
       cmp   [window_minimize],1
1019
       jge   .window_minimize_no_check_mouse
1020
 
1021
       movzx  eax, word [0xfb0a]
1022
       movzx  ebx, word [0xfb0c]
1023
 
1024
        cmp   ecx, eax
1025
        jae   cwloop
1026
        cmp   edx, ebx
1027
        jae   cwloop
1028
        add   ecx, [edi+8]
1029
        add   edx, [edi+12]
1030
        cmp   eax, ecx
1031
        jae   cwloop
1032
        cmp   ebx, edx
1033
        jae   cwloop
1034
 
1035
      .window_minimize_no_check_mouse:
1036
 
1037
        pushad
1038
        mov   eax, esi
1039
        mov   ebx, [0x3004]
1040
        cmp   eax, ebx      ; is this window active?
1041
        jz    .move_resize_window
1042
 
1043
        ; eax = position in windowing stack
1044
        ; redraw must ?
1045
        lea   esi, [0xC400 + esi * 2]
1046
        call  waredraw
1047
        add   esp, 32
1048
 
1049
      .exit:
1050
        popad
1051
        ret
1052
 
1053
   .move_resize_window:    ; MOVE OR RESIZE WINDOW
1054
 
1055
        popad
1056
 
1057
        ; Check for user enabled fixed window
1058
        mov   edx, [edi+0x14]
1059
        and   edx, 0x0f000000
1060
        cmp   edx, 0x01000000
1061
        jne   .window_move_enabled_for_user
1062
        popad
1063
        ret
1064
      .window_move_enabled_for_user:
1065
 
1066
        mov   [do_resize_from_corner],byte 0   ; resize for skinned window
1067
        mov   edx, [edi+0x10]
1068
        and   edx, 0x0f000000
1069
        cmp   edx, 0x02000000
1070
        jb    .no_resize_2 ; not type 2 wnd
1071
 
1072
        mov   edx, [edi+4]
1073
        add   edx, [edi+12]
1074
        sub   edx, 6       ; edx = y_end - 6
1075
        cmp   ebx, edx     ; ebx = mouse_y
1076
        jb    .no_resize_2
1077
        mov   [do_resize_from_corner],byte 1
1078
        jmp   .continue
1079
      .no_resize_2:
1080
 
1081
;// mike.dld [
1082
        mov   dl,[edi+0x10+3]
1083
        and   dl,0x0F
1084
        cmp   dl,0x03
1085
        jne   @f
1086
        mov   edx, [edi+4] ; check if touch on bar
1087
        add   edx, [_skinh]
1088
        cmp   ebx, edx
1089
        jae   .exit
1090
        jmp   .continue
1091
    @@:
1092
;// mike.dld ]
1093
 
1094
        mov   edx, [edi+4] ; check if touch on bar
1095
        add   edx, 21
1096
        cmp   ebx, edx
1097
        jae   .exit
1098
 
1099
     .continue:
1100
 
1101
        push  esi
1102
        mov   esi, window_moving
1103
        call  sys_msg_board_str
1104
        pop   esi
1105
 
1106
        mov   ecx, [timer_ticks] ;[0xfdf0]    ; double-click ?
1107
        mov   edx, ecx
1108
        sub   edx, [latest_window_touch]
1109
        mov   [latest_window_touch], ecx
1110
        mov   [latest_window_touch_delta], edx
1111
 
1112
        mov   cl, [0xfb40]     ; save for shade check
1113
        mov   [do_resize], cl
1114
        cmp  [window_minimize],0
1115
        je    no_emulation_righ_button
1116
        mov   [do_resize], byte 2
1117
     no_emulation_righ_button:
1118
        mov   ecx, [edi+0]
1119
        mov   edx, [edi+4]
1120
 
1121
        push  eax ecx edx
1122
        mov   [dlx], ecx      ; save for drawlimits
1123
        mov   [dly], edx
1124
        mov   eax, [edi+8]
1125
        add   ecx, eax
1126
        mov   eax, [edi+12]
1127
        add   edx, eax
1128
        mov   [dlxe], ecx
1129
        mov   [dlye], edx
1130
        pop   edx ecx eax
1131
 
1132
        sub   eax, ecx
1133
        sub   ebx, edx
1134
 
1135
        mov   esi, [0xfb0a]
1136
        mov   [0xf300], esi
1137
 
1138
        pushad           ; wait for putimages to finish
1139
;        mov   eax,5
1140
;        call  delay_hs
1141
        mov   eax,[edi+0]
1142
        mov   [npx],eax
1143
        mov   eax,[edi+4]
1144
        mov   [npy],eax
1145
        popad
1146
 
1147
        push eax                  ; save old coordinates
1148
        mov   ax,[edi+00]
1149
        mov   word [oldc+00],ax
1150
        mov   ax,[edi+04]
1151
        mov   word [oldc+04],ax
1152
        mov   ax,[edi+8]
1153
        mov   word [oldc+8],ax
1154
        mov   word [npxe],ax
1155
        mov   ax,[edi+12]
1156
        mov   word [oldc+12],ax
1157
        mov   word [npye],ax
1158
        pop eax
1159
 
1160
        call  drawwindowframes
1161
 
1162
        mov   [reposition],0
1163
        mov   [0xfb44],byte 1   ; no reaction to mouse up/down
1164
 
1165
        ; move window
1166
 
1167
      newchm:
1168
 
1169
        mov   [0xfff5],byte 1
1170
 
1171
        call  checkidle
1172
 
1173
        call  checkEgaCga
1174
 
1175
        mov   [0xfff4],byte 0
1176
 
1177
        call  [draw_pointer]
1178
 
1179
        pushad
1180
        call   stack_handler
1181
        popad
1182
 
1183
        mov   esi,[0xf300]
1184
        cmp   esi,[0xfb0a]
1185
        je    cwb
1186
 
1187
        mov   cx,[0xfb0a]
1188
        mov   dx,[0xfb0c]
1189
        sub   cx,ax
1190
        sub   dx,bx
1191
 
1192
        push  ax
1193
        push  bx
1194
 
1195
        call  drawwindowframes
1196
 
1197
        mov   ax,[0xfe00]
1198
        mov   bx,[0xfe04]
1199
 
1200
        cmp   [do_resize_from_corner],1
1201
        je    no_new_position
1202
 
1203
        mov   word [npx],word 0     ; x repos ?
1204
        cmp   ax,cx
1205
        jb    noreposx
1206
        mov   [reposition],1
1207
        sub   ax,word [npxe]
1208
        mov   word [npx],ax
1209
        cmp   ax,cx
1210
        jb    noreposx
1211
        mov   word [npx],cx
1212
      noreposx:
1213
 
1214
        mov   word [npy],word 0     ; y repos ?
1215
        cmp   bx,dx
1216
        jb    noreposy
1217
        mov   [reposition],1
1218
        sub   bx,word [npye]
1219
        mov   word [npy],bx
1220
        cmp   bx,dx
1221
        jb    noreposy
1222
        mov   word [npy],dx
1223
      noreposy:
1224
 
1225
      no_new_position:
1226
 
1227
        cmp   [do_resize_from_corner],0    ; resize from right corner
1228
        je    norepos_size
1229
        pushad
1230
 
1231
        mov   edx,edi
1232
        sub   edx,window_data
1233
        shr   edx,5
1234
        shl   edx,8
1235
        add   edx,0x80000                 ; process base at 0x80000+
1236
 
1237
        movzx eax,word [0xfb0a]
1238
        cmp   eax,[edi+0]
1239
        jb    nnepx
1240
        sub   eax,[edi+0]
1241
        cmp   eax,[edx+0x90+8]
1242
        jge   nnepx2
1243
        mov   eax,[edx+0x90+8]
1244
      nnepx2:
1245
        mov   [npxe],eax
1246
      nnepx:
1247
 
1248
        movzx eax,word [0xfb0c]
1249
        cmp   eax,[edi+4]
1250
        jb    nnepy
1251
        sub   eax,[edi+4]
1252
        cmp   eax,23 ; [edx+0x90+12]
1253
        jge   nnepy2
1254
        mov   eax,23 ; [edx+0x90+12]
1255
      nnepy2:
1256
        mov   [npye],eax
1257
      nnepy:
1258
 
1259
        mov   [reposition],1
1260
 
1261
        popad
1262
      norepos_size:
1263
 
1264
        pop   bx
1265
        pop   ax
1266
        call  drawwindowframes
1267
 
1268
        mov   esi,[0xfb0a]
1269
        mov   [0xf300],esi
1270
 
1271
      cwb:
1272
        cmp   [0xfb40],byte 0
1273
        jne   newchm
1274
                                     ; new position done
1275
        call  drawwindowframes
1276
        mov   [0xfff5],byte 1
1277
 
1278
        mov   eax,[npx]
1279
        mov   [edi+0],eax
1280
        mov   eax,[npy]
1281
        mov   [edi+4],eax
1282
        mov   eax,[npxe]
1283
        mov   [edi+8],eax
1284
        mov   eax,[npye]
1285
        mov   [edi+12],eax
1286
 
1287
        cmp   [reposition],1         ; save new X and Y start
1288
        jne   no_xy_save
1289
        ; 
1290
        push  esi edi ecx
1291
        mov   esi,edi
1292
        sub   edi,window_data
1293
        shr   edi,5
1294
        shl   edi,8
1295
        add   edi,0x80000+0x90
1296
        mov   ecx,2
1297
        cld
1298
        rep   movsd
1299
        pop   ecx edi esi
1300
        ; 
1301
      no_xy_save:
1302
 
1303
        pushad                             ; WINDOW SHADE/FULLSCREEN
1304
 
1305
        cmp   [reposition],1
1306
        je    no_window_sizing
1307
        mov   edx,edi
1308
        sub   edx,window_data
1309
        shr   edx,5
1310
        shl   edx,8
1311
        add   edx,0x80000                 ; process base at 0x80000+
1312
 
1313
        cmp   [do_resize],2               ; window shade ?
1314
        jb    no_window_shade
1315
        mov   [reposition],1
1316
 
1317
        cmp   [window_minimize],1
1318
        jge    for_window_minimize
1319
        cmp   [edi+12],dword 23
1320
        jle    window_shade_up
1321
        jmp   for_window_shade
1322
    for_window_minimize:
1323
        cmp   [edi+12],dword 0
1324
        je    window_shade_up
1325
    for_window_shade:
1326
        cmp   [window_minimize],0
1327
        je   no_window_minimize
1328
        cmp   [window_minimize],2
1329
        je   window_minimize_no_shade_full ;window_shade_up
1330
        mov   [edi+8],dword 0 ;66
1331
        mov   [edi+12],dword 0 ;279           ; on
1332
        jmp   no_window_shade
1333
  no_window_minimize:
1334
        mov   [edi+12],dword 23           ; on
1335
        jmp   no_window_shade
1336
      window_shade_up:
1337
        cmp   [window_minimize],1
1338
        jge   window_minimize_no_shade_full
1339
        mov   eax,[edi+0]
1340
        add   eax,[edi+4]
1341
        test  eax, eax
1342
        je    shade_full
1343
        push  edi
1344
        lea   esi, [edx + 0x90]
1345
        mov   ecx,4
1346
        cld
1347
        rep   movsd
1348
        pop   edi
1349
 
1350
    window_minimize_no_shade_full:
1351
;        mov   eax,[edx+0x90]              ; off
1352
;        mov   [edi+0],eax
1353
;        mov   eax,[edx+0x94]              ; off
1354
;        mov   [edi+4],eax
1355
;        mov   eax,[edx+0x98]              ; off
1356
;        mov   [edi+8],eax
1357
;        mov   eax,[edx+0x9C]              ; off
1358
;        mov   [edi+12],eax
1359
 
1360
        push  edi
1361
        lea   esi, [edx + 0x90]
1362
        mov   ecx,4
1363
        cld
1364
        rep   movsd
1365
        pop   edi
1366
        jmp   no_window_shade
1367
 
1368
      shade_full:
1369
;        mov   eax,[0xfe00]
1370
;        mov   [edi+8],eax
1371
        mov   eax,[0xfe04]
1372
        sub   eax,19
1373
        mov   [edi+12],eax
1374
      no_window_shade:
1375
 
1376
        cmp   [do_resize],1               ; fullscreen/restore ?
1377
        jne   no_fullscreen_restore
1378
        cmp   [latest_window_touch_delta],dword 50
1379
        jg    no_fullscreen_restore
1380
        mov   [reposition],1
1381
        mov   eax,[edi+12]
1382
        add   eax,19
1383
        cmp   eax,[0xfe04]
1384
        je    restore_from_fullscreen
1385
        mov   [edi+0],dword 0             ; set fullscreen
1386
        mov   [edi+4],dword 0
1387
        mov   eax,[0xfe00]
1388
        mov   [edi+8],eax
1389
        mov   eax,[0xfe04]
1390
        sub   eax,19
1391
        mov   [edi+12],eax
1392
        jmp   no_fullscreen_restore
1393
      restore_from_fullscreen:
1394
        push  edi                         ; restore
1395
;        mov   esi,edx
1396
;        add   esi,0x90
1397
        lea   esi, [edx + 0x90]
1398
        mov   ecx,4
1399
        cld
1400
        rep   movsd
1401
        pop   edi
1402
 
1403
      no_fullscreen_restore:
1404
 
1405
        mov   eax,[edi+4]                 ; check Y inside screen
1406
        add   eax,[edi+12]
1407
        cmp   eax,[0xfe04]
1408
        jbe   no_window_sizing
1409
        mov   eax,[edi+0]                 ; check X inside screen
1410
        add   eax,[edi+8]
1411
        cmp   eax,[0xfe00]
1412
        jbe   no_window_sizing
1413
        mov   eax,[0xfe00]
1414
        sub   eax,[edi+8]
1415
        mov   [edi+0],eax
1416
        mov   eax,[0xfe04]
1417
        sub   eax,[edi+12]
1418
        mov   [edi+4],eax
1419
      no_window_sizing:
1420
 
1421
        popad
1422
 
1423
        cmp   [reposition],0
1424
        je    retwm
1425
 
1426
        pushad
1427
        mov   eax,[edi+00]
1428
        mov   ebx,[edi+04]
1429
        mov   ecx,[edi+8]
1430
        mov   edx,[edi+12]
1431
        add   ecx,eax
1432
        add   edx,ebx
1433
        mov   edi,[0x3004]
1434
        shl   edi,1
1435
        add   edi,0xc400
1436
        movzx esi,byte [edi]
1437
        shl   esi,5
1438
        add   esi,0x3000+0xe
1439
        movzx esi,byte [esi]
1440
 
1441
        sub   edi,draw_data
1442
        shr   edi,5
1443
        shl   edi,8
1444
        add   edi,0x80000+0x80
1445
        ;cmp   [edi],dword 0
1446
        ;jne   no_rect_shaped_move
1447
        call  setscreen
1448
        jmp   move_calculated
1449
      no_rect_shaped_move:
1450
        call  calculatescreen
1451
      move_calculated:
1452
 
1453
        popad
1454
 
1455
        mov   [edi+31],byte 1 ; mark first as redraw
1456
        mov   [0xfff5],byte 1 ; no mouse
1457
 
1458
        push  eax ebx ecx edx
1459
        mov   eax,[oldc+00]
1460
        mov   ebx,[oldc+04]
1461
        mov   ecx,[oldc+8]
1462
        mov   edx,[oldc+12]
1463
        add   ecx,eax
1464
        add   edx,ebx
1465
        call  calculatescreen
1466
        pop   edx ecx ebx eax
1467
 
1468
        mov   eax,edi
1469
        call  redrawscreen
1470
 
1471
        mov   ecx,100         ; wait to avoid mouse residuals
1472
      waitre2:
1473
        mov   [0xfff5],byte 1
1474
        call  checkidle
1475
        cmp   [edi+31],byte 0
1476
        jz    retwm
1477
        loop  waitre2
1478
 
1479
      retwm:
1480
 
1481
        mov   [0xfff5],byte 0 ; mouse pointer
1482
        mov   [0xfff4],byte 0 ; no mouse under
1483
        mov   [0xfb44],byte 0 ; react to mouse up/down
1484
 
1485
        mov    esi,window_moved
1486
        call   sys_msg_board_str
1487
 
1488
        popad
1489
 
1490
       mov   [window_minimize],0
1491
;        sti
1492
        ret
1493
 
1494
;temp_mouse_1 dw 0
1495
;temp_mouse_2 dw 0
1496
 
1497
uglobal
1498
  add_window_data            dd  0
1499
  do_resize_from_corner      db  0x0
1500
  reposition                 db  0x0
1501
  latest_window_touch        dd  0x0
1502
  latest_window_touch_delta  dd  0x0
1503
 
1504
  do_resize db 0x0
1505
 
1506
  oldc    dd 0x0,0x0,0x0,0x0
1507
 
1508
  dlx     dd 0x0
1509
  dly     dd 0x0
1510
  dlxe    dd 0x0
1511
  dlye    dd 0x0
1512
 
1513
  npx     dd 0x0
1514
  npy     dd 0x0
1515
  npxe    dd 0x0
1516
  npye    dd 0x0
1517
 
1518
  mpx     dd 0x0
1519
  mpy     dd 0x0
1520
endg
1521
 
1522
 
1523
; draw negative window frames
1524
 
1525
drawwindowframes:
1526
 
1527
        pushad
1528
 
1529
        mov   eax,[npx]
1530
        shl   eax,16
1531
        add   eax,[npx]
1532
        add   eax,[npxe]
1533
        add   eax,65536*1-1
1534
        mov   ebx,[npy]
1535
        shl   ebx,16
1536
        add   ebx,[npy]
1537
        mov   ecx,0x01000000
1538
        push  edi
1539
        mov   edi,1
1540
        call  [draw_line]
1541
        pop   edi
1542
 
1543
        mov   eax,[npx]
1544
        shl   eax,16
1545
        add   eax,[npx]
1546
        add   eax,[npxe]
1547
        add   eax,65536*1-1
1548
        mov   ebx,[npy]
1549
        add   ebx,[npye]
1550
        shl   ebx,16
1551
        add   ebx,[npy]
1552
        add   ebx,[npye]
1553
        mov   ecx,0x01000000
1554
        push  edi
1555
        mov   edi,1
1556
        call  [draw_line]
1557
        pop   edi
1558
 
1559
        mov   eax,[npx]
1560
        shl   eax,16
1561
        add   eax,[npx]
1562
        mov   ebx,[npy]
1563
        shl   ebx,16
1564
        add   ebx,[npy]
1565
        add   ebx,[npye]
1566
        mov   ecx,0x01000000
1567
        push  edi
1568
        mov   edi,1
1569
        call  [draw_line]
1570
        pop   edi
1571
 
1572
        mov   eax,[npx]
1573
        add   eax,[npxe]
1574
        shl   eax,16
1575
        add   eax,[npx]
1576
        add   eax,[npxe]
1577
        mov   ebx,[npy]
1578
        shl   ebx,16
1579
        add   ebx,[npy]
1580
        add   ebx,[npye]
1581
        mov   ecx,0x01000000
1582
        push  edi
1583
        mov   edi,1
1584
        call  [draw_line]
1585
        mov   edi,[0x3000]
1586
        shl   edi,5
1587
        add   edi,window_data
1588
        mov   [edi+30],byte 1
1589
        pop   edi
1590
 
1591
        popad
1592
 
1593
        ret
1594
 
1595
 
1596
 
1597
random_shaped_window:
1598
 
1599
;
1600
;  eax = 0    giving address of data area
1601
;      ebx    address
1602
;  ebx = 1    shape area scale
1603
;      ebx    2^ebx scale
1604
 
1605
     test eax, eax
1606
     jne  rsw_no_address
1607
     mov  eax,[0x3000]
1608
     shl  eax,8
1609
 
1610
     mov  [eax+0x80000+0x80],ebx
1611
   rsw_no_address:
1612
 
1613
     cmp  eax,1
1614
     jne  rsw_no_scale
1615
     mov  eax,[0x3000]
1616
     shl  eax,8
1617
     mov  [eax+0x80000+0x84],bl
1618
   rsw_no_scale:
1619
 
1620
     ret
1621