Subversion Repositories Kolibri OS

Rev

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