Subversion Repositories Kolibri OS

Rev

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