Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2382 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;                                                              ;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
9
$Revision: 2382 $
10
 
11
;==============================================================================
12
;///// public functions ///////////////////////////////////////////////////////
13
;==============================================================================
14
 
15
window.BORDER_SIZE = 5
16
 
17
macro FuncTable name, table_name, [label]
18
{
19
  common
20
    align 4
21
    \label name#.#table_name dword
22
  forward
23
    dd name#.#label
24
  common
25
    name#.sizeof.#table_name = $ - name#.#table_name
26
}
27
 
28
uglobal
29
  common_colours rd 32
30
  draw_limits    RECT
31
endg
32
 
33
align 4
34
;------------------------------------------------------------------------------
35
syscall_draw_window: ;///// system function 0 /////////////////////////////////
36
;------------------------------------------------------------------------------
37
;? 
38
;------------------------------------------------------------------------------
39
        mov     eax, edx
40
        shr     eax, 24
41
        and     al, 0x0f
42
        cmp     al, 5
43
        jae     .exit
44
 
45
        push    eax
46
        inc     [mouse_pause]
47
        call    [_display.disable_mouse]
48
        call    window._.sys_set_window
49
        call    [_display.disable_mouse]
50
        pop     eax
51
 
52
        or      al, al
53
        jnz     @f
54
 
55
        ; type I - original style
56
        call    drawwindow_I
57
        jmp     window._.draw_window_caption.2
58
 
59
    @@:
60
        dec     al
61
        jnz     @f
62
 
63
        ; type II - only reserve area, no draw
64
        call    sys_window_mouse
65
        dec     [mouse_pause]
66
        call    [draw_pointer]
67
        jmp     .exit
68
 
69
    @@:
70
        dec     al
71
        jnz     @f
72
 
73
        ; type III  - new style
74
        call    drawwindow_III
75
        jmp     window._.draw_window_caption.2
76
 
77
        ; type IV & V - skinned window (resizable & not)
78
    @@:
79
        mov     eax, [TASK_COUNT]
80
        movzx   eax, word[WIN_POS + eax * 2]
81
        cmp     eax, [CURRENT_TASK]
82
        setz    al
83
        movzx   eax, al
84
        push    eax
85
        call    drawwindow_IV
86
        jmp     window._.draw_window_caption.2
87
 
88
  .exit:
89
        ret
90
 
91
align 4
92
;------------------------------------------------------------------------------
93
syscall_display_settings: ;///// system function 48 ///////////////////////////
94
;------------------------------------------------------------------------------
95
;; Redraw screen:
96
;< ebx = 0
97
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98
;; Set button style:
99
;< ebx = 1
100
;< ecx = 0 (flat) or 1 (with gradient)
101
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102
;; Set system color palette:
103
;< ebx = 2
104
;< ecx = pointer to color table
105
;< edx = size of color table
106
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
107
;; Get system color palette:
108
;< ebx = 3
109
;< ecx = pointer to color table buffer
110
;< edx = size of color table buffer
111
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
112
;; Get skinned caption height:
113
;< ebx = 4
114
;> eax = height in pixels
115
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
116
;; Get screen working area:
117
;< ebx = 5
118
;> eax = pack[16(left), 16(right)]
119
;> ebx = pack[16(top), 16(bottom)]
120
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
121
;; Set screen working area:
122
;< ebx = 6
123
;< ecx = pack[16(left), 16(right)]
124
;< edx = pack[16(top), 16(bottom)]
125
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
126
;; Get skin margins:
127
;< ebx = 7
128
;> eax = pack[16(left), 16(right)]
129
;> ebx = pack[16(top), 16(bottom)]
130
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
131
;; Set skin:
132
;< ebx = 8
133
;< ecx = pointer to FileInfoBlock struct
134
;> eax = FS error code
135
;------------------------------------------------------------------------------
136
        cmp     ebx, .sizeof.ftable / 4
137
        ja      @f
138
        jmp     [.ftable + ebx * 4]
139
    @@:
140
        ret
141
 
142
 
143
align 4
144
syscall_display_settings.00:
145
        xor     eax, eax
146
        inc     ebx
147
        cmp     [windowtypechanged], ebx
148
        jne     .exit
149
        mov     [windowtypechanged], eax
150
 
151
        jmp     syscall_display_settings._.redraw_whole_screen
152
 
153
  .exit:
154
        ret
155
 
156
align 4
157
syscall_display_settings.01:
158
        and     ecx, 1
159
        cmp     ecx, [buttontype]
160
        je      .exit
161
        mov     [buttontype], ecx
162
        mov     [windowtypechanged], ebx
163
 
164
  .exit:
165
        ret
166
 
167
align 4
168
syscall_display_settings.02:
169
        dec     ebx
170
        mov     esi, ecx
171
        and     edx, 127
172
        mov     edi, common_colours
173
        mov     ecx, edx
174
        rep movsb
175
        mov     [windowtypechanged], ebx
176
        ret
177
 
178
align 4
179
syscall_display_settings.03:
180
        mov     edi, ecx
181
        and     edx, 127
182
        mov     esi, common_colours
183
        mov     ecx, edx
184
        rep movsb
185
        ret
186
 
187
align 4
188
syscall_display_settings.04:
189
        mov     eax, [_skinh]
190
        mov     [esp + 32], eax
191
        ret
192
 
193
align 4
194
syscall_display_settings.05:
195
        mov     eax, [screen_workarea.left - 2]
196
        mov     ax, word[screen_workarea.right]
197
        mov     [esp + 32], eax
198
        mov     eax, [screen_workarea.top - 2]
199
        mov     ax, word[screen_workarea.bottom]
200
        mov     [esp + 20], eax
201
        ret
202
 
203
align 4
204
syscall_display_settings.06:
205
        xor     esi, esi
206
 
207
        mov     edi, [Screen_Max_X]
208
        mov     eax, ecx
209
        movsx   ebx, ax
210
        sar     eax, 16
211
        cmp     eax, ebx
212
        jge     .check_horizontal
213
        inc     esi
214
        or      eax, eax
215
        jge     @f
216
        xor     eax, eax
217
    @@:
218
        mov     [screen_workarea.left], eax
219
        cmp     ebx, edi
220
        jle     @f
221
        mov     ebx, edi
222
    @@:
223
        mov     [screen_workarea.right], ebx
224
 
225
  .check_horizontal:
226
        mov     edi, [Screen_Max_Y]
227
        mov     eax, edx
228
        movsx   ebx, ax
229
        sar     eax, 16
230
        cmp     eax, ebx
231
        jge     .check_if_redraw_needed
232
        inc     esi
233
        or      eax, eax
234
        jge     @f
235
        xor     eax, eax
236
    @@:
237
        mov     [screen_workarea.top], eax
238
        cmp     ebx, edi
239
        jle     @f
240
        mov     ebx, edi
241
    @@:
242
        mov     [screen_workarea.bottom], ebx
243
 
244
  .check_if_redraw_needed:
245
        or      esi, esi
246
        jz      .exit
247
 
248
        call    repos_windows
249
        jmp     syscall_display_settings._.calculate_whole_screen
250
 
251
  .exit:
252
        ret
253
 
254
align 4
255
syscall_display_settings.07:
256
        mov     eax, [_skinmargins + 0]
257
        mov     [esp + 32], eax
258
        mov     eax, [_skinmargins + 4]
259
        mov     [esp + 20], eax
260
        ret
261
 
262
align 4
263
syscall_display_settings.08:
264
        mov     ebx, ecx
265
        call    read_skin_file
266
        mov     [esp + 32], eax
267
        test    eax, eax
268
        jnz     .exit
269
 
270
        call    syscall_display_settings._.calculate_whole_screen
271
        jmp     syscall_display_settings._.redraw_whole_screen
272
 
273
  .exit:
274
        ret
275
 
276
syscall_display_settings._.calculate_whole_screen:
277
        xor     eax, eax
278
        xor     ebx, ebx
279
        mov     ecx, [Screen_Max_X]
280
        mov     edx, [Screen_Max_Y]
281
        jmp     calculatescreen
282
 
283
syscall_display_settings._.redraw_whole_screen:
284
        xor     eax, eax
285
        mov     [draw_limits.left], eax
286
        mov     [draw_limits.top], eax
287
        mov     eax, [Screen_Max_X]
288
        mov     [draw_limits.right], eax
289
        mov     eax, [Screen_Max_Y]
290
        mov     [draw_limits.bottom], eax
291
        mov     eax, window_data
292
        jmp     redrawscreen
293
 
294
align 4
295
;------------------------------------------------------------------------------
296
syscall_set_window_shape: ;///// system function 50 ///////////////////////////
297
;------------------------------------------------------------------------------
298
;; Set window shape address:
299
;> ebx = 0
300
;> ecx = shape data address
301
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
302
;; Set window shape scale:
303
;> ebx = 1
304
;> ecx = scale power (resulting scale is 2^ebx)
305
;------------------------------------------------------------------------------
306
        mov     edi, [current_slot]
307
 
308
        test    ebx, ebx
309
        jne     .shape_scale
310
        mov     [edi + APPDATA.wnd_shape], ecx
311
 
312
  .shape_scale:
313
        dec     ebx
314
        jnz     .exit
315
        mov     [edi + APPDATA.wnd_shape_scale], ecx
316
 
317
  .exit:
318
        ret
319
 
