Subversion Repositories Kolibri OS

Rev

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