Subversion Repositories Kolibri OS

Rev

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

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