Subversion Repositories Kolibri OS

Rev

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

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