Subversion Repositories Kolibri OS

Rev

Rev 1424 | Rev 1465 | 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: 1460 $
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
;------------------------------------------------------------------------------
1460 Lrz 859
;        push    -1
1391 mikedld 860
        mov     eax, [TASK_COUNT]
861
        lea     eax, [WIN_POS + eax * 2]
862
        cmp     eax, esi
1460 Lrz 863
;        pop     eax
864
	or	eax,-1
1391 mikedld 865
        je      .exit
866
 
1362 mikedld 867
        ; is it overlapped by another window now?
868
        push    ecx
869
        call    window._.check_window_draw
870
        test    ecx, ecx
871
        pop     ecx
872
        jz      .do_not_draw
873
 
874
        ; yes it is, activate and update screen buffer
875
        mov     byte[MOUSE_DOWN], 1
876
        call    window._.window_activate
877
 
878
        pushad
879
        mov     edi, [TASK_COUNT]
880
        movzx   esi, word[WIN_POS + edi * 2]
881
        shl     esi, 5
882
        add     esi, window_data
883
 
884
        mov     eax, [esi + WDATA.box.left]
885
        mov     ebx, [esi + WDATA.box.top]
886
        mov     ecx, [esi + WDATA.box.width]
887
        mov     edx, [esi + WDATA.box.height]
888
 
889
        add     ecx, eax
890
        add     edx, ebx
891
 
892
        mov     edi, [TASK_COUNT]
893
        movzx   esi, word[WIN_POS + edi * 2]
894
        call    window._.set_screen
895
        popad
896
 
897
        ; tell application to redraw itself
898
        mov     [edi + WDATA.fl_redraw], 1
1391 mikedld 899
        xor     eax, eax
900
        jmp     .exit
1362 mikedld 901
 
902
  .do_not_draw:
903
        ; no it's not, just activate the window
904
        call    window._.window_activate
1391 mikedld 905
        xor     eax, eax
1460 Lrz 906
        mov     byte[MOUSE_BACKGROUND], al
907
        mov     byte[DONT_DRAW_MOUSE], al
1391 mikedld 908
 
1460 Lrz 909
 
1391 mikedld 910
  .exit:
911
        mov     byte[MOUSE_DOWN], 0
912
        inc     eax
1362 mikedld 913
        ret
914
 
915
align 4
916
;------------------------------------------------------------------------------
917
minimize_window: ;/////////////////////////////////////////////////////////////
918
;------------------------------------------------------------------------------
919
;> eax = window number on screen
920
;------------------------------------------------------------------------------
921
;# corrupts [dl*]
922
;------------------------------------------------------------------------------
923
        push    edi
924
        pushfd
925
        cli
926
 
927
        ; is it already minimized?
928
        movzx   edi, word[WIN_POS + eax * 2]
929
        shl     edi, 5
930
        add     edi, window_data
931
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
932
        jnz     .exit
933
 
934
        push    eax ebx ecx edx esi
935
 
936
        ; no it's not, let's do that