320
align 4
321
;------------------------------------------------------------------------------
322
syscall_move_window: ;///// system function 67 ////////////////////////////////
323
;------------------------------------------------------------------------------
324
;? 
325
;------------------------------------------------------------------------------
326
        mov     edi, [CURRENT_TASK]
327
        shl     edi, 5
328
        add     edi, window_data
329
 
330
        test    [edi + WDATA.fl_wdrawn], 1
331
        jz      .exit
332
 
333
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
334
        jnz     .exit
335
 
336
        cmp     ebx, -1
337
        jne     @f
338
        mov     ebx, [edi + WDATA.box.left]
339
    @@:
340
        cmp     ecx, -1
341
        jne     @f
342
        mov     ecx, [edi + WDATA.box.top]
343
    @@:
344
        cmp     edx, -1
345
        jne     @f
346
        mov     edx, [edi + WDATA.box.width]
347
    @@:
348
        cmp     esi, -1
349
        jne     @f
350
        mov     esi, [edi + WDATA.box.height]
351
 
352
    @@:
353
        push    esi edx ecx ebx
354
        mov     eax, esp
355
        mov     bl, [edi + WDATA.fl_wstate]
356
        call    window._.set_window_box
357
        add     esp, sizeof.BOX
358
 
359
        ; NOTE: do we really need this? to be reworked
360
;       mov     byte[DONT_DRAW_MOUSE], 0 ; mouse pointer
361
;       mov     byte[MOUSE_BACKGROUND], 0 ; no mouse under
362
;       mov     byte[MOUSE_DOWN], 0 ; react to mouse up/down
363
 
364
        ; NOTE: do we really need this? to be reworked
365
;       call    [draw_pointer]
366
 
367
  .exit:
368
        ret
369
 
370
align 4
371
;------------------------------------------------------------------------------
372
syscall_window_settings: ;///// system function 71 /////////////////////////////
373
;------------------------------------------------------------------------------
374
;? 
375
;------------------------------------------------------------------------------
376
        dec     ebx     ; subfunction #1 - set window caption
377
        jnz     .exit_fail
378
 
379
        ; NOTE: only window owner thread can set its caption,
380
        ;       so there's no parameter for PID/TID
381
 
382
        mov     edi, [CURRENT_TASK]
383
        shl     edi, 5
384
 
385
        mov     [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx
386
        or      [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
387
 
388
        call    window._.draw_window_caption
389
 
390
        xor     eax, eax ; eax = 0 (success)
391
        ret
392
 
393
;  .get_window_caption:
394
;        dec     eax     ; subfunction #2 - get window caption
395
;        jnz     .exit_fail
396
 
397
        ; not implemented yet
398
 
399
  .exit_fail:
400
        xor     eax, eax
401
        inc     eax     ; eax = 1 (fail)
402
        ret
403
 
404
align 4
405
;------------------------------------------------------------------------------
406
set_window_defaults: ;/////////////////////////////////////////////////////////
407
;------------------------------------------------------------------------------
408
;? 
409
;------------------------------------------------------------------------------
410
        mov     byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable
411
        push    eax ecx
412
        xor     eax, eax
413
        mov     ecx, WIN_STACK
414
    @@:
415
        inc     eax
416
        add     ecx, 2
417
        ; process no
418
        mov     [ecx + 0x000], ax
419
        ; positions in stack
420
        mov     [ecx + 0x400], ax
421
        cmp     ecx, WIN_POS - 2
422
        jne     @b
423
        pop     ecx eax
424
        ret
425
 
426
align 4
427
;------------------------------------------------------------------------------
428
calculatescreen: ;/////////////////////////////////////////////////////////////
429
;------------------------------------------------------------------------------
430
;? Scan all windows from bottom to top, calling `setscreen` for each one
431
;? intersecting given screen area
432
;------------------------------------------------------------------------------
433
;> eax = left
434
;> ebx = top
435
;> ecx = right
436
;> edx = bottom
437
;------------------------------------------------------------------------------
438
        push    esi
439
        pushfd
440
        cli
441
 
442
        mov     esi, 1
443
        call    window._.set_screen
444
 
445
        push    ebp
446
 
447
        mov     ebp, [TASK_COUNT]
448
        cmp     ebp, 1
449
        jbe     .exit
450
 
451
        push    edx ecx ebx eax
452
 
453
  .next_window:
454
        movzx   edi, word[WIN_POS + esi * 2]
455
        shl     edi, 5
456
 
457
        cmp     [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE
458
        je      .skip_window
459
 
460
        add     edi, window_data
461
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
462
        jnz     .skip_window
463
 
464
        mov     eax, [edi + WDATA.box.left]
465
        cmp     eax, [esp + RECT.right]
466
        jg      .skip_window
467
        mov     ebx, [edi + WDATA.box.top]
468
        cmp     ebx, [esp + RECT.bottom]
469
        jg      .skip_window
470
        mov     ecx, [edi + WDATA.box.width]
471
        add     ecx, eax
472
        cmp     ecx, [esp + RECT.left]
473
        jl      .skip_window
474
        mov     edx, [edi + WDATA.box.height]
475
        add     edx, ebx
476
        cmp     edx, [esp + RECT.top]
477
        jl      .skip_window
478
 
479
        cmp     eax, [esp + RECT.left]
480
        jae     @f
481
        mov     eax, [esp + RECT.left]
482
    @@:
483
        cmp     ebx, [esp + RECT.top]
484
        jae     @f
485
        mov     ebx, [esp + RECT.top]
486
    @@:
487
        cmp     ecx, [esp + RECT.right]
488
        jbe     @f
489
        mov     ecx, [esp + RECT.right]
490
    @@:
491
        cmp     edx, [esp + RECT.bottom]
492
        jbe     @f
493
        mov     edx, [esp + RECT.bottom]
494
 
495
    @@:
496
        push    esi
497
        movzx   esi, word[WIN_POS + esi * 2]
498
        call    window._.set_screen
499
        pop     esi
500
 
501
  .skip_window:
502
        inc     esi
503
        dec     ebp
504
        jnz     .next_window
505
 
506
        pop     eax ebx ecx edx
507
 
508
  .exit:
509
        pop     ebp
510
        popfd
511
        pop     esi
512
        ret
513
 
514
align 4
515
;------------------------------------------------------------------------------
516
repos_windows: ;///////////////////////////////////////////////////////////////
517
;------------------------------------------------------------------------------
518
;? 
519
;------------------------------------------------------------------------------
520
        mov     ecx, [TASK_COUNT]
521
        mov     edi, window_data + sizeof.WDATA * 2
522
        call    force_redraw_background
523
        dec     ecx
524
        jle     .exit
525
 
526
  .next_window:
527
        mov     [edi + WDATA.fl_redraw], 1
528
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
529
        jnz     .fix_maximized
530
 
531
        mov     eax, [edi + WDATA.box.left]
532
        add     eax, [edi + WDATA.box.width]
533
        mov     ebx, [Screen_Max_X]
534
        cmp     eax, ebx
535
        jle     .fix_vertical
536
        mov     eax, [edi + WDATA.box.width]
537
        sub     eax, ebx
538
        jle     @f
539
        mov     [edi + WDATA.box.width], ebx
540
    @@:
541
        sub     ebx, [edi + WDATA.box.width]
542
        mov     [edi + WDATA.box.left], ebx
543
 
544
  .fix_vertical:
545
        mov     eax, [edi + WDATA.box.top]
546
        add     eax, [edi + WDATA.box.height]
547
        mov     ebx, [Screen_Max_Y]
548
        cmp     eax, ebx
549
        jle     .fix_client_box
550
        mov     eax, [edi + WDATA.box.height]
551
        sub     eax, ebx
552
        jle     @f
553
        mov     [edi + WDATA.box.height], ebx
554
    @@:
555
        sub     ebx, [edi + WDATA.box.height]
556
        mov     [edi + WDATA.box.top], ebx
557
        jmp     .fix_client_box
558
 
559
  .fix_maximized:
560
        mov     eax, [screen_workarea.left]
561
        mov     [edi + WDATA.box.left], eax
562
        sub     eax, [screen_workarea.right]
563
        neg     eax
564
        mov     [edi + WDATA.box.width], eax
565
        mov     eax, [screen_workarea.top]
566
        mov     [edi + WDATA.box.top], eax
567
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
568
        jnz     .fix_client_box
569
        sub     eax, [screen_workarea.bottom]
570
        neg     eax
571
        mov     [edi + WDATA.box.height], eax
572
 
573
  .fix_client_box:
574
        call    window._.set_window_clientbox
575
 
576
        add     edi, sizeof.WDATA
577
        loop    .next_window
578
 
579
  .exit:
580
        ret
581
 
582
align 4
583
;------------------------------------------------------------------------------
584
sys_window_mouse: ;////////////////////////////////////////////////////////////
585
;------------------------------------------------------------------------------
586
;? 
587
;------------------------------------------------------------------------------
588
        ; NOTE: commented out since doesn't provide necessary functionality
589
        ;       anyway, to be reworked
590
;       push    eax
591
;
592
;       mov     eax, [timer_ticks]
593
;       cmp     [new_window_starting], eax
594
;       jb      .exit
595
;
596
;       mov     byte[MOUSE_BACKGROUND], 0
597
;       mov     byte[DONT_DRAW_MOUSE], 0
598
;
599
;       mov     [new_window_starting], eax
600
;
601
; .exit:
602
;       pop     eax
603
        ret
604
 
605
align 4
606
;------------------------------------------------------------------------------
607
draw_rectangle: ;//////////////////////////////////////////////////////////////
608
;------------------------------------------------------------------------------
609
;> eax = pack[16(left), 16(right)]
610
;> ebx = pack[16(top), 16(bottom)]
611
;> esi = color
612
;------------------------------------------------------------------------------
613
        push    eax ebx ecx edi
614
 
615
        xor     edi, edi
616
 
617
  .flags_set:
618
        push    ebx
619
 
620
        ; set line color
621
        mov     ecx, esi
622
 
623
        ; draw top border
624
        rol     ebx, 16
625
        push    ebx
626
        rol     ebx, 16
627
        pop     bx
628
        call    [draw_line]
629
 
630
        ; draw bottom border
631
        mov     ebx, [esp - 2]
632
        pop     bx
633
        call    [draw_line]
634
 
635
        pop     ebx
636
        add     ebx, 1 * 65536 - 1
637
 
638
        ; draw left border
639
        rol     eax, 16
640
        push    eax
641
        rol     eax, 16
642
        pop     ax
643
        call    [draw_line]
644
 
645
        ; draw right border
646
        mov     eax, [esp - 2]
647
        pop     ax
648
        call    [draw_line]
649
 
650
        pop     edi ecx ebx eax
651
        ret
652
 
653
  .forced:
654
        push    eax ebx ecx edi
655
        xor     edi, edi
656
        inc     edi
657
        jmp     .flags_set
658
 
659
align 4
660
;------------------------------------------------------------------------------
661
drawwindow_I_caption: ;////////////////////////////////////////////////////////
662
;------------------------------------------------------------------------------
663
;? 
664
;------------------------------------------------------------------------------
665
        push    [edx + WDATA.cl_titlebar]
666
        mov     esi, edx
667
 
668
        mov     edx, [esi + WDATA.box.top]
669
        mov     eax, edx
670
        lea     ebx, [edx + 21]
671
        inc     edx
672
        add     eax, [esi + WDATA.box.height]
673
 
674
        cmp     ebx, eax
675
        jbe     @f
676
        mov     ebx, eax
677
    @@:
678
        push    ebx
679
 
680
        xor     edi, edi
681
 
682
  .next_line:
683
        mov     ebx, edx
684
        shl     ebx, 16
685
        add     ebx, edx
686
        mov     eax, [esi + WDATA.box.left]
687
        inc     eax
688
        shl     eax, 16
689
        add     eax, [esi + WDATA.box.left]
690
        add     eax, [esi + WDATA.box.width]
691
        dec     eax
692
        mov     ecx, [esi + WDATA.cl_titlebar]
693
        test    ecx, 0x80000000
694
        jz      @f
695
        sub     ecx, 0x00040404
696
        mov     [esi + WDATA.cl_titlebar], ecx
697
    @@:
698
        and     ecx, 0x00ffffff
699
        call    [draw_line]
700
        inc     edx
701
        cmp     edx, [esp]
702
        jb      .next_line
703
 
704
        add     esp, 4
705
        pop     [esi + WDATA.cl_titlebar]
706
        ret
707
 
708
align 4
709
;------------------------------------------------------------------------------
710
drawwindow_I: ;////////////////////////////////////////////////////////////////
711
;------------------------------------------------------------------------------
712
;? 
713
;------------------------------------------------------------------------------
714
        pushad
715
 
716
        ; window border
717
 
718
        mov     eax, [edx + WDATA.box.left - 2]
719
        mov     ax, word[edx + WDATA.box.left]
720
        add     ax, word[edx + WDATA.box.width]
721
        mov     ebx, [edx + WDATA.box.top - 2]
722
        mov     bx, word[edx + WDATA.box.top]
723
        add     bx, word[edx + WDATA.box.height]
724
 
725
        mov     esi, [edx + WDATA.cl_frames]
726
        call    draw_rectangle
727
 
728
        ; window caption
729
 
730
        call    drawwindow_I_caption
731
 
732
        ; window client area
733
 
734
        ; do we need to draw it?
735
        mov     edi, [esi + WDATA.cl_workarea]
736
        test    edi, 0x40000000
737
        jnz     .exit
738
 
739
        ; does client area have a positive size on screen?
740
        mov     edx, [esi + WDATA.box.top]
741
        add     edx, 21 + 5
742
        mov     ebx, [esi + WDATA.box.top]
743
        add     ebx, [esi + WDATA.box.height]
744
        cmp     edx, ebx
745
        jg      .exit
746
 
747
        ; okay, let's draw it
748
        mov     eax, 1
749
        mov     ebx, 21
750
        mov     ecx, [esi + WDATA.box.width]
751
        mov     edx, [esi + WDATA.box.height]
752
        call    [drawbar]
753
 
754
  .exit:
755
        popad
756
        ret
757
 
758
align 4
759
;------------------------------------------------------------------------------
760
drawwindow_III_caption: ;/////////////////////////////////////////////////////
761
;------------------------------------------------------------------------------
762
;? 
763
;------------------------------------------------------------------------------
764
        mov     ecx, [edx + WDATA.cl_titlebar]
765
        push    ecx
766
        mov     esi, edx
767
        mov     edx, [esi + WDATA.box.top]
768
        add     edx, 4
769
        mov     ebx, [esi + WDATA.box.top]
770
        add     ebx, 20
771
        mov     eax, [esi + WDATA.box.top]
772
        add     eax, [esi + WDATA.box.height]
773
 
774
        cmp     ebx, eax
775
        jb      @f
776
        mov     ebx, eax
777
    @@:
778
        push    ebx
779
 
780
        xor     edi, edi
781
 
782
  .next_line:
783
        mov     ebx, edx
784
        shl     ebx, 16
785
        add     ebx, edx
786
        mov     eax, [esi + WDATA.box.left]
787
        shl     eax, 16
788
        add     eax, [esi + WDATA.box.left]
789
        add     eax, [esi + WDATA.box.width]
790
        add     eax, 4 * 65536 - 4
791
        mov     ecx, [esi + WDATA.cl_titlebar]
792
        test    ecx, 0x40000000
793
        jz      @f
794
        add     ecx, 0x00040404
795
    @@:
796
        test    ecx, 0x80000000
797
        jz      @f
798
        sub     ecx, 0x00040404
799
    @@:
800
        mov     [esi + WDATA.cl_titlebar], ecx
801
        and     ecx, 0x00ffffff
802
        call    [draw_line]
803
        inc     edx
804
        cmp     edx, [esp]
805
        jb      .next_line
806
 
807
        add     esp, 4
808
        pop     [esi + WDATA.cl_titlebar]
809
        ret
810
 
811
align 4
812
;------------------------------------------------------------------------------
813
drawwindow_III: ;//////////////////////////////////////////////////////////////
814
;------------------------------------------------------------------------------
815
;? 
816
;------------------------------------------------------------------------------
817
        pushad
818
 
819
        ; window border
820
 
821
        mov     eax, [edx + WDATA.box.left - 2]
822
        mov     ax, word[edx + WDATA.box.left]
823
        add     ax, word[edx + WDATA.box.width]
824
        mov     ebx, [edx + WDATA.box.top - 2]
825
        mov     bx, word[edx + WDATA.box.top]
826
        add     bx, word[edx + WDATA.box.height]
827
 
828
        mov     esi, [edx + WDATA.cl_frames]
829
        shr     esi, 1
830
        and     esi, 0x007f7f7f
831
        call    draw_rectangle
832
 
833
        push    esi
834
        mov     ecx, 3
835
        mov     esi, [edx + WDATA.cl_frames]
836
 
837
  .next_frame:
838
        add     eax, 1 * 65536 - 1
839
        add     ebx, 1 * 65536 - 1
840
        call    draw_rectangle
841
        dec     ecx
842
        jnz     .next_frame
843
 
844
        pop     esi
845
        add     eax, 1 * 65536 - 1
846
        add     ebx, 1 * 65536 - 1
847
        call    draw_rectangle
848
 
849
        ; window caption
850
 
851
        call    drawwindow_III_caption
852
 
853
        ; window client area
854
 
855
        ; do we need to draw it?
856
        mov     edi, [esi + WDATA.cl_workarea]
857
        test    edi, 0x40000000
858
        jnz     .exit
859
 
860
        ; does client area have a positive size on screen?
861
        mov     edx, [esi + WDATA.box.top]
862
        add     edx, 21 + 5
863
        mov     ebx, [esi + WDATA.box.top]
864
        add     ebx, [esi + WDATA.box.height]
865
        cmp     edx, ebx
866
        jg      .exit
867
 
868
        ; okay, let's draw it
869
        mov     eax, 5
870
        mov     ebx, 20
871
        mov     ecx, [esi + WDATA.box.width]
872
        mov     edx, [esi + WDATA.box.height]
873
        sub     ecx, 4
874
        sub     edx, 4
875
        call    [drawbar]
876
 
877
  .exit:
878
        popad
879
        ret
880
 
881
align 4
882
;------------------------------------------------------------------------------
883
waredraw: ;////////////////////////////////////////////////////////////////////
884
;------------------------------------------------------------------------------
885
;? Activate window, redrawing if necessary
886
;------------------------------------------------------------------------------
887
        push    -1
888
        mov     eax, [TASK_COUNT]
889
        lea     eax, [WIN_POS + eax * 2]
890
        cmp     eax, esi
891
        pop     eax
892
        je      .exit
893
 
894
        ; is it overlapped by another window now?
895
        push    ecx
896
        call    window._.check_window_draw
897
        test    ecx, ecx
898
        pop     ecx
899
        jz      .do_not_draw
900
 
901
        ; yes it is, activate and update screen buffer
902
        mov     byte[MOUSE_DOWN], 1
903
        call    window._.window_activate
904
 
905
        pushad
906
        mov     edi, [TASK_COUNT]
907
        movzx   esi, word[WIN_POS + edi * 2]
908
        shl     esi, 5
909
        add     esi, window_data
910
 
911
        mov     eax, [esi + WDATA.box.left]
912
        mov     ebx, [esi + WDATA.box.top]
913
        mov     ecx, [esi + WDATA.box.width]
914
        mov     edx, [esi + WDATA.box.height]
915
 
916
        add     ecx, eax
917
        add     edx, ebx
918
 
919
        mov     edi, [TASK_COUNT]
920
        movzx   esi, word[WIN_POS + edi * 2]
921
        call    window._.set_screen
922
        popad
923
 
924
        ; tell application to redraw itself
925
        mov     [edi + WDATA.fl_redraw], 1
926
        xor     eax, eax
927
        jmp     .exit
928
 
929
  .do_not_draw:
930
        ; no it's not, just activate the window
931
        call    window._.window_activate
932
        xor     eax, eax
933
        mov     byte[MOUSE_BACKGROUND], al
934
        mov     byte[DONT_DRAW_MOUSE], al
935
 
936
 
937
  .exit:
938
        mov     byte[MOUSE_DOWN], 0
939
        inc     eax
940
        ret
941
 
942
align 4
943
;------------------------------------------------------------------------------
944
minimize_window: ;/////////////////////////////////////////////////////////////
945
;------------------------------------------------------------------------------
946
;> eax = window number on screen
947
;------------------------------------------------------------------------------
948
;# corrupts [dl*]
949
;------------------------------------------------------------------------------
950
        push    edi
951
        pushfd
952
        cli
953
 
954
        ; is it already minimized?
955
        movzx   edi, word[WIN_POS + eax * 2]
956
        shl     edi, 5
957
        add     edi, window_data
958
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
959
        jnz     .exit
960
 
961
        push    eax ebx ecx edx esi
962
 
963
        ; no it's not, let's do that
964
        or      [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
965
        mov     eax, [edi + WDATA.box.left]
966
        mov     [draw_limits.left], eax
967
        mov     ecx, eax
968
        add     ecx, [edi + WDATA.box.width]
969
        mov     [draw_limits.right], ecx
970
        mov     ebx, [edi + WDATA.box.top]
971
        mov     [draw_limits.top], ebx
972
        mov     edx, ebx
973
        add     edx, [edi + WDATA.box.height]
974
        mov     [draw_limits.bottom], edx
975
        call    calculatescreen
976
        xor     esi, esi
977
        xor     eax, eax
978
        call    redrawscreen
979
 
980
        pop     esi edx ecx ebx eax
981
 
982
  .exit:
983
        popfd
984
        pop     edi
985
        ret
986
 
987
align 4
988
;------------------------------------------------------------------------------
989
restore_minimized_window: ;////////////////////////////////////////////////////
990
;------------------------------------------------------------------------------
991
;> eax = window number on screen
992
;------------------------------------------------------------------------------
993
;# corrupts [dl*]
994
;------------------------------------------------------------------------------
995
        pushad
996
        pushfd
997
        cli
998
 
999
        ; is it already restored?
1000
        movzx   esi, word[WIN_POS + eax * 2]
1001
        mov     edi, esi
1002
        shl     edi, 5
1003
        add     edi, window_data
1004
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
1005
        jz      .exit
1006
 
1007
        ; no it's not, let's do that
1008
        mov     [edi + WDATA.fl_redraw], 1
1009
        and     [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED
1010
        mov     ebp, window._.set_screen
1011
        cmp     eax, [TASK_COUNT]
1012
        jz      @f
1013
        mov     ebp, calculatescreen
1014
    @@:
1015
        mov     eax, [edi + WDATA.box.left]
1016
        mov     ebx, [edi + WDATA.box.top]
1017
        mov     ecx, [edi + WDATA.box.width]
1018
        mov     edx, [edi + WDATA.box.height]
1019
        add     ecx, eax
1020
        add     edx, ebx
1021
        call    ebp
1022
 
1023
        mov     byte[MOUSE_BACKGROUND], 0
1024
 
1025
  .exit:
1026
        popfd
1027
        popad
1028
        ret
1029
 
1030
align 4
1031
; TODO: remove this proc
1032
;------------------------------------------------------------------------------
1033
window_check_events: ;/////////////////////////////////////////////////////////
1034
;------------------------------------------------------------------------------
1035
;? 
1036
;------------------------------------------------------------------------------
1037
        ; do we have window minimize/restore request?
1038
        cmp     [window_minimize], 0
1039
        je      .exit
1040
 
1041
        ; okay, minimize or restore top-most window and exit
1042
        mov     eax, [TASK_COUNT]
1043
        mov     bl, 0
1044
        xchg    [window_minimize], bl
1045
        dec     bl
1046
        jnz     @f
1047
        call    minimize_window
1048
        jmp     .exit
1049
 
1050
    @@:
1051
        call    restore_minimized_window
1052
 
1053
  .exit:
1054
        ret
1055
 
1056
align 4
1057
;------------------------------------------------------------------------------
1058
sys_window_maximize_handler: ;/////////////////////////////////////////////////
1059
;------------------------------------------------------------------------------
1060
;? 
1061
;------------------------------------------------------------------------------
1062
;> esi = process slot
1063
;------------------------------------------------------------------------------
1064
        mov     edi, esi
1065
        shl     edi, 5
1066
        add     edi, window_data
1067
 
1068
        ; can window change its height?
1069
        ; only types 2 and 3 can be resized
1070
        mov     dl, [edi + WDATA.fl_wstyle]
1071
        test    dl, 2
1072
        jz      .exit
1073
 
1074
        ; toggle normal/maximized window state
1075
        mov     bl, [edi + WDATA.fl_wstate]
1076
        xor     bl, WSTATE_MAXIMIZED
1077
 
1078
        ; calculate and set appropriate window bounds
1079
        test    bl, WSTATE_MAXIMIZED
1080
        jz      .restore_size
1081
 
1082
        mov     eax, [screen_workarea.left]
1083
        mov     ecx, [screen_workarea.top]
1084
        push    [screen_workarea.bottom] \
1085
                [screen_workarea.right] \
1086
                ecx \
1087
                eax
1088
        sub     [esp + BOX.width], eax
1089
        sub     [esp + BOX.height], ecx
1090
        mov     eax, esp
1091
        jmp     .set_box
1092
 
1093
  .restore_size:
1094
        mov     eax, esi
1095
        shl     eax, 8
1096
        add     eax, SLOT_BASE + APPDATA.saved_box
1097
        push    [eax + BOX.height] \
1098
                [eax + BOX.width] \
1099
                [eax + BOX.top] \
1100
                [eax + BOX.left]
1101
        mov     eax, esp
1102
 
1103
  .set_box:
1104
        test    bl, WSTATE_ROLLEDUP
1105
        jz      @f
1106
 
1107
        xchg    eax, ecx
1108
        call    window._.get_rolledup_height
1109
        mov     [ecx + BOX.height], eax
1110
        xchg    eax, ecx
1111
 
1112
    @@:
1113
        call    window._.set_window_box
1114
        add     esp, sizeof.BOX
1115
 
1116
  .exit:
1117
        ret
1118
 
1119
align 4
1120
;------------------------------------------------------------------------------
1121
sys_window_rollup_handler: ;///////////////////////////////////////////////////
1122
;------------------------------------------------------------------------------
1123
;? 
1124
;------------------------------------------------------------------------------
1125
;> esi = process slot
1126
;------------------------------------------------------------------------------
1127
        mov     edx, esi
1128
        shl     edx, 8
1129
        add     edx, SLOT_BASE
1130
 
1131
        ; toggle normal/rolled up window state
1132
        mov     bl, [edi + WDATA.fl_wstate]
1133
        xor     bl, WSTATE_ROLLEDUP
1134
 
1135
        ; calculate and set appropriate window bounds
1136
        test    bl, WSTATE_ROLLEDUP
1137
        jz      .restore_size
1138
 
1139
        call    window._.get_rolledup_height
1140
        push    eax \
1141
                [edi + WDATA.box.width] \
1142
                [edi + WDATA.box.top] \
1143
                [edi + WDATA.box.left]
1144
        mov     eax, esp
1145
        jmp     .set_box
1146
 
1147
  .restore_size:
1148
        test    bl, WSTATE_MAXIMIZED
1149
        jnz     @f
1150
        add     esp, -sizeof.BOX
1151
        lea     eax, [edx + APPDATA.saved_box]
1152
        jmp     .set_box
1153
 
1154
    @@:
1155
        mov     eax, [screen_workarea.top]
1156
        push    [screen_workarea.bottom] \
1157
                [edi + WDATA.box.width] \
1158
                eax \
1159
                [edi + WDATA.box.left]
1160
        sub     [esp + BOX.height], eax
1161
        mov     eax, esp
1162
 
1163
  .set_box:
1164
        call    window._.set_window_box
1165
        add     esp, sizeof.BOX
1166
 
1167
        ret
1168
 
1169
align 4
1170
;------------------------------------------------------------------------------
1171
sys_window_start_moving_handler: ;/////////////////////////////////////////////
1172
;------------------------------------------------------------------------------
1173
;? 
1174
;------------------------------------------------------------------------------
1175
;> eax = old (original) window box
1176
;> esi = process slot
1177
;------------------------------------------------------------------------------
1178
        mov     edi, eax
1179
        call    window._.draw_negative_box
1180
 
1181
        ret
1182
 
1183
align 4
1184
;------------------------------------------------------------------------------
1185
sys_window_end_moving_handler: ;///////////////////////////////////////////////
1186
;------------------------------------------------------------------------------
1187
;? 
1188
;------------------------------------------------------------------------------
1189
;> eax = old (original) window box
1190
;> ebx = new (final) window box
1191
;> esi = process slot
1192
;------------------------------------------------------------------------------
1193
        mov     edi, ebx
1194
        call    window._.end_moving__box
1195
 
1196
        mov     edi, esi
1197
        shl     edi, 5
1198
        add     edi, window_data
1199
 
1200
        mov     eax, ebx
1201
        mov     bl, [edi + WDATA.fl_wstate]
1202
        call    window._.set_window_box
1203
        ret
1204
 
1205
align 4
1206
;------------------------------------------------------------------------------
1207
sys_window_moving_handler: ;///////////////////////////////////////////////////
1208
;------------------------------------------------------------------------------
1209
;? 
1210
;------------------------------------------------------------------------------
1211
;> eax = old (from previous call) window box
1212
;> ebx = new (current) window box
1213
;> esi = process_slot
1214
;------------------------------------------------------------------------------
1215
        mov     edi, eax
1216
        call    window._.draw_negative_box
1217
        mov     edi, ebx
1218
        call    window._.draw_negative_box
1219
        ret
1220
 
1221
;==============================================================================
1222
;///// private functions //////////////////////////////////////////////////////
1223
;==============================================================================
1224
 
1225
iglobal
1226
  FuncTable syscall_display_settings, ftable, \
1227
    00, 01, 02, 03, 04, 05, 06, 07, 08
1228
 
1229
  align 4
1230
  window_topleft dd \
1231
    1, 21, \ ;type 0
1232
    0,  0, \ ;type 1
1233
    5, 20, \ ;type 2
1234
    5,  ?, \ ;type 3 {set by skin}
1235
    5,  ?    ;type 4 {set by skin}
1236
endg
1237
 
1238
;uglobal
1239
  ; NOTE: commented out since doesn't provide necessary functionality anyway,
1240
  ;       to be reworked
1241
; new_window_starting       dd ?
1242
;endg
1243
 
1244
align 4
1245
;------------------------------------------------------------------------------
1246
window._.invalidate_screen: ;//////////////////////////////////////////////////
1247
;------------------------------------------------------------------------------
1248
;? 
1249
;------------------------------------------------------------------------------
1250
;> eax = old (original) window box
1251
;> ebx = new (final) window box
1252
;> edi = pointer to WDATA struct
1253
;------------------------------------------------------------------------------
1254
        push    eax ebx
1255
 
1256
        ; TODO: do we really need `draw_limits`?
1257
        ; Yes, they are used by background drawing code.
1258
        mov     ecx, [eax + BOX.left]
1259
        mov     edx, [ebx + BOX.left]
1260
        cmp     ecx, edx
1261
        jle     @f
1262
        mov     ecx, edx
1263
    @@:
1264
        mov     [draw_limits.left], ecx
1265
        mov     ecx, [eax + BOX.left]
1266
        add     ecx, [eax + BOX.width]
1267
        add     edx, [ebx + BOX.width]
1268
        cmp     ecx, edx
1269
        jae     @f
1270
        mov     ecx, edx
1271
    @@:
1272
        mov     [draw_limits.right], ecx
1273
        mov     ecx, [eax + BOX.top]
1274
        mov     edx, [ebx + BOX.top]
1275
        cmp     ecx, edx
1276
        jle     @f
1277
        mov     ecx, edx
1278
    @@:
1279
        mov     [draw_limits.top], ecx
1280
        mov     ecx, [eax + BOX.top]
1281
        add     ecx, [eax + BOX.height]
1282
        add     edx, [ebx + BOX.height]
1283
        cmp     ecx, edx
1284
        jae     @f
1285
        mov     ecx, edx
1286
    @@:
1287
        mov     [draw_limits.bottom], ecx
1288
 
1289
        ; recalculate screen buffer at old position
1290
        push    ebx
1291
        mov     edx, [eax + BOX.height]
1292
        mov     ecx, [eax + BOX.width]
1293
        mov     ebx, [eax + BOX.top]
1294
        mov     eax, [eax + BOX.left]
1295
        add     ecx, eax
1296
        add     edx, ebx
1297
        call    calculatescreen
1298
        pop     eax
1299
 
1300
        ; recalculate screen buffer at new position
1301
        mov     edx, [eax + BOX.height]
1302
        mov     ecx, [eax + BOX.width]
1303
        mov     ebx, [eax + BOX.top]
1304
        mov     eax, [eax + BOX.left]
1305
        add     ecx, eax
1306
        add     edx, ebx
1307
        call    calculatescreen
1308
 
1309
        mov     eax, edi
1310
        call    redrawscreen
1311
 
1312
        ; tell window to redraw itself
1313
        mov     [edi + WDATA.fl_redraw], 1
1314
 
1315
        pop     ebx eax
1316
        ret
1317
 
1318
align 4
1319
;------------------------------------------------------------------------------
1320
window._.set_window_box: ;/////////////////////////////////////////////////////
1321
;------------------------------------------------------------------------------
1322
;? 
1323
;------------------------------------------------------------------------------
1324
;> eax = pointer to BOX struct
1325
;> bl = new window state flags
1326
;> edi = pointer to WDATA struct
1327
;------------------------------------------------------------------------------
1328
        push    eax ebx esi
1329
 
1330
; don't do anything if the new box is identical to the old
1331
        cmp     bl, [edi + WDATA.fl_wstate]
1332
        jnz     @f
1333
        mov     esi, eax
1334
        push    edi
1335
if WDATA.box
1336
        add     edi, WDATA.box
1337
end if
1338
        mov     ecx, 4
1339
        repz cmpsd
1340
        pop     edi
1341
        jz      .exit
1342
@@:
1343
 
1344
        add     esp, -sizeof.BOX
1345
 
1346
        mov     ebx, esp
1347
if WDATA.box
1348
        lea     esi, [edi + WDATA.box]
1349
else
1350
        mov     esi, edi ; optimization for WDATA.box = 0
1351
end if
1352
        xchg    eax, esi
1353
        mov     ecx, sizeof.BOX
1354
        call    memmove
1355
        xchg    eax, esi
1356
        xchg    ebx, esi
1357
        call    memmove
1358
        mov     eax, ebx
1359
        mov     ebx, esi
1360
 
1361
        call    window._.check_window_position
1362
        call    window._.set_window_clientbox
1363
        call    window._.invalidate_screen
1364
 
1365
        add     esp, sizeof.BOX
1366
 
1367
        mov     cl, [esp + 4]
1368
        mov     ch, cl
1369
        xchg    cl, [edi + WDATA.fl_wstate]
1370
 
1371
        or      cl, ch
1372
        test    cl, WSTATE_MAXIMIZED
1373
        jnz     .exit
1374
 
1375
        mov     eax, edi
1376
        sub     eax, window_data
1377
        shl     eax, 3
1378
        add     eax, SLOT_BASE
1379
 
1380
        lea     ebx, [edi + WDATA.box]
1381
        xchg    esp, ebx
1382
 
1383
        pop     [eax + APPDATA.saved_box.left] \
1384
                [eax + APPDATA.saved_box.top] \
1385
                [eax + APPDATA.saved_box.width] \
1386
                edx
1387
 
1388
        xchg    esp, ebx
1389
 
1390
        test    ch, WSTATE_ROLLEDUP
1391
        jnz     .exit
1392
 
1393
        mov     [eax + APPDATA.saved_box.height], edx
1394
 
1395
  .exit:
1396
        pop     esi ebx eax
1397
        ret
1398
 
1399
align 4
1400
;------------------------------------------------------------------------------
1401
window._.set_window_clientbox: ;///////////////////////////////////////////////
1402
;------------------------------------------------------------------------------
1403
;? 
1404
;------------------------------------------------------------------------------
1405
;> edi = pointer to WDATA struct
1406
;------------------------------------------------------------------------------
1407
        push    eax ecx edi
1408
 
1409
        mov     eax, [_skinh]
1410
        mov     [window_topleft + 8 * 3 + 4], eax
1411
        mov     [window_topleft + 8 * 4 + 4], eax
1412
 
1413
        mov     ecx, edi
1414
        sub     edi, window_data
1415
        shl     edi, 3
1416
        test    [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
1417
        jz      .whole_window
1418
 
1419
        movzx   eax, [ecx + WDATA.fl_wstyle]
1420
        and     eax, 0x0F
1421
        mov     eax, [eax * 8 + window_topleft + 0]
1422
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1423
        shl     eax, 1
1424
        neg     eax
1425
        add     eax, [ecx + WDATA.box.width]
1426
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1427
 
1428
        movzx   eax, [ecx + WDATA.fl_wstyle]
1429
        and     eax, 0x0F
1430
        push    [eax * 8 + window_topleft + 0]
1431
        mov     eax, [eax * 8 + window_topleft + 4]
1432
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1433
        neg     eax
1434
        sub     eax, [esp]
1435
        add     eax, [ecx + WDATA.box.height]
1436
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1437
        add     esp, 4
1438
        jmp     .exit
1439
 
1440
  .whole_window:
1441
        xor     eax, eax
1442
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1443
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1444
        mov     eax, [ecx + WDATA.box.width]
1445
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1446
        mov     eax, [ecx + WDATA.box.height]
1447
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1448
 
1449
  .exit:
1450
        pop     edi ecx eax
1451
        ret
1452
 
1453
align 4
1454
;------------------------------------------------------------------------------
1455
window._.sys_set_window: ;/////////////////////////////////////////////////////
1456
;------------------------------------------------------------------------------
1457
;? 
1458
;------------------------------------------------------------------------------
1459
;< edx = pointer to WDATA struct
1460
;------------------------------------------------------------------------------
1461
        mov     eax, [CURRENT_TASK]
1462
        shl     eax, 5
1463
        add     eax, window_data
1464
 
1465
        ; save window colors
1466
        mov     [eax + WDATA.cl_workarea], edx
1467
        mov     [eax + WDATA.cl_titlebar], esi
1468
        mov     [eax + WDATA.cl_frames], edi
1469
 
1470
        mov     edi, eax
1471
 
1472
        ; was it already defined before?
1473
        test    [edi + WDATA.fl_wdrawn], 1
1474
        jnz     .set_client_box
1475
        or      [edi + WDATA.fl_wdrawn], 1
1476
 
1477
        ; NOTE: commented out since doesn't provide necessary functionality
1478
        ;       anyway, to be reworked
1479
;       mov     eax, [timer_ticks] ; [0xfdf0]
1480
;       add     eax, 100
1481
;       mov     [new_window_starting], eax
1482
 
1483
        ; no it wasn't, performing initial window definition
1484
        movzx   eax, bx
1485
        mov     [edi + WDATA.box.width], eax
1486
        movzx   eax, cx
1487
        mov     [edi + WDATA.box.height], eax
1488
        sar     ebx, 16
1489
        sar     ecx, 16
1490
        mov     [edi + WDATA.box.left], ebx
1491
        mov     [edi + WDATA.box.top], ecx
1492
 
1493
        call    window._.check_window_position
1494
 
1495
        push    ecx edi
1496
 
1497
        mov     cl, [edi + WDATA.fl_wstyle]
1498
        mov     eax, [edi + WDATA.cl_frames]
1499
 
1500
        sub     edi, window_data
1501
        shl     edi, 3
1502
        add     edi, SLOT_BASE
1503
 
1504
        and     cl, 0x0F
1505
        cmp     cl, 3
1506
        je      @f
1507
        cmp     cl, 4
1508
        je      @f
1509
 
1510
        xor     eax, eax
1511
 
1512
    @@:
1513
        mov     [edi + APPDATA.wnd_caption], eax
1514
 
1515
        mov     esi, [esp]
1516
        add     edi, APPDATA.saved_box
1517
        movsd
1518
        movsd
1519
        movsd
1520
        movsd
1521
 
1522
        pop     edi ecx
1523
 
1524
        mov     esi, [CURRENT_TASK]
1525
        movzx   esi, word[WIN_STACK + esi * 2]
1526
        lea     esi, [WIN_POS + esi * 2]
1527
        call    waredraw
1528
 
1529
        mov     eax, [edi + WDATA.box.left]
1530
        mov     ebx, [edi + WDATA.box.top]
1531
        mov     ecx, [edi + WDATA.box.width]
1532
        mov     edx, [edi + WDATA.box.height]
1533
        add     ecx, eax
1534
        add     edx, ebx
1535
        call    calculatescreen
1536
 
1537
        mov     byte[KEY_COUNT], 0           ; empty keyboard buffer
1538
        mov     byte[BTN_COUNT], 0           ; empty button buffer
1539
 
1540
  .set_client_box:
1541
        ; update window client box coordinates
1542
        call    window._.set_window_clientbox
1543
 
1544
        ; reset window redraw flag and exit
1545
        mov     [edi + WDATA.fl_redraw], 0
1546
        mov     edx, edi
1547
        ret
1548
 
1549
align 4
1550
;------------------------------------------------------------------------------
1551
window._.check_window_position: ;//////////////////////////////////////////////
1552
;------------------------------------------------------------------------------
1553
;? Check if window is inside screen area
1554
;------------------------------------------------------------------------------
1555
;> edi = pointer to WDATA
1556
;------------------------------------------------------------------------------
1557
        push    eax ebx ecx edx esi
1558
 
1559
        mov     eax, [edi + WDATA.box.left]
1560
        mov     ebx, [edi + WDATA.box.top]
1561
        mov     ecx, [edi + WDATA.box.width]
1562
        mov     edx, [edi + WDATA.box.height]
1563
 
1564
        mov     esi, [Screen_Max_X]
1565
        cmp     ecx, esi
1566
        ja      .fix_width_high
1567
 
1568
  .check_left:
1569
        or      eax, eax
1570
        jl      .fix_left_low
1571
        add     eax, ecx
1572
        cmp     eax, esi
1573
        jg      .fix_left_high
1574
 
1575
  .check_height:
1576
        mov     esi, [Screen_Max_Y]
1577
        cmp     edx, esi
1578
        ja      .fix_height_high
1579
 
1580
  .check_top:
1581
        or      ebx, ebx
1582
        jl      .fix_top_low
1583
        add     ebx, edx
1584
        cmp     ebx, esi
1585
        jg      .fix_top_high
1586
 
1587
  .exit:
1588
        pop     esi edx ecx ebx eax
1589
        ret
1590
 
1591
  .fix_width_high:
1592
        mov     ecx, esi
1593
        mov     [edi + WDATA.box.width], esi
1594
        jmp     .check_left
1595
 
1596
  .fix_left_low:
1597
        xor     eax, eax
1598
        mov     [edi + WDATA.box.left], eax
1599
        jmp     .check_height
1600
 
1601
  .fix_left_high:
1602
        mov     eax, esi
1603
        sub     eax, ecx
1604
        mov     [edi + WDATA.box.left], eax
1605
        jmp     .check_height
1606
 
1607
  .fix_height_high:
1608
        mov     edx, esi
1609
        mov     [edi + WDATA.box.height], esi
1610
        jmp     .check_top
1611
 
1612
  .fix_top_low:
1613
        xor     ebx, ebx
1614
        mov     [edi + WDATA.box.top], ebx
1615
        jmp     .exit
1616
 
1617
  .fix_top_high:
1618
        mov     ebx, esi
1619
        sub     ebx, edx
1620
        mov     [edi + WDATA.box.top], ebx
1621
        jmp     .exit
1622
 
1623
align 4
1624
;------------------------------------------------------------------------------
1625
window._.get_titlebar_height: ;////////////////////////////////////////////////
1626
;------------------------------------------------------------------------------
1627
;? 
1628
;------------------------------------------------------------------------------
1629
;> edi = pointer to WDATA
1630
;------------------------------------------------------------------------------
1631
        mov     al, [edi + WDATA.fl_wstyle]
1632
        and     al, 0x0f
1633
        cmp     al, 0x03
1634
        jne     @f
1635
        mov     eax, [_skinh]
1636
        ret
1637
    @@:
1638
        mov     eax, 21
1639
        ret
1640
 
1641
align 4
1642
;------------------------------------------------------------------------------
1643
window._.get_rolledup_height: ;////////////////////////////////////////////////
1644
;------------------------------------------------------------------------------
1645
;? 
1646
;------------------------------------------------------------------------------
1647
;> edi = pointer to WDATA
1648
;------------------------------------------------------------------------------
1649
        mov     al, [edi + WDATA.fl_wstyle]
1650
        and     al, 0x0f
1651
        cmp     al, 0x03
1652
        jb      @f
1653
        mov     eax, [_skinh]
1654
        add     eax, 3
1655
        ret
1656
    @@:
1657
        or      al, al
1658
        jnz     @f
1659
        mov     eax, 21
1660
        ret
1661
    @@:
1662
        mov     eax, 21 + 2
1663
        ret
1664
 
1665
align 4
1666
;------------------------------------------------------------------------------
1667
window._.set_screen: ;/////////////////////////////////////////////////////////
1668
;------------------------------------------------------------------------------
1669
;? Reserve window area in screen buffer
1670
;------------------------------------------------------------------------------
1671
;> eax = left
1672
;> ebx = top
1673
;> ecx = right
1674
;> edx = bottom
1675
;> esi = process number
1676
;------------------------------------------------------------------------------
1677
virtual at esp
1678
  ff_x     dd ?
1679
  ff_y     dd ?
1680
  ff_width dd ?
1681
  ff_xsz   dd ?
1682
  ff_ysz   dd ?
1683
  ff_scale dd ?
1684
end virtual
1685
 
1686
        pushad
1687
 
1688
        cmp     esi, 1
1689
        jz      .check_for_shaped_window
1690
        mov     edi, esi
1691
        shl     edi, 5
1692
        cmp     [window_data + edi + WDATA.box.width], 0
1693
        jnz     .check_for_shaped_window
1694
        cmp     [window_data + edi + WDATA.box.height], 0
1695
        jz      .exit
1696
 
1697
  .check_for_shaped_window:
1698
        mov     edi, esi
1699
        shl     edi, 8
1700
        add     edi, SLOT_BASE
1701
        cmp     [edi + APPDATA.wnd_shape], 0
1702
        jne     .shaped_window
1703
 
1704
        ; get x&y size
1705
        sub     ecx, eax
1706
        sub     edx, ebx
1707
        inc     ecx
1708
        inc     edx
1709
 
1710
        ; get WinMap start
1711
        push    esi
1712
        mov     edi, [Screen_Max_X]
1713
        inc     edi
1714
        mov     esi, edi
1715
        imul    edi, ebx
1716
        add     edi, eax
1717
        add     edi, [_WinMapAddress]
1718
        pop     eax
1719
        mov     ah, al
1720
        push    ax
1721
        shl     eax, 16
1722
        pop     ax
1723
 
1724
  .next_line:
1725
        push    ecx
1726
        shr     ecx, 2
1727
        rep stosd
1728
        mov     ecx, [esp]
1729
        and     ecx, 3
1730
        rep stosb
1731
        pop     ecx
1732
        add     edi, esi
1733
        sub     edi, ecx
1734
        dec     edx
1735
        jnz     .next_line
1736
 
1737
        jmp     .exit
1738
 
1739
  .shaped_window:
1740
        ;  for (y=0; y <= x_size; y++)
1741
        ;      for (x=0; x <= x_size; x++)
1742
        ;          if (shape[coord(x,y,scale)]==1)
1743
        ;             set_pixel(x, y, process_number);
1744
 
1745
        sub     ecx, eax
1746
        sub     edx, ebx
1747
        inc     ecx
1748
        inc     edx
1749
 
1750
        push    [edi + APPDATA.wnd_shape_scale]  ; push scale first -> for loop
1751
 
1752
        ; get WinMap start  -> ebp
1753
        push    eax
1754
        mov     eax, [Screen_Max_X] ; screen_sx
1755
        inc     eax
1756
        imul    eax, ebx
1757
        add     eax, [esp]
1758
        add     eax, [_WinMapAddress]
1759
        mov     ebp, eax
1760
 
1761
        mov     edi, [edi + APPDATA.wnd_shape]
1762
        pop     eax
1763
 
1764
        ; eax = x_start
1765
        ; ebx = y_start
1766
        ; ecx = x_size
1767
        ; edx = y_size
1768
        ; esi = process_number
1769
        ; edi = &shape
1770
        ;       [scale]
1771
        push    edx ecx ; for loop - x,y size
1772
 
1773
        mov     ecx, esi
1774
        shl     ecx, 5
1775
        mov     edx, [window_data + ecx + WDATA.box.top]
1776
        push    [window_data + ecx + WDATA.box.width]           ; for loop - width
1777
        mov     ecx, [window_data + ecx + WDATA.box.left]
1778
        sub     ebx, edx
1779
        sub     eax, ecx
1780
        push    ebx eax ; for loop - x,y
1781
 
1782
        add     [ff_xsz], eax
1783
        add     [ff_ysz], ebx
1784
 
1785
        mov     ebx, [ff_y]
1786
 
1787
  .ff_new_y:
1788
        mov     edx, [ff_x]
1789
 
1790
  .ff_new_x:
1791
        ; -- body --
1792
        mov     ecx, [ff_scale]
1793
        mov     eax, [ff_width]
1794
        inc     eax
1795
        shr     eax, cl
1796
        push    ebx edx
1797
        shr     ebx, cl
1798
        shr     edx, cl
1799
        imul    eax, ebx
1800
        add     eax, edx
1801
        pop     edx ebx
1802
        add     eax, edi
1803
        call    .read_byte
1804
        test    al, al
1805
        jz      @f
1806
        mov     eax, esi
1807
        mov     [ebp], al
1808
        ; -- end body --
1809
    @@:
1810
        inc     ebp
1811
        inc     edx
1812
        cmp     edx, [ff_xsz]
1813
        jb      .ff_new_x
1814
 
1815
        sub     ebp, [ff_xsz]
1816
        add     ebp, [ff_x]
1817
        add     ebp, [Screen_Max_X]  ; screen.x
1818
        inc     ebp
1819
        inc     ebx
1820
        cmp     ebx, [ff_ysz]
1821
        jb      .ff_new_y
1822
 
1823
        add     esp, 24
1824
 
1825
  .exit:
1826
        popad
1827
        ret
1828
 
1829
  .read_byte:
1830
        ; eax - address
1831
        ; esi - slot
1832
        push    eax ecx edx esi
1833
        xchg    eax, esi
1834
        lea     ecx, [esp + 12]
1835
        mov     edx, 1
1836
        call    read_process_memory
1837
        pop     esi edx ecx eax
1838
        ret
1839
 
1840
align 4
1841
;------------------------------------------------------------------------------
1842
window._.window_activate: ;////////////////////////////////////////////////////
1843
;------------------------------------------------------------------------------
1844
;? Activate window
1845
;------------------------------------------------------------------------------
1846
;> esi = pointer to WIN_POS+ window data
1847
;------------------------------------------------------------------------------
1848
        push    eax ebx
1849
 
1850
        ; if type of current active window is 3 or 4, it must be redrawn
1851
        mov     ebx, [TASK_COUNT]
1852
 
1853
;       DEBUGF  1, "K : TASK_COUNT (0x%x)\n", ebx
1854
 
1855
        movzx   ebx, word[WIN_POS + ebx * 2]
1856
        shl     ebx, 5
1857
        add     eax, window_data
1858
        mov     al, [window_data + ebx + WDATA.fl_wstyle]
1859
        and     al, 0x0f
1860
        cmp     al, 0x03
1861
        je      .set_window_redraw_flag
1862
        cmp     al, 0x04
1863
        jne     .move_others_down
1864
 
1865
  .set_window_redraw_flag:
1866
        mov     [window_data + ebx + WDATA.fl_redraw], 1
1867
 
1868
  .move_others_down:
1869
        ; ax <- process no
1870
        movzx   ebx, word[esi]
1871
        ; ax <- position in window stack
1872
        movzx   ebx, word[WIN_STACK + ebx * 2]
1873
 
1874
        ; drop others
1875
        xor     eax, eax
1876
 
1877
  .next_stack_window:
1878
        cmp     eax, [TASK_COUNT]
1879
        jae     .move_self_up
1880
        inc     eax
1881
 
1882
;       push    ebx
1883
;       xor     ebx,ebx
1884
;       mov     bx,[WIN_STACK + eax * 2]
1885
;       DEBUGF  1, "K : DEC WIN_STACK (0x%x)\n",ebx
1886
;       pop     ebx
1887
 
1888
        cmp     [WIN_STACK + eax * 2], bx
1889
        jbe     .next_stack_window
1890
        dec     word[WIN_STACK + eax * 2]
1891
        jmp     .next_stack_window
1892
 
1893
  .move_self_up:
1894
        movzx   ebx, word[esi]
1895
        ; number of processes
1896
        mov     ax, [TASK_COUNT]
1897
        ; this is the last (and the upper)
1898
        mov     [WIN_STACK + ebx * 2], ax
1899
 
1900
        ; update on screen - window stack
1901
        xor     eax, eax
1902
 
1903
  .next_window_pos:
1904
        cmp     eax, [TASK_COUNT]
1905
        jae     .reset_vars
1906
        inc     eax
1907
        movzx   ebx, word[WIN_STACK + eax * 2]
1908
        mov     [WIN_POS + ebx * 2], ax
1909
        jmp     .next_window_pos
1910
 
1911
  .reset_vars:
1912
        mov     byte[KEY_COUNT], 0
1913
        mov     byte[BTN_COUNT], 0
1914
        mov     word[MOUSE_SCROLL_H], 0
1915
        mov     word[MOUSE_SCROLL_V], 0
1916
 
1917
        pop     ebx eax
1918
        ret
1919
 
1920
;------------------------------------------------------------------------------
1921
window._.window_deactivate: ;////////////////////////////////////////////////////
1922
;------------------------------------------------------------------------------
1923
;? Deactivate window
1924
;------------------------------------------------------------------------------
1925
;> esi = pointer to WIN_POS+ window data
1926
;------------------------------------------------------------------------------
1927
        push    eax ebx
1928
;------------------------------------------------------------------------------
1929
.move_others_up:
1930
        ; ax <- process no
1931
        movzx   ebx, word[esi]
1932
        ; ax <- position in window stack
1933
        movzx   ebx, word[WIN_STACK + ebx * 2]
1934
        ; up others
1935
        xor     eax, eax
1936
.next_stack_window:
1937
        cmp     eax, [TASK_COUNT]
1938
        jae     .move_self_down
1939
        inc     eax
1940
        cmp     [WIN_STACK + eax * 2], bx
1941
        jae     .next_stack_window
1942
        inc     word[WIN_STACK + eax * 2]
1943
        jmp     .next_stack_window
1944
;----------------------------------------------
1945
.move_self_down:
1946
        movzx   ebx, word[esi]
1947
        ; this is the last (and the low)
1948
        mov     [WIN_STACK + ebx * 2], word 1
1949
        ; update on screen - window stack
1950
        xor     eax, eax
1951
.next_window_pos:
1952
        cmp     eax, [TASK_COUNT]
1953
        jae     .reset_vars
1954
        inc     eax
1955
        movzx   ebx, word[WIN_STACK + eax * 2]
1956
        mov     [WIN_POS + ebx * 2], ax
1957
        jmp     .next_window_pos
1958
;-----------------------------------------------
1959
.reset_vars:
1960
        mov     byte[KEY_COUNT], 0
1961
        mov     byte[BTN_COUNT], 0
1962
        mov     word[MOUSE_SCROLL_H], 0
1963
        mov     word[MOUSE_SCROLL_V], 0
1964
        pop     ebx eax
1965
        ret
1966
;------------------------------------------------------------------------------
1967
align 4
1968
;------------------------------------------------------------------------------
1969
window._.check_window_draw: ;//////////////////////////////////////////////////
1970
;------------------------------------------------------------------------------
1971
;? Check if window is necessary to draw
1972
;------------------------------------------------------------------------------
1973
;> edi = pointer to WDATA
1974
;------------------------------------------------------------------------------
1975
        mov     cl, [edi + WDATA.fl_wstyle]
1976
        and     cl, 0x0f
1977
        cmp     cl, 3
1978
        je      .exit.redraw      ; window type 3
1979
        cmp     cl, 4
1980
        je      .exit.redraw      ; window type 4
1981
 
1982
        push    eax ebx edx esi
1983
 
1984
        mov     eax, edi
1985
        sub     eax, window_data
1986
        shr     eax, 5
1987
 
1988
        movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
1989
        lea     esi, [WIN_POS + eax * 2]        ; get address of this process at 0xC400
1990
 
1991
  .next_window:
1992
        add     esi, 2
1993
 
1994
        mov     eax, [TASK_COUNT]
1995
        lea     eax, word[WIN_POS + eax * 2] ; number of the upper window
1996
 
1997
        cmp     esi, eax
1998
        ja      .exit.no_redraw
1999
 
2000
        movzx   edx, word[esi]
2001
        shl     edx, 5
2002
        cmp     [CURRENT_TASK + edx + TASKDATA.state], TSTATE_FREE
2003
        je      .next_window
2004
 
2005
        mov     eax, [edi + WDATA.box.top]
2006
        mov     ebx, [edi + WDATA.box.height]
2007
        add     ebx, eax
2008
 
2009
        mov     ecx, [window_data + edx + WDATA.box.top]
2010
        cmp     ecx, ebx
2011
        jge     .next_window
2012
        add     ecx, [window_data + edx + WDATA.box.height]
2013
        cmp     eax, ecx
2014
        jge     .next_window
2015
 
2016
        mov     eax, [edi + WDATA.box.left]
2017
        mov     ebx, [edi + WDATA.box.width]
2018
        add     ebx, eax
2019
 
2020
        mov     ecx, [window_data + edx + WDATA.box.left]
2021
        cmp     ecx, ebx
2022
        jge     .next_window
2023
        add     ecx, [window_data + edx + WDATA.box.width]
2024
        cmp     eax, ecx
2025
        jge     .next_window
2026
 
2027
        pop     esi edx ebx eax
2028
 
2029
  .exit.redraw:
2030
        xor     ecx, ecx
2031
        inc     ecx
2032
        ret
2033
 
2034
  .exit.no_redraw:
2035
        pop     esi edx ebx eax
2036
        xor     ecx, ecx
2037
        ret
2038
 
2039
align 4
2040
;------------------------------------------------------------------------------
2041
window._.draw_window_caption: ;////////////////////////////////////////////////
2042
;------------------------------------------------------------------------------
2043
;? 
2044
;------------------------------------------------------------------------------
2045
        inc     [mouse_pause]
2046
        call    [_display.disable_mouse]
2047
 
2048
        xor     eax, eax
2049
        mov     edx, [TASK_COUNT]
2050
        movzx   edx, word[WIN_POS + edx * 2]
2051
        cmp     edx, [CURRENT_TASK]
2052
        jne     @f
2053
        inc     eax
2054
    @@:
2055
        mov     edx, [CURRENT_TASK]
2056
        shl     edx, 5
2057
        add     edx, window_data
2058
        movzx   ebx, [edx + WDATA.fl_wstyle]
2059
        and     bl, 0x0F
2060
        cmp     bl, 3
2061
        je      .draw_caption_style_3
2062
        cmp     bl, 4
2063
        je      .draw_caption_style_3
2064
 
2065
        jmp     .not_style_3
2066
 
2067
  .draw_caption_style_3:
2068
        push    edx
2069
        call    drawwindow_IV_caption
2070
        add     esp, 4
2071
        jmp     .2
2072
 
2073
  .not_style_3:
2074
        cmp     bl, 2
2075
        jne     .not_style_2
2076
 
2077
        call    drawwindow_III_caption
2078
        jmp     .2
2079
 
2080
  .not_style_2:
2081
        cmp     bl, 0
2082
        jne     .2
2083
 
2084
        call    drawwindow_I_caption
2085
 
2086
  .2:
2087
        mov     edi, [CURRENT_TASK]
2088
        shl     edi, 5
2089
        test    [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
2090
        jz      .exit
2091
        mov     edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
2092
        or      edx, edx
2093
        jz      .exit
2094
 
2095
        movzx   eax, [edi + window_data + WDATA.fl_wstyle]
2096
        and     al, 0x0F
2097
        cmp     al, 3
2098
        je      .skinned
2099
        cmp     al, 4
2100
        je      .skinned
2101
 
2102
        jmp     .not_skinned
2103
 
2104
  .skinned:
2105
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
2106
        mov     bp, word[edi + window_data + WDATA.box.top]
2107
        movzx   eax, word[edi + window_data + WDATA.box.width]
2108
        sub     ax, [_skinmargins.left]
2109
        sub     ax, [_skinmargins.right]
2110
        push    edx
2111
        cwde
2112
        cdq
2113
        mov     ebx, 6
2114
        idiv    ebx
2115
        pop     edx
2116
        or      eax, eax
2117
        js      .exit
2118
 
2119
        mov     esi, eax
2120
        mov     ebx, dword[_skinmargins.left - 2]
2121
        mov     bx, word[_skinh]
2122
        sub     bx, [_skinmargins.bottom]
2123
        sub     bx, [_skinmargins.top]
2124
        sar     bx, 1
2125
        adc     bx, 0
2126
        add     bx, [_skinmargins.top]
2127
        add     bx, -3
2128
        add     ebx, ebp
2129
        jmp     .dodraw
2130
 
2131
  .not_skinned:
2132
        cmp     al, 1
2133
        je      .exit
2134
 
2135
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
2136
        mov     bp, word[edi + window_data + WDATA.box.top]
2137
        movzx   eax, word[edi + window_data + WDATA.box.width]
2138
        sub     eax, 16
2139
        push    edx
2140
        cwde
2141
        cdq
2142
        mov     ebx, 6
2143
        idiv    ebx
2144
        pop     edx
2145
        or      eax, eax
2146
        js      .exit
2147
 
2148
        mov     esi, eax
2149
        mov     ebx, 0x00080007
2150
        add     ebx, ebp
2151
 
2152
  .dodraw:
2153
        mov     ecx, [common_colours + 16]
2154
        or      ecx, 0x80000000
2155
        xor     edi, edi
2156
        call    dtext_asciiz_esi
2157
 
2158
  .exit:
2159
        dec     [mouse_pause]
2160
        call    [draw_pointer]
2161
        ret
2162
 
2163
align 4
2164
;------------------------------------------------------------------------------
2165
window._.draw_negative_box: ;//////////////////////////////////////////////////
2166
;------------------------------------------------------------------------------
2167
;? Draw negative box
2168
;------------------------------------------------------------------------------
2169
;> edi = pointer to BOX struct
2170
;------------------------------------------------------------------------------
2171
        push    eax ebx esi
2172
        mov     esi, 0x01000000
2173
.1:
2174
        mov     eax, [edi + BOX.left - 2]
2175
        mov     ax, word[edi + BOX.left]
2176
        add     ax, word[edi + BOX.width]
2177
        mov     ebx, [edi + BOX.top - 2]
2178
        mov     bx, word[edi + BOX.top]
2179
        add     bx, word[edi + BOX.height]
2180
        call    draw_rectangle.forced
2181
        pop     esi ebx eax
2182
        ret
2183
;------------------------------------------------------------------------------
2184
window._.end_moving__box: ;//////////////////////////////////////////////////
2185
;------------------------------------------------------------------------------
2186
;? Draw positive box
2187
;------------------------------------------------------------------------------
2188
;> edi = pointer to BOX struct
2189
;------------------------------------------------------------------------------
2190
        push    eax ebx esi
2191
        xor     esi, esi
2192
        jmp     window._.draw_negative_box.1
2193
 
2194
 
2195
;------------------------------------------------------------------------------
2196
window._.get_rect: ;/////////////////////////////////////////////////////
2197
;------------------------------------------------------------------------------
2198
;?   void __fastcall get_window_rect(struct RECT* rc);
2199
;------------------------------------------------------------------------------
2200
;> ecx = pointer to RECT
2201
;------------------------------------------------------------------------------
2202
        mov     eax, [TASK_BASE]
2203
 
2204
        mov     edx, [eax-twdw + WDATA.box.left]
2205
        mov     [ecx+RECT.left], edx
2206
 
2207
        add     edx, [eax-twdw + WDATA.box.width]
2208
        mov     [ecx+RECT.right], edx
2209
 
2210
        mov     edx, [eax-twdw + WDATA.box.top]
2211
        mov     [ecx+RECT.top], edx
2212
 
2213
        add     edx, [eax-twdw + WDATA.box.height]
2214
        mov     [ecx+RECT.bottom], edx
2215
 
2216
        ret
2217