Subversion Repositories Kolibri OS

Rev

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

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