937
        or      [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
938
        mov     eax, [edi + WDATA.box.left]
939
        mov     [draw_limits.left], eax
940
        mov     ecx, eax
941
        add     ecx, [edi + WDATA.box.width]
942
        mov     [draw_limits.right], ecx
943
        mov     ebx, [edi + WDATA.box.top]
944
        mov     [draw_limits.top], ebx
945
        mov     edx, ebx
946
        add     edx, [edi + WDATA.box.height]
947
        mov     [draw_limits.bottom], edx
948
        call    calculatescreen
949
        xor     esi, esi
950
        xor     eax, eax
951
        call    redrawscreen
952
 
953
        pop     esi edx ecx ebx eax
954
 
955
  .exit:
956
        popfd
957
        pop     edi
958
        ret
959
 
960
align 4
961
;------------------------------------------------------------------------------
962
restore_minimized_window: ;////////////////////////////////////////////////////
963
;------------------------------------------------------------------------------
964
;> eax = window number on screen
965
;------------------------------------------------------------------------------
966
;# corrupts [dl*]
967
;------------------------------------------------------------------------------
968
        pushad
969
        pushfd
970
        cli
971
 
972
        ; is it already restored?
973
        movzx   esi, word[WIN_POS + eax * 2]
974
        mov     edi, esi
975
        shl     edi, 5
976
        add     edi, window_data
977
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
978
        jz      .exit
979
 
980
        ; no it's not, let's do that
981
        mov     [edi + WDATA.fl_redraw], 1
982
        and     [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED
983
        mov     ebp, window._.set_screen
984
        cmp     eax, [TASK_COUNT]
985
        jz      @f
986
        mov     ebp, calculatescreen
987
    @@: mov     eax, [edi + WDATA.box.left]
988
        mov     ebx, [edi + WDATA.box.top]
989
        mov     ecx, [edi + WDATA.box.width]
990
        mov     edx, [edi + WDATA.box.height]
991
        add     ecx, eax
992
        add     edx, ebx
993
        call    ebp
994
 
995
        mov     byte[MOUSE_BACKGROUND], 0
996
 
997
  .exit:
998
        popfd
999
        popad
1000
        ret
1001
 
1002
align 4
1391 mikedld 1003
; TODO: remove this proc
1362 mikedld 1004
;------------------------------------------------------------------------------
1391 mikedld 1005
window_check_events: ;/////////////////////////////////////////////////////////
1362 mikedld 1006
;------------------------------------------------------------------------------
1391 mikedld 1007
;? 
1362 mikedld 1008
;------------------------------------------------------------------------------
1009
        ; do we have window minimize/restore request?
1010
        cmp     [window_minimize], 0
1391 mikedld 1011
        je      .exit
1362 mikedld 1012
 
1013
        ; okay, minimize or restore top-most window and exit
1014
        mov     eax, [TASK_COUNT]
1015
        mov     bl, 0
1016
        xchg    [window_minimize], bl
1017
        dec     bl
1018
        jnz     @f
1019
        call    minimize_window
1391 mikedld 1020
        jmp     .exit
1021
 
1362 mikedld 1022
    @@: call    restore_minimized_window
1023
 
1391 mikedld 1024
  .exit:
1025
        ret
1362 mikedld 1026
 
1391 mikedld 1027
align 4
1028
;------------------------------------------------------------------------------
1029
sys_window_maximize_handler: ;/////////////////////////////////////////////////
1030
;------------------------------------------------------------------------------
1031
;? 
1032
;------------------------------------------------------------------------------
1033
;> esi = process slot
1034
;------------------------------------------------------------------------------
1035
        mov     edi, esi
1036
        shl     edi, 5
1037
        add     edi, window_data
1362 mikedld 1038
 
1391 mikedld 1039
        ; can window change its height?
1040
        mov     dl, [edi + WDATA.fl_wstyle]
1041
        and     dl, 0x0f
1042
        cmp     dl, 0x04
1043
        je      .exit
1362 mikedld 1044
 
1391 mikedld 1045
        ; toggle normal/maximized window state
1046
        mov     bl, [edi + WDATA.fl_wstate]
1047
        xor     bl, WSTATE_MAXIMIZED
1362 mikedld 1048
 
1391 mikedld 1049
        ; calculate and set appropriate window bounds
1050
        test    bl, WSTATE_MAXIMIZED
1051
        jz      .restore_size
1362 mikedld 1052
 
1391 mikedld 1053
        mov     eax, [screen_workarea.left]
1054
        mov     ecx, [screen_workarea.top]
1055
        push    [screen_workarea.bottom] \
1056
                [screen_workarea.right] \
1057
                ecx \
1058
                eax
1059
        sub     [esp + BOX.width], eax
1060
        sub     [esp + BOX.height], ecx
1061
        mov     eax, esp
1062
        jmp     .set_box
1362 mikedld 1063
 
1391 mikedld 1064
  .restore_size:
1065
        mov     eax, esi
1066
        shl     eax, 8
1067
        add     eax, SLOT_BASE + APPDATA.saved_box
1068
        push    [eax + BOX.height] \
1069
                [eax + BOX.width] \
1070
                [eax + BOX.top] \
1071
                [eax + BOX.left]
1072
        mov     eax, esp
1362 mikedld 1073
 
1391 mikedld 1074
  .set_box:
1075
        test    bl, WSTATE_ROLLEDUP
1076
        jz      @f
1362 mikedld 1077
 
1391 mikedld 1078
        xchg    eax, ecx
1079
        call    window._.get_rolledup_height
1080
        mov     [ecx + BOX.height], eax
1081
        xchg    eax, ecx
1362 mikedld 1082
 
1391 mikedld 1083
    @@: call    window._.set_window_box
1084
        add     esp, BOX.sizeof
1362 mikedld 1085
 
1391 mikedld 1086
  .exit:
1087
        ret
1362 mikedld 1088
 
1391 mikedld 1089
align 4
1090
;------------------------------------------------------------------------------
1091
sys_window_rollup_handler: ;///////////////////////////////////////////////////
1092
;------------------------------------------------------------------------------
1093
;? 
1094
;------------------------------------------------------------------------------
1095
;> esi = process slot
1096
;------------------------------------------------------------------------------
1097
        mov     edx, esi
1098
        shl     edx, 8
1099
        add     edx, SLOT_BASE
1362 mikedld 1100
 
1391 mikedld 1101
        ; toggle normal/rolled up window state
1102
        mov     bl, [edi + WDATA.fl_wstate]
1103
        xor     bl, WSTATE_ROLLEDUP
1362 mikedld 1104
 
1391 mikedld 1105
        ; calculate and set appropriate window bounds
1106
        test    bl, WSTATE_ROLLEDUP
1107
        jz      .restore_size
1362 mikedld 1108
 
1391 mikedld 1109
        call    window._.get_rolledup_height
1110
        push    eax \
1111
                [edi + WDATA.box.width] \
1112
                [edi + WDATA.box.top] \
1113
                [edi + WDATA.box.left]
1114
        mov     eax, esp
1115
        jmp     .set_box
1362 mikedld 1116
 
1391 mikedld 1117
  .restore_size:
1118
        test    bl, WSTATE_MAXIMIZED
1119
        jnz     @f
1120
        add     esp, -BOX.sizeof
1121
        lea     eax, [edx + APPDATA.saved_box]
1122
        jmp     .set_box
1362 mikedld 1123
 
1391 mikedld 1124
    @@: mov     eax, [screen_workarea.top]
1125
        push    [screen_workarea.bottom] \
1126
                [edi + WDATA.box.width] \
1127
                eax \
1128
                [edi + WDATA.box.left]
1129
        sub     [esp + BOX.height], eax
1130
        mov     eax, esp
1362 mikedld 1131
 
1391 mikedld 1132
  .set_box:
1133
        call    window._.set_window_box
1134
        add     esp, BOX.sizeof
1362 mikedld 1135
 
1391 mikedld 1136
        ret
1362 mikedld 1137
 
1391 mikedld 1138
align 4
1139
;------------------------------------------------------------------------------
1140
sys_window_start_moving_handler: ;/////////////////////////////////////////////
1141
;------------------------------------------------------------------------------
1142
;? 
1143
;------------------------------------------------------------------------------
1144
;> eax = old (original) window box
1145
;> esi = process slot
1146
;------------------------------------------------------------------------------
1147
        mov     edi, eax
1148
        call    window._.draw_negative_box
1362 mikedld 1149
 
1391 mikedld 1150
        ret
1362 mikedld 1151
 
1391 mikedld 1152
align 4
1153
;------------------------------------------------------------------------------
1154
sys_window_end_moving_handler: ;///////////////////////////////////////////////
1155
;------------------------------------------------------------------------------
1156
;? 
1157
;------------------------------------------------------------------------------
1158
;> eax = old (original) window box
1159
;> ebx = new (final) window box
1160
;> esi = process slot
1161
;------------------------------------------------------------------------------
1162
        mov     edi, ebx
1163
        call    window._.draw_negative_box
1362 mikedld 1164
 
1391 mikedld 1165
        mov     edi, esi
1166
        shl     edi, 5
1167
        add     edi, window_data
1362 mikedld 1168
 
1391 mikedld 1169
        mov     eax, ebx
1170
        mov     bl, [edi + WDATA.fl_wstate]
1171
        call    window._.set_window_box
1172
        ret
1362 mikedld 1173
 
1391 mikedld 1174
align 4
1175
;------------------------------------------------------------------------------
1176
sys_window_moving_handler: ;///////////////////////////////////////////////////
1177
;------------------------------------------------------------------------------
1178
;? 
1179
;------------------------------------------------------------------------------
1180
;> eax = old (from previous call) window box
1181
;> ebx = new (current) window box
1182
;> esi = process_slot
1183
;------------------------------------------------------------------------------
1184
        mov     edi, eax
1185
        call    window._.draw_negative_box
1186
        mov     edi, ebx
1187
        call    window._.draw_negative_box
1188
        ret
1362 mikedld 1189
 
1391 mikedld 1190
;==============================================================================
1191
;///// private functions //////////////////////////////////////////////////////
1192
;==============================================================================
1362 mikedld 1193
 
1391 mikedld 1194
iglobal
1195
  FuncTable syscall_display_settings, ftable, \
1196
    00, 01, 02, 03, 04, 05, 06, 07, 08
1362 mikedld 1197
 
1391 mikedld 1198
  align 4
1199
  window_topleft dd \
1200
    1, 21, \ ;type 0
1201
    0,  0, \ ;type 1
1202
    5, 20, \ ;type 2
1203
    5,  ?, \ ;type 3 {set by skin}
1204
    5,  ?    ;type 4 {set by skin}
1205
endg
1362 mikedld 1206
 
1391 mikedld 1207
;uglobal
1208
  ; NOTE: commented out since doesn't provide necessary functionality anyway,
1209
  ;       to be reworked
1210
; new_window_starting       dd ?
1211
;endg
1362 mikedld 1212
 
1391 mikedld 1213
align 4
1214
;------------------------------------------------------------------------------
1215
window._.invalidate_screen: ;//////////////////////////////////////////////////
1216
;------------------------------------------------------------------------------
1217
;? 
1218
;------------------------------------------------------------------------------
1219
;> eax = old (original) window box
1220
;> ebx = new (final) window box
1221
;> edi = pointer to WDATA struct
1222
;------------------------------------------------------------------------------
1362 mikedld 1223
        push    eax ebx
1224
 
1391 mikedld 1225
        ; TODO: do we really need `draw_limits`?
1226
        mov     ecx, [eax + BOX.left]
1227
        mov     edx, [ebx + BOX.left]
1228
        cmp     ecx, edx
1229
        jle     @f
1230
        xchg    ecx, edx
1231
    @@: mov     [draw_limits.left], ecx
1232
        mov     ecx, [eax + BOX.width]
1233
        cmp     ecx, [ebx + BOX.width]
1234
        jae     @f
1235
        mov     ecx, [ebx + BOX.width]
1236
    @@: add     ecx, edx
1237
        mov     [draw_limits.right], ecx
1238
        mov     ecx, [eax + BOX.top]
1239
        mov     edx, [ebx + BOX.top]
1240
        cmp     ecx, edx
1241
        jle     @f
1242
        xchg    ecx, edx
1243
    @@: mov     [draw_limits.top], ecx
1244
        mov     ecx, [eax + BOX.height]
1245
        cmp     ecx, [ebx + BOX.height]
1246
        jae     @f
1247
        mov     ecx, [ebx + BOX.height]
1248
    @@: add     ecx, edx
1249
        mov     [draw_limits.bottom], ecx
1362 mikedld 1250
 
1391 mikedld 1251
        ; recalculate screen buffer at old position
1252
        push    ebx
1253
        mov     edx, [eax + BOX.height]
1254
        mov     ecx, [eax + BOX.width]
1255
        mov     ebx, [eax + BOX.top]
1256
        mov     eax, [eax + BOX.left]
1257
        add     ecx, eax
1258
        add     edx, ebx
1259
        call    calculatescreen
1260
        pop     eax
1362 mikedld 1261
 
1391 mikedld 1262
        ; recalculate screen buffer at new position
1263
        mov     edx, [eax + BOX.height]
1264
        mov     ecx, [eax + BOX.width]
1265
        mov     ebx, [eax + BOX.top]
1266
        mov     eax, [eax + BOX.left]
1267
        add     ecx, eax
1268
        add     edx, ebx
1269
        call    calculatescreen
1362 mikedld 1270
 
1391 mikedld 1271
        mov     eax, edi
1272
        call    redrawscreen
1362 mikedld 1273
 
1391 mikedld 1274
        ; tell window to redraw itself
1275
        mov     [edi + WDATA.fl_redraw], 1
1362 mikedld 1276
 
1391 mikedld 1277
        pop     ebx eax
1278
        ret
1362 mikedld 1279
 
1391 mikedld 1280
align 4
1281
;------------------------------------------------------------------------------
1282
window._.set_window_box: ;/////////////////////////////////////////////////////
1283
;------------------------------------------------------------------------------
1284
;? 
1285
;------------------------------------------------------------------------------
1286
;> eax = pointer to BOX struct
1287
;> bl = new window state flags
1288
;> edi = pointer to WDATA struct
1289
;------------------------------------------------------------------------------
1290
        push    eax ebx esi
1362 mikedld 1291
 
1391 mikedld 1292
        add     esp, -BOX.sizeof
1362 mikedld 1293
 
1391 mikedld 1294
        mov     ebx, esp
1424 diamond 1295
if WDATA.box
1391 mikedld 1296
        lea     esi, [edi + WDATA.box]
1424 diamond 1297
else
1298
	mov	esi, edi ; optimization for WDATA.box = 0
1299
end if
1391 mikedld 1300
        xchg    eax, esi
1301
        mov     ecx, BOX.sizeof
1302
        call    memmove
1303
        xchg    eax, esi
1304
        xchg    ebx, esi
1305
        call    memmove
1424 diamond 1306
        mov     eax, ebx
1307
        mov     ebx, esi
1362 mikedld 1308
 
1391 mikedld 1309
        call    window._.check_window_position
1310
        call    window._.set_window_clientbox
1311
        call    window._.invalidate_screen
1362 mikedld 1312
 
1391 mikedld 1313
        add     esp, BOX.sizeof
1362 mikedld 1314
 
1391 mikedld 1315
        mov     cl, [esp + 4]
1316
        mov     ch, cl
1317
        xchg    cl, [edi + WDATA.fl_wstate]
1362 mikedld 1318
 
1391 mikedld 1319
        or      cl, ch
1320
        test    cl, WSTATE_MAXIMIZED
1321
        jnz     .exit
1362 mikedld 1322
 
1391 mikedld 1323
        mov     eax, edi
1324
        sub     eax, window_data
1325
        shl     eax, 3
1326
        add     eax, SLOT_BASE
1362 mikedld 1327
 
1391 mikedld 1328
        lea     ebx, [edi + WDATA.box]
1329
        xchg    esp, ebx
1362 mikedld 1330
 
1391 mikedld 1331
        pop     [eax + APPDATA.saved_box.left] \
1332
                [eax + APPDATA.saved_box.top] \
1333
                [eax + APPDATA.saved_box.width] \
1334
                edx
1362 mikedld 1335
 
1391 mikedld 1336
        xchg    esp, ebx
1362 mikedld 1337
 
1391 mikedld 1338
        test    ch, WSTATE_ROLLEDUP
1339
        jnz     .exit
1362 mikedld 1340
 
1391 mikedld 1341
        mov     [eax + APPDATA.saved_box.height], edx
1362 mikedld 1342
 
1391 mikedld 1343
  .exit:
1344
        pop     esi ebx eax
1345
        ret
1362 mikedld 1346
 
1391 mikedld 1347
align 4
1348
;------------------------------------------------------------------------------
1349
window._.set_window_clientbox: ;///////////////////////////////////////////////
1350
;------------------------------------------------------------------------------
1351
;? 
1352
;------------------------------------------------------------------------------
1353
;> edi = pointer to WDATA struct
1354
;------------------------------------------------------------------------------
1355
        push    eax ecx edi
1362 mikedld 1356
 
1391 mikedld 1357
        mov     eax, [_skinh]
1358
        mov     [window_topleft + 8 * 3 + 4], eax
1359
        mov     [window_topleft + 8 * 4 + 4], eax
1362 mikedld 1360
 
1391 mikedld 1361
        mov     ecx, edi
1362
        sub     edi, window_data
1363
        shl     edi, 3
1364
        test    [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
1365
        jz      .whole_window
1362 mikedld 1366
 
1391 mikedld 1367
        movzx   eax, [ecx + WDATA.fl_wstyle]
1368
        and     eax, 0x0F
1369
        mov     eax, [eax * 8 + window_topleft + 0]
1370
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1371
        shl     eax, 1
1372
        neg     eax
1373
        add     eax, [ecx + WDATA.box.width]
1374
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1362 mikedld 1375
 
1391 mikedld 1376
        movzx   eax, [ecx + WDATA.fl_wstyle]
1377
        and     eax, 0x0F
1378
        push    [eax * 8 + window_topleft + 0]
1379
        mov     eax, [eax * 8 + window_topleft + 4]
1380
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1381
        neg     eax
1382
        sub     eax, [esp]
1383
        add     eax, [ecx + WDATA.box.height]
1384
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1385
        add     esp, 4
1386
        jmp     .exit
1362 mikedld 1387
 
1391 mikedld 1388
  .whole_window:
1389
        xor     eax, eax
1390
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1391
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1392
        mov     eax, [ecx + WDATA.box.width]
1393
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1394
        mov     eax, [ecx + WDATA.box.height]
1395
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1362 mikedld 1396
 
1391 mikedld 1397
  .exit:
1398
        pop     edi ecx eax
1399
        ret
1362 mikedld 1400
 
1391 mikedld 1401
align 4
1402
;------------------------------------------------------------------------------
1403
window._.sys_set_window: ;/////////////////////////////////////////////////////
1404
;------------------------------------------------------------------------------
1405
;? 
1406
;------------------------------------------------------------------------------
1407
;< edx = pointer to WDATA struct
1408
;------------------------------------------------------------------------------
1409
        mov     eax, [CURRENT_TASK]
1410
        shl     eax, 5
1411
        add     eax, window_data
1362 mikedld 1412
 
1391 mikedld 1413
        ; save window colors
1414
        mov     [eax + WDATA.cl_workarea], edx
1415
        mov     [eax + WDATA.cl_titlebar], esi
1416
        mov     [eax + WDATA.cl_frames], edi
1362 mikedld 1417
 
1391 mikedld 1418
        mov     edi, eax
1362 mikedld 1419
 
1391 mikedld 1420
        ; was it already defined before?
1421
        test    [edi + WDATA.fl_wdrawn], 1
1422
        jnz     .set_client_box
1362 mikedld 1423
 
1391 mikedld 1424
        ; NOTE: commented out since doesn't provide necessary functionality
1425
        ;       anyway, to be reworked
1426
;       mov     eax, [timer_ticks] ; [0xfdf0]
1427
;       add     eax, 100
1428
;       mov     [new_window_starting], eax
1429
 
1430
        ; no it wasn't, performing initial window definition
1431
        movzx   eax, bx
1362 mikedld 1432
        mov     [edi + WDATA.box.width], eax
1391 mikedld 1433
        movzx   eax, cx
1362 mikedld 1434
        mov     [edi + WDATA.box.height], eax
1391 mikedld 1435
        sar     ebx, 16
1436
        sar     ecx, 16
1437
        mov     [edi + WDATA.box.left], ebx
1438
        mov     [edi + WDATA.box.top], ecx
1362 mikedld 1439
 
1391 mikedld 1440
        call    window._.check_window_position
1362 mikedld 1441
 
1391 mikedld 1442
        push    ecx edi
1362 mikedld 1443
 
1391 mikedld 1444
        mov     cl, [edi + WDATA.fl_wstyle]
1445
        mov     eax, [edi + WDATA.cl_frames]
1362 mikedld 1446
 
1391 mikedld 1447
        sub     edi, window_data
1448
        shl     edi, 3
1449
        add     edi, SLOT_BASE
1362 mikedld 1450
 
1391 mikedld 1451
        and     cl, 0x0F
1452
        cmp     cl, 3
1453
        je      @f
1454
        cmp     cl, 4
1455
        je      @f
1362 mikedld 1456
 
1391 mikedld 1457
        xor     eax, eax
1362 mikedld 1458
 
1391 mikedld 1459
    @@: mov     [edi + APPDATA.wnd_caption], eax
1362 mikedld 1460
 
1391 mikedld 1461
        mov     esi, [esp]
1462
        add     edi, APPDATA.saved_box
1463
        movsd
1464
        movsd
1465
        movsd
1466
        movsd
1362 mikedld 1467
 
1391 mikedld 1468
        pop     edi ecx
1469
 
1470
        mov     esi, [CURRENT_TASK]
1471
        movzx   esi, word[WIN_STACK + esi * 2]
1472
        lea     esi, [WIN_POS + esi * 2]
1473
        call    waredraw
1474
 
1362 mikedld 1475
        mov     eax, [edi + WDATA.box.left]
1476
        mov     ebx, [edi + WDATA.box.top]
1477
        mov     ecx, [edi + WDATA.box.width]
1478
        mov     edx, [edi + WDATA.box.height]
1479
        add     ecx, eax
1480
        add     edx, ebx
1481
        call    calculatescreen
1482
 
1391 mikedld 1483
        mov     byte[KEY_COUNT], 0           ; empty keyboard buffer
1484
        mov     byte[BTN_COUNT], 0           ; empty button buffer
1362 mikedld 1485
 
1391 mikedld 1486
  .set_client_box:
1487
        ; update window client box coordinates
1488
        call    window._.set_window_clientbox
1362 mikedld 1489
 
1391 mikedld 1490
        ; reset window redraw flag and exit
1491
        mov     [edi + WDATA.fl_redraw], 0
1492
        mov     edx, edi
1493
        ret
1362 mikedld 1494
 
1391 mikedld 1495
align 4
1496
;------------------------------------------------------------------------------
1497
window._.check_window_position: ;//////////////////////////////////////////////
1498
;------------------------------------------------------------------------------
1499
;? Check if window is inside screen area
1500
;------------------------------------------------------------------------------
1501
;> edi = pointer to WDATA
1502
;------------------------------------------------------------------------------
1503
        push    eax ebx ecx edx esi
1362 mikedld 1504
 
1391 mikedld 1505
        mov     eax, [edi + WDATA.box.left]
1506
        mov     ebx, [edi + WDATA.box.top]
1507
        mov     ecx, [edi + WDATA.box.width]
1508
        mov     edx, [edi + WDATA.box.height]
1362 mikedld 1509
 
1391 mikedld 1510
        mov     esi, [Screen_Max_X]
1511
        cmp     ecx, esi
1512
        ja      .fix_width_high
1362 mikedld 1513
 
1391 mikedld 1514
  .check_left:
1515
        or      eax, eax
1516
        jl      .fix_left_low
1517
        add     eax, ecx
1518
        cmp     eax, esi
1519
        jg      .fix_left_high
1362 mikedld 1520
 
1391 mikedld 1521
  .check_height:
1522
        mov     esi, [Screen_Max_Y]
1523
        cmp     edx, esi
1524
        ja      .fix_height_high
1525
 
1526
  .check_top:
1527
        or      ebx, ebx
1528
        jl      .fix_top_low
1529
        add     ebx, edx
1530
        cmp     ebx, esi
1531
        jg      .fix_top_high
1532
 
1362 mikedld 1533
  .exit:
1391 mikedld 1534
        pop     esi edx ecx ebx eax
1362 mikedld 1535
        ret
1536
 
1391 mikedld 1537
  .fix_width_high:
1538
        mov     ecx, esi
1539
        mov     [edi + WDATA.box.width], esi
1540
        jmp     .check_left
1362 mikedld 1541
 
1391 mikedld 1542
  .fix_left_low:
1543
        xor     eax, eax
1544
        mov     [edi + WDATA.box.left], eax
1545
        jmp     .check_height
1546
 
1547
  .fix_left_high:
1548
        mov     eax, esi
1549
        sub     eax, ecx
1550
        mov     [edi + WDATA.box.left], eax
1551
        jmp     .check_height
1552
 
1553
  .fix_height_high:
1554
        mov     edx, esi
1555
        mov     [edi + WDATA.box.height], esi
1556
        jmp     .check_top
1557
 
1558
  .fix_top_low:
1559
        xor     ebx, ebx
1560
        mov     [edi + WDATA.box.top], ebx
1561
        jmp     .exit
1562
 
1563
  .fix_top_high:
1564
        mov     ebx, esi
1565
        sub     ebx, edx
1566
        mov     [edi + WDATA.box.top], ebx
1567
        jmp     .exit
1568
 
1362 mikedld 1569
align 4
1570
;------------------------------------------------------------------------------
1571
window._.get_titlebar_height: ;////////////////////////////////////////////////
1572
;------------------------------------------------------------------------------
1391 mikedld 1573
;? 
1574
;------------------------------------------------------------------------------
1362 mikedld 1575
;> edi = pointer to WDATA
1576
;------------------------------------------------------------------------------
1577
        mov     al, [edi + WDATA.fl_wstyle]
1578
        and     al, 0x0f
1579
        cmp     al, 0x03
1580
        jne     @f
1581
        mov     eax, [_skinh]
1582
        ret
1583
    @@: mov     eax, 21
1584
        ret
1585
 
1586
align 4
1587
;------------------------------------------------------------------------------
1588
window._.get_rolledup_height: ;////////////////////////////////////////////////
1589
;------------------------------------------------------------------------------
1391 mikedld 1590
;? 
1591
;------------------------------------------------------------------------------
1362 mikedld 1592
;> edi = pointer to WDATA
1593
;------------------------------------------------------------------------------
1594
        mov     al, [edi + WDATA.fl_wstyle]
1595
        and     al, 0x0f
1596
        cmp     al, 0x03
1597
        jb      @f
1598
        mov     eax, [_skinh]
1599
        add     eax, 3
1600
        ret
1601
    @@: or      al, al
1602
        jnz     @f
1603
        mov     eax, 21
1604
        ret
1605
    @@: mov     eax, 21 + 2
1606
        ret
1607
 
1608
align 4
1609
;------------------------------------------------------------------------------
1610
window._.set_screen: ;/////////////////////////////////////////////////////////
1611
;------------------------------------------------------------------------------
1612
;? Reserve window area in screen buffer
1613
;------------------------------------------------------------------------------
1614
;> eax = left
1615
;> ebx = top
1616
;> ecx = right
1617
;> edx = bottom
1618
;> esi = process number
1619
;------------------------------------------------------------------------------
1620
virtual at esp
1621
  ff_x     dd ?
1622
  ff_y     dd ?
1623
  ff_width dd ?
1624
  ff_xsz   dd ?
1625
  ff_ysz   dd ?
1626
  ff_scale dd ?
1627
end virtual
1628
 
1629
        pushad
1630
 
1631
        cmp     esi, 1
1632
        jz      .check_for_shaped_window
1633
        mov     edi, esi
1634
        shl     edi, 5
1635
        cmp     [window_data + edi + WDATA.box.width], 0
1636
        jnz     .check_for_shaped_window
1637
        cmp     [window_data + edi + WDATA.box.height], 0
1638
        jz      .exit
1639
 
1640
  .check_for_shaped_window:
1641
        mov     edi, esi
1642
        shl     edi, 8
1643
        add     edi, SLOT_BASE
1644
        cmp     [edi + APPDATA.wnd_shape], 0
1645
        jne     .shaped_window
1646
 
1647
        ; get x&y size
1648
        sub     ecx, eax
1649
        sub     edx, ebx
1650
        inc     ecx
1651
        inc     edx
1652
 
1653
        ; get WinMap start
1368 mikedld 1654
        push    esi
1362 mikedld 1655
        mov     edi, [Screen_Max_X]
1656
        inc     edi
1368 mikedld 1657
        mov     esi, edi
1362 mikedld 1658
        imul    edi, ebx
1659
        add     edi, eax
1660
        add     edi, [_WinMapAddress]
1368 mikedld 1661
        pop     eax
1662
        mov     ah, al
1663
        push    ax
1664
        shl     eax, 16
1665
        pop     ax
1362 mikedld 1666
 
1667
  .next_line:
1668
        push    ecx
1368 mikedld 1669
        shr     ecx, 2
1670
        rep     stosd
1671
        mov     ecx, [esp]
1672
        and     ecx, 3
1362 mikedld 1673
        rep     stosb
1674
        pop     ecx
1368 mikedld 1675
        add     edi, esi
1362 mikedld 1676
        sub     edi, ecx
1677
        dec     edx
1678
        jnz     .next_line
1679
 
1680
        jmp     .exit
1681
 
1682
  .shaped_window:
1683
        ;  for (y=0; y <= x_size; y++)
1684
        ;      for (x=0; x <= x_size; x++)
1685
        ;          if (shape[coord(x,y,scale)]==1)
1686
        ;             set_pixel(x, y, process_number);
1687
 
1688
        sub     ecx, eax
1689
        sub     edx, ebx
1690
        inc     ecx
1691
        inc     edx
1692
 
1693
        push    [edi + APPDATA.wnd_shape_scale]  ; push scale first -> for loop
1694
 
1695
        ; get WinMap start  -> ebp
1696
        push    eax
1697
        mov     eax, [Screen_Max_X] ; screen_sx
1698
        inc     eax
1699
        imul    eax, ebx
1700
        add     eax, [esp]
1701
        add     eax, [_WinMapAddress]
1702
        mov     ebp, eax
1703
 
1704
        mov     edi, [edi + APPDATA.wnd_shape]
1705
        pop     eax
1706
 
1707
        ; eax = x_start
1708
        ; ebx = y_start
1709
        ; ecx = x_size
1710
        ; edx = y_size
1711
        ; esi = process_number
1712
        ; edi = &shape
1713
        ;       [scale]
1714
        push    edx ecx ; for loop - x,y size
1715
 
1716
        mov     ecx, esi
1717
        shl     ecx, 5
1718
        mov     edx, [window_data + ecx + WDATA.box.top]
1719
        push    [window_data + ecx + WDATA.box.width]           ; for loop - width
1720
        mov     ecx, [window_data + ecx + WDATA.box.left]
1721
        sub     ebx, edx
1722
        sub     eax, ecx
1723
        push    ebx eax ; for loop - x,y
1724
 
1725
        add     [ff_xsz], eax
1726
        add     [ff_ysz], ebx
1727
 
1728
        mov     ebx, [ff_y]
1729
 
1730
  .ff_new_y:
1731
        mov     edx, [ff_x]
1732
 
1733
  .ff_new_x:
1734
        ; -- body --
1735
        mov     ecx, [ff_scale]
1736
        mov     eax, [ff_width]
1737
        inc     eax
1738
        shr     eax, cl
1739
        push    ebx edx
1740
        shr     ebx, cl
1741
        shr     edx, cl
1742
        imul    eax, ebx
1743
        add     eax, edx
1744
        pop     edx ebx
1745
        add     eax, edi
1746
        call    .read_byte
1747
        test    al,al
1748
        jz      @f
1749
        mov     eax, esi
1750
        mov     [ebp], al
1751
        ; -- end body --
1752
    @@: inc     ebp
1753
        inc     edx
1754
        cmp     edx, [ff_xsz]
1755
        jb      .ff_new_x
1756
 
1757
        sub     ebp, [ff_xsz]
1758
        add     ebp, [ff_x]
1759
        add     ebp, [Screen_Max_X]  ; screen.x
1760
        inc     ebp
1761
        inc     ebx
1762
        cmp     ebx, [ff_ysz]
1763
        jb      .ff_new_y
1764
 
1765
        add     esp, 24
1766
 
1767
  .exit:
1768
        popad
1769
        ret
1770
 
1771
  .read_byte:
1772
        ; eax - address
1773
        ; esi - slot
1774
        push    eax ecx edx esi
1775
        xchg    eax, esi
1776
        lea     ecx, [esp + 12]
1777
        mov     edx, 1
1778
        call    read_process_memory
1779
        pop     esi edx ecx eax
1780
        ret
1781
 
1782
align 4
1783
;------------------------------------------------------------------------------
1784
window._.window_activate: ;////////////////////////////////////////////////////
1785
;------------------------------------------------------------------------------
1786
;? Activate window
1787
;------------------------------------------------------------------------------
1788
;> esi = pointer to WIN_POS+ window data
1789
;------------------------------------------------------------------------------
1790
        push    eax ebx
1791
 
1792
        ; if type of current active window is 3 or 4, it must be redrawn
1368 mikedld 1793
        mov     ebx, [TASK_COUNT]
1794
        movzx   ebx, word[WIN_POS + ebx * 2]
1795
        shl     ebx, 5
1362 mikedld 1796
        add     eax, window_data
1368 mikedld 1797
        mov     al, [window_data + ebx + WDATA.fl_wstyle]
1798
        and     al, 0x0f
1799
        cmp     al, 0x03
1362 mikedld 1800
        je      .set_window_redraw_flag
1368 mikedld 1801
        cmp     al, 0x04
1802
        jne     .move_others_down
1362 mikedld 1803
 
1804
  .set_window_redraw_flag:
1368 mikedld 1805
        mov     [window_data + ebx + WDATA.fl_redraw], 1
1362 mikedld 1806
 
1807
  .move_others_down:
1808
        ; ax <- process no
1368 mikedld 1809
        movzx   ebx, word[esi]
1362 mikedld 1810
        ; ax <- position in window stack
1368 mikedld 1811
        movzx   ebx, word[WIN_STACK + ebx * 2]
1362 mikedld 1812
 
1813
        ; drop others
1368 mikedld 1814
        xor     eax, eax
1362 mikedld 1815
 
1816
  .next_stack_window:
1368 mikedld 1817
        cmp     eax, [TASK_COUNT]
1362 mikedld 1818
        jae     .move_self_up
1368 mikedld 1819
        inc     eax
1820
        cmp     [WIN_STACK + eax * 2], bx
1362 mikedld 1821
        jbe     .next_stack_window
1368 mikedld 1822
        dec     word[WIN_STACK + eax * 2]
1362 mikedld 1823
        jmp     .next_stack_window
1824
 
1825
  .move_self_up:
1368 mikedld 1826
        movzx   ebx, word[esi]
1362 mikedld 1827
        ; number of processes
1368 mikedld 1828
        mov     ax, [TASK_COUNT]
1362 mikedld 1829
        ; this is the last (and the upper)
1368 mikedld 1830
        mov     [WIN_STACK + ebx * 2], ax
1362 mikedld 1831
 
1832
        ; update on screen - window stack
1368 mikedld 1833
        xor     eax, eax
1362 mikedld 1834
 
1835
  .next_window_pos:
1368 mikedld 1836
        cmp     eax, [TASK_COUNT]
1362 mikedld 1837
        jae     .reset_vars
1368 mikedld 1838
        inc     eax
1839
        movzx   ebx, word[WIN_STACK + eax * 2]
1840
        mov     [WIN_POS + ebx * 2], ax
1362 mikedld 1841
        jmp     .next_window_pos
1842
 
1843
  .reset_vars:
1844
        mov     byte[KEY_COUNT], 0
1845
        mov     byte[BTN_COUNT], 0
1846
        mov     word[MOUSE_SCROLL_H], 0
1847
        mov     word[MOUSE_SCROLL_V], 0
1848
 
1849
        pop     ebx eax
1850
        ret
1851
 
1852
align 4
1853
;------------------------------------------------------------------------------
1854
window._.check_window_draw: ;//////////////////////////////////////////////////
1855
;------------------------------------------------------------------------------
1856
;? Check if window is necessary to draw
1857
;------------------------------------------------------------------------------
1858
;> edi = pointer to WDATA
1859
;------------------------------------------------------------------------------
1860
        mov     cl, [edi + WDATA.fl_wstyle]
1861
        and     cl, 0x0f
1391 mikedld 1862
        cmp     cl, 3
1362 mikedld 1863
        je      .exit.redraw      ; window type 3
1391 mikedld 1864
        cmp     cl, 4
1362 mikedld 1865
        je      .exit.redraw      ; window type 4
1866
 
1867
        push    eax ebx edx esi
1868
 
1869
        mov     eax, edi
1870
        sub     eax, window_data
1871
        shr     eax, 5
1872
 
1873
        movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
1874
        lea     esi, [WIN_POS + eax * 2]        ; get address of this process at 0xC400
1875
 
1876
  .next_window:
1877
        add     esi, 2
1878
 
1879
        mov     eax, [TASK_COUNT]
1880
        lea     eax, word[WIN_POS + eax * 2] ; number of the upper window
1881
 
1882
        cmp     esi, eax
1883
        ja      .exit.no_redraw
1884
 
1885
        movzx   edx, word[esi]
1886
        shl     edx, 5
1887
        cmp     [CURRENT_TASK + edx + TASKDATA.state], TSTATE_FREE
1888
        je      .next_window
1889
 
1890
        mov     eax, [edi + WDATA.box.top]
1891
        mov     ebx, [edi + WDATA.box.height]
1892
        add     ebx, eax
1893
 
1894
        mov     ecx, [window_data + edx + WDATA.box.top]
1895
        cmp     ecx, ebx
1896
        jge     .next_window
1897
        add     ecx, [window_data + edx + WDATA.box.height]
1898
        cmp     eax, ecx
1899
        jge     .next_window
1900
 
1901
        mov     eax, [edi + WDATA.box.left]
1902
        mov     ebx, [edi + WDATA.box.width]
1903
        add     ebx, eax
1904
 
1905
        mov     ecx, [window_data + edx + WDATA.box.left]
1906
        cmp     ecx, ebx
1907
        jge     .next_window
1908
        add     ecx, [window_data + edx + WDATA.box.width]
1909
        cmp     eax, ecx
1910
        jge     .next_window
1911
 
1912
        pop     esi edx ebx eax
1913
 
1914
  .exit.redraw:
1915
        xor     ecx, ecx
1916
        inc     ecx
1917
        ret
1918
 
1919
  .exit.no_redraw:
1920
        pop     esi edx ebx eax
1921
        xor     ecx, ecx
1922
        ret
1923
 
1924
align 4
1925
;------------------------------------------------------------------------------
1391 mikedld 1926
window._.draw_window_caption: ;////////////////////////////////////////////////
1362 mikedld 1927
;------------------------------------------------------------------------------
1391 mikedld 1928
;? 
1362 mikedld 1929
;------------------------------------------------------------------------------
1391 mikedld 1930
        inc     [mouse_pause]
1931
        call    [_display.disable_mouse]
1362 mikedld 1932
 
1391 mikedld 1933
        xor     eax, eax
1934
        mov     edx, [TASK_COUNT]
1935
        movzx   edx, word[WIN_POS + edx * 2]
1936
        cmp     edx, [CURRENT_TASK]
1937
        jne     @f
1938
        inc     eax
1939
    @@: mov     edx, [CURRENT_TASK]
1940
        shl     edx, 5
1941
        add     edx, window_data
1942
        movzx   ebx, [edx + WDATA.fl_wstyle]
1943
        and     bl, 0x0F
1944
        cmp     bl, 3
1945
        je      .draw_caption_style_3
1946
        cmp     bl, 4
1947
        je      .draw_caption_style_3
1362 mikedld 1948
 
1391 mikedld 1949
        jmp     .not_style_3
1362 mikedld 1950
 
1391 mikedld 1951
  .draw_caption_style_3:
1952
        push    edx
1953
        call    drawwindow_IV_caption
1954
        add     esp, 4
1955
        jmp     .2
1956
 
1957
  .not_style_3:
1958
        cmp     bl, 2
1959
        jne     .not_style_2
1960
 
1961
        call    drawwindow_III_caption
1962
        jmp     .2
1963
 
1964
  .not_style_2:
1965
        cmp     bl, 0
1966
        jne     .2
1967
 
1968
        call    drawwindow_I_caption
1969
 
1970
  .2:   mov     edi, [CURRENT_TASK]
1971
        shl     edi, 5
1972
        test    [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
1973
        jz      .exit
1974
        mov     edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
1975
        or      edx, edx
1976
        jz      .exit
1977
 
1978
        movzx   eax, [edi + window_data + WDATA.fl_wstyle]
1979
        and     al, 0x0F
1980
        cmp     al, 3
1981
        je      .skinned
1982
        cmp     al, 4
1983
        je      .skinned
1984
 
1985
        jmp     .not_skinned
1986
 
1987
  .skinned:
1988
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
1989
        mov     bp, word[edi + window_data + WDATA.box.top]
1990
        movzx   eax, word[edi + window_data + WDATA.box.width]
1991
        sub     ax, [_skinmargins.left]
1992
        sub     ax, [_skinmargins.right]
1993
        push    edx
1994
        cwde
1995
        cdq
1996
        mov     ebx, 6
1997
        idiv    ebx
1998
        pop     edx
1999
        or      eax, eax
2000
        js      .exit
2001
 
2002
        mov     esi, eax
2003
        mov     ebx, dword[_skinmargins.left - 2]
2004
        mov     bx, word[_skinh]
2005
        sub     bx, [_skinmargins.bottom]
2006
        sub     bx, [_skinmargins.top]
2007
        sar     bx, 1
2008
        adc     bx, 0
2009
        add     bx, [_skinmargins.top]
2010
        add     bx, -3
2011
        add     ebx, ebp
2012
        jmp     .dodraw
2013
 
2014
  .not_skinned:
2015
        cmp     al, 1
2016
        je      .exit
2017
 
2018
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
2019
        mov     bp, word[edi + window_data + WDATA.box.top]
2020
        movzx   eax, word[edi + window_data + WDATA.box.width]
2021
        sub     eax, 16
2022
        push    edx
2023
        cwde
2024
        cdq
2025
        mov     ebx, 6
2026
        idiv    ebx
2027
        pop     edx
2028
        or      eax, eax
2029
        js      .exit
2030
 
2031
        mov     esi, eax
2032
        mov     ebx, 0x00080007
2033
        add     ebx, ebp
2034
 
2035
  .dodraw:
2036
        mov     ecx, [common_colours + 16]
2037
        or      ecx, 0x80000000
2038
        xor     edi, edi
2039
        call    dtext_asciiz_esi
2040
 
1362 mikedld 2041
  .exit:
1391 mikedld 2042
        dec     [mouse_pause]
2043
        call    [draw_pointer]
1362 mikedld 2044
        ret
2045
 
1391 mikedld 2046
align 4
2047
;------------------------------------------------------------------------------
2048
window._.draw_negative_box: ;//////////////////////////////////////////////////
2049
;------------------------------------------------------------------------------
2050
;? Draw negative box
2051
;------------------------------------------------------------------------------
2052
;> edi = pointer to BOX struct
2053
;------------------------------------------------------------------------------
2054
        push    eax ebx esi
2055
        mov     eax, [edi + BOX.left - 2]
2056
        mov     ax, word[edi + BOX.left]
2057
        add     ax, word[edi + BOX.width]
2058
        mov     ebx, [edi + BOX.top - 2]
2059
        mov     bx, word[edi + BOX.top]
2060
        add     bx, word[edi + BOX.height]
2061
        mov     esi, 0x01000000
2062
        call    draw_rectangle.forced
2063
        pop     esi ebx eax
2064
        ret