Subversion Repositories Kolibri OS

Rev

Rev 1526 | Rev 1550 | 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: 1540 $
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
;------------------------------------------------------------------------------
1540 diamond 395
        mov     byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable
1362 mikedld 396
        push    eax ecx
397
        xor     eax, eax
398
        mov     ecx, WIN_STACK
399
    @@: inc     eax
400
        add     ecx, 2
401
        ; process no
402
        mov     [ecx + 0x000], ax
403
        ; positions in stack
404
        mov     [ecx + 0x400], ax
405
        cmp     ecx, WIN_POS - 2
406
        jne     @b
407
        pop     ecx eax
408
        ret
409
 
410
align 4
411
;------------------------------------------------------------------------------
412
calculatescreen: ;/////////////////////////////////////////////////////////////
413
;------------------------------------------------------------------------------
414
;? Scan all windows from bottom to top, calling `setscreen` for each one
415
;? intersecting given screen area
416
;------------------------------------------------------------------------------
417
;> eax = left
418
;> ebx = top
419
;> ecx = right
420
;> edx = bottom
421
;------------------------------------------------------------------------------
422
        push    esi
423
        pushfd
424
        cli
425
 
426
        mov     esi, 1
427
        call    window._.set_screen
428
 
429
        push    ebp
430
 
431
        mov     ebp, [TASK_COUNT]
432
        cmp     ebp, 1
433
        jbe     .exit
434
 
435
        push    edx ecx ebx eax
436
 
437
  .next_window:
438
        movzx   edi, word[WIN_POS + esi * 2]
439
        shl     edi, 5
440
 
441
        cmp     [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE
442
        je      .skip_window
443
 
444
        add     edi, window_data
445
        test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
446
        jnz     .skip_window
447
 
448
        mov     eax, [edi + WDATA.box.left]
449
        cmp     eax, [esp + RECT.right]
1368 mikedld 450
        jg      .skip_window
1362 mikedld 451
        mov     ebx, [edi + WDATA.box.top]
452
        cmp     ebx, [esp + RECT.bottom]
1368 mikedld 453
        jg      .skip_window
1362 mikedld 454
        mov     ecx, [edi + WDATA.box.width]
455
        add     ecx, eax
456
        cmp     ecx, [esp + RECT.left]
1368 mikedld 457
        jl      .skip_window
1362 mikedld 458
        mov     edx, [edi + WDATA.box.height]
459
        add     edx, ebx
460
        cmp     edx, [esp + RECT.top]
1368 mikedld 461
        jl      .skip_window
1362 mikedld 462
 
463
        cmp     eax, [esp + RECT.left]
464
        jae     @f
465
        mov     eax, [esp + RECT.left]
466
    @@: cmp     ebx, [esp + RECT.top]
467
        jae     @f
468
        mov     ebx, [esp + RECT.top]
469
    @@: cmp     ecx, [esp + RECT.right]
470
        jbe     @f
471
        mov     ecx, [esp + RECT.right]
472
    @@: cmp     edx, [esp + RECT.bottom]
473
        jbe     @f
474
        mov     edx, [esp + RECT.bottom]
475
 
476
    @@: push    esi
477
        movzx   esi, word[WIN_POS + esi * 2]
478
        call    window._.set_screen
479
        pop     esi
480
 
481
  .skip_window:
482
        inc     esi
483
        dec     ebp
484
        jnz     .next_window
485
 
486
        pop     eax ebx ecx edx
487
 
488
  .exit:
489
        pop     ebp
490
        popfd
491
        pop     esi
492
        ret
493
 
494
align 4
495
;------------------------------------------------------------------------------
496
repos_windows: ;///////////////////////////////////////////////////////////////
497
;------------------------------------------------------------------------------
498
;? 
499
;------------------------------------------------------------------------------
500
        mov     ecx, [TASK_COUNT]
501
        mov     edi, window_data + WDATA.sizeof * 2
502
        call    force_redraw_background
503
        dec     ecx
504
        jle     .exit
505
 
506
  .next_window:
507
        mov     [edi + WDATA.fl_redraw], 1
508
        test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
509
        jnz     .fix_maximized
510
 
511
        mov     eax, [edi + WDATA.box.left]
512
        add     eax, [edi + WDATA.box.width]
513
        mov     ebx, [Screen_Max_X]
514
        cmp     eax, ebx
515
        jle     .fix_vertical
516
        mov     eax, [edi + WDATA.box.width]
517
        sub     eax, ebx
518
        jle     @f
519
        mov     [edi + WDATA.box.width], ebx
520
    @@: sub     ebx, [edi + WDATA.box.width]
521
        mov     [edi + WDATA.box.left], ebx
522
 
523
  .fix_vertical:
524
        mov     eax, [edi + WDATA.box.top]
525
        add     eax, [edi + WDATA.box.height]
526
        mov     ebx, [Screen_Max_Y]
527
        cmp     eax, ebx
528
        jle     .fix_client_box
529
        mov     eax, [edi + WDATA.box.height]
530
        sub     eax, ebx
531
        jle     @f
532
        mov     [edi + WDATA.box.height], ebx
533
    @@: sub     ebx, [edi + WDATA.box.height]
534
        mov     [edi + WDATA.box.top], ebx
535
        jmp     .fix_client_box
536
 
537
  .fix_maximized:
538
        mov     eax, [screen_workarea.left]
539
        mov     [edi + WDATA.box.left], eax
540
        sub     eax, [screen_workarea.right]
541
        neg     eax
542
        mov     [edi + WDATA.box.width], eax
543
        mov     eax, [screen_workarea.top]
544
        mov     [edi + WDATA.box.top], eax
545
        test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
546
        jnz     .fix_client_box
547
        sub     eax, [screen_workarea.bottom]
548
        neg     eax
549
        mov     [edi + WDATA.box.height], eax
550
 
551
  .fix_client_box:
1391 mikedld 552
        call    window._.set_window_clientbox
1362 mikedld 553
 
554
        add     edi, WDATA.sizeof
555
        loop    .next_window
556
 
557
  .exit:
558
        ret
559
 
560
align 4
561
;------------------------------------------------------------------------------
562
sys_window_mouse: ;////////////////////////////////////////////////////////////
563
;------------------------------------------------------------------------------
564
;? 
565
;------------------------------------------------------------------------------
1391 mikedld 566
        ; NOTE: commented out since doesn't provide necessary functionality
567
        ;       anyway, to be reworked
568
;       push    eax
569
;
570
;       mov     eax, [timer_ticks]
571
;       cmp     [new_window_starting], eax
572
;       jb      .exit
573
;
574
;       mov     byte[MOUSE_BACKGROUND], 0
575
;       mov     byte[DONT_DRAW_MOUSE], 0
576
;
577
;       mov     [new_window_starting], eax
578
;
579
; .exit:
580
;       pop     eax
1362 mikedld 581
        ret
582
 
583
align 4
584
;------------------------------------------------------------------------------
585
draw_rectangle: ;//////////////////////////////////////////////////////////////
586
;------------------------------------------------------------------------------
587
;> eax = pack[16(left), 16(right)]
588
;> ebx = pack[16(top), 16(bottom)]
589
;> esi = color
590
;------------------------------------------------------------------------------
591
        push    eax ebx ecx edi
592
 
593
        xor     edi, edi
594
 
595
  .flags_set:
596
        push    ebx
597
 
598
        ; set line color
599
        mov     ecx, esi
600
 
601
        ; draw top border
602
        rol     ebx, 16
603
        push    ebx
604
        rol     ebx, 16
605
        pop     bx
606
        call    [draw_line]
607
 
608
        ; draw bottom border
609
        mov     ebx, [esp - 2]
610
        pop     bx
611
        call    [draw_line]
612
 
613
        pop     ebx
614
        add     ebx, 1 * 65536 - 1
615
 
616
        ; draw left border
617
        rol     eax, 16
618
        push    eax
619
        rol     eax, 16
620
        pop     ax
621
        call    [draw_line]
622
 
623
        ; draw right border
624
        mov     eax, [esp - 2]
625
        pop     ax
626
        call    [draw_line]
627
 
628
        pop     edi ecx ebx eax
629
        ret
630
 
631
  .forced:
632
        push    eax ebx ecx edi
633
        xor     edi, edi
634
        inc     edi
635
        jmp     .flags_set
636
 
637
align 4
638
;------------------------------------------------------------------------------
639
drawwindow_I_caption: ;////////////////////////////////////////////////////////
640
;------------------------------------------------------------------------------
641
;? 
642
;------------------------------------------------------------------------------
643
        push    [edx + WDATA.cl_titlebar]
644
        mov     esi, edx
645
 
646
        mov     edx, [esi + WDATA.box.top]
647
        mov     eax, edx
648
        lea     ebx, [edx + 21]
649
        inc     edx
650
        add     eax, [esi + WDATA.box.height]
651
 
652
        cmp     ebx, eax
653
        jbe     @f
654
        mov     ebx, eax
655
    @@: push    ebx
656
 
657
        xor     edi, edi
658
 
659
  .next_line:
660
        mov     ebx, edx
661
        shl     ebx, 16
662
        add     ebx, edx
663
        mov     eax, [esi + WDATA.box.left]
664
        inc     eax
665
        shl     eax, 16
666
        add     eax, [esi + WDATA.box.left]
667
        add     eax, [esi + WDATA.box.width]
668
        dec     eax
669
        mov     ecx, [esi + WDATA.cl_titlebar]
670
        test    ecx, 0x80000000
671
        jz      @f
672
        sub     ecx, 0x00040404
673
        mov     [esi + WDATA.cl_titlebar], ecx
674
    @@: and     ecx, 0x00ffffff
675
        call    [draw_line]
676
        inc     edx
677
        cmp     edx, [esp]
678
        jb      .next_line
679
 
680
        add     esp, 4
681
        pop     [esi + WDATA.cl_titlebar]
682
        ret
683
 
684
align 4
685
;------------------------------------------------------------------------------
686
drawwindow_I: ;////////////////////////////////////////////////////////////////
687
;------------------------------------------------------------------------------
688
;? 
689
;------------------------------------------------------------------------------
690
        pushad
691
 
692
        ; window border
693
 
694
        mov     eax, [edx + WDATA.box.left - 2]
695
        mov     ax, word[edx + WDATA.box.left]
696
        add     ax, word[edx + WDATA.box.width]
697
        mov     ebx, [edx + WDATA.box.top - 2]
698
        mov     bx, word[edx + WDATA.box.top]
699
        add     bx, word[edx + WDATA.box.height]
700
 
701
        mov     esi, [edx + WDATA.cl_frames]
702
        call    draw_rectangle
703
 
704
        ; window caption
705
 
706
        call    drawwindow_I_caption
707
 
708
        ; window client area
709
 
710
        ; do we need to draw it?
711
        mov     edi, [esi + WDATA.cl_workarea]
712
        test    edi, 0x40000000
713
        jnz     .exit
714
 
715
        ; does client area have a positive size on screen?
716
        mov     edx, [esi + WDATA.box.top]
717
        add     edx, 21 + 5
718
        mov     ebx, [esi + WDATA.box.top]
719
        add     ebx, [esi + WDATA.box.height]
720
        cmp     edx, ebx
721
        jg      .exit
722
 
723
        ; okay, let's draw it
724
        mov     eax, 1
725
        mov     ebx, 21
726
        mov     ecx, [esi + WDATA.box.width]
727
        mov     edx, [esi + WDATA.box.height]
728
        call    [drawbar]
729
 
730
  .exit:
731
        popad
732
        ret
733
 
734
align 4
735
;------------------------------------------------------------------------------
736
drawwindow_III_caption: ;/////////////////////////////////////////////////////
737
;------------------------------------------------------------------------------
738
;? 
739
;------------------------------------------------------------------------------
740
        mov     ecx, [edx + WDATA.cl_titlebar]
741
        push    ecx
742
        mov     esi, edx
743
        mov     edx, [esi + WDATA.box.top]
744
        add     edx, 4
745
        mov     ebx, [esi + WDATA.box.top]
746
        add     ebx, 20
747
        mov     eax, [esi + WDATA.box.top]
748
        add     eax, [esi + WDATA.box.height]
749
 
750
        cmp     ebx, eax
751
        jb      @f
752
        mov     ebx, eax
753
    @@: push    ebx
754
 
755
        xor     edi, edi
756
 
757
  .next_line:
758
        mov     ebx, edx
759
        shl     ebx, 16
760
        add     ebx, edx
761
        mov     eax, [esi + WDATA.box.left]
762
        shl     eax, 16
763
        add     eax, [esi + WDATA.box.left]
764
        add     eax, [esi + WDATA.box.width]
765
        add     eax, 4 * 65536 - 4
766
        mov     ecx, [esi + WDATA.cl_titlebar]
767
        test    ecx, 0x40000000
768
        jz      @f
769
        add     ecx, 0x00040404
770
    @@: test    ecx, 0x80000000
771
        jz      @f
772
        sub     ecx, 0x00040404
773
    @@: mov     [esi + WDATA.cl_titlebar], ecx
774
        and     ecx, 0x00ffffff
775
        call    [draw_line]
776
        inc     edx
777
        cmp     edx, [esp]
778
        jb      .next_line
779
 
780
        add     esp, 4
781
        pop     [esi + WDATA.cl_titlebar]
782
        ret
783
 
784
align 4
785
;------------------------------------------------------------------------------
786
drawwindow_III: ;//////////////////////////////////////////////////////////////
787
;------------------------------------------------------------------------------
788
;? 
789
;------------------------------------------------------------------------------
790
        pushad
791
 
792
        ; window border
793
 
794
        mov     eax, [edx + WDATA.box.left - 2]
795
        mov     ax, word[edx + WDATA.box.left]
796
        add     ax, word[edx + WDATA.box.width]
797
        mov     ebx, [edx + WDATA.box.top - 2]
798
        mov     bx, word[edx + WDATA.box.top]
799
        add     bx, word[edx + WDATA.box.height]
800
 
801
        mov     esi, [edx + WDATA.cl_frames]
802
        shr     esi, 1
803
        and     esi, 0x007f7f7f
804
        call    draw_rectangle
805
 
806
        push    esi
807
        mov     ecx, 3
808
        mov     esi, [edx + WDATA.cl_frames]
809
 
810
  .next_frame:
811
        add     eax, 1 * 65536 - 1
812
        add     ebx, 1 * 65536 - 1
813
        call    draw_rectangle
814
        dec     ecx
815
        jnz     .next_frame
816
 
817
        pop     esi
818
        add     eax, 1 * 65536 - 1
819
        add     ebx, 1 * 65536 - 1
820
        call    draw_rectangle
821
 
822
        ; window caption
823
 
824
        call    drawwindow_III_caption
825
 
826
        ; window client area
827
 
828
        ; do we need to draw it?
829
        mov     edi, [esi + WDATA.cl_workarea]
830
        test    edi, 0x40000000
831
        jnz     .exit
832
 
833
        ; does client area have a positive size on screen?
834
        mov     edx, [esi + WDATA.box.top]
835
        add     edx, 21 + 5
836
        mov     ebx, [esi + WDATA.box.top]
837
        add     ebx, [esi + WDATA.box.height]
838
        cmp     edx, ebx
839
        jg      .exit
840
 
841
        ; okay, let's draw it
842
        mov     eax, 5
843
        mov     ebx, 20
844
        mov     ecx, [esi + WDATA.box.width]
845
        mov     edx, [esi + WDATA.box.height]
846
        sub     ecx, 4
847
        sub     edx, 4
848
        call    [drawbar]
849
 
850
  .exit:
851
        popad
852
        ret
853
 
854
align 4
855
;------------------------------------------------------------------------------
856
waredraw: ;////////////////////////////////////////////////////////////////////
857
;------------------------------------------------------------------------------
858
;? Activate window, redrawing if necessary
859
;------------------------------------------------------------------------------
1465 mario79 860
        push    -1
1391 mikedld 861
        mov     eax, [TASK_COUNT]
862
        lea     eax, [WIN_POS + eax * 2]
863
        cmp     eax, esi
1465 mario79 864
        pop     eax
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?
1526 diamond 1040
        ; only types 2 and 3 can be resized
1391 mikedld 1041
        mov     dl, [edi + WDATA.fl_wstyle]
1526 diamond 1042
        test    dl, 2
1043
        jz      .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
 
1474 diamond 1292
; don't do anything if the new box is identical to the old
1293
	cmp	bl, [edi + WDATA.fl_wstate]
1294
	jnz	@f
1295
	mov	esi, eax
1296
	push	edi
1297
if WDATA.box
1298
	add	edi, WDATA.box
1299
end if
1300
	mov	ecx, 4
1301
	repz	cmpsd
1302
	pop	edi
1303
	jz	.exit
1304
@@:
1305
 
1391 mikedld 1306
        add     esp, -BOX.sizeof
1362 mikedld 1307
 
1391 mikedld 1308
        mov     ebx, esp
1424 diamond 1309
if WDATA.box
1391 mikedld 1310
        lea     esi, [edi + WDATA.box]
1424 diamond 1311
else
1312
	mov	esi, edi ; optimization for WDATA.box = 0
1313
end if
1391 mikedld 1314
        xchg    eax, esi
1315
        mov     ecx, BOX.sizeof
1316
        call    memmove
1317
        xchg    eax, esi
1318
        xchg    ebx, esi
1319
        call    memmove
1424 diamond 1320
        mov     eax, ebx
1321
        mov     ebx, esi
1362 mikedld 1322
 
1391 mikedld 1323
        call    window._.check_window_position
1324
        call    window._.set_window_clientbox
1325
        call    window._.invalidate_screen
1362 mikedld 1326
 
1391 mikedld 1327
        add     esp, BOX.sizeof
1362 mikedld 1328
 
1391 mikedld 1329
        mov     cl, [esp + 4]
1330
        mov     ch, cl
1331
        xchg    cl, [edi + WDATA.fl_wstate]
1362 mikedld 1332
 
1391 mikedld 1333
        or      cl, ch
1334
        test    cl, WSTATE_MAXIMIZED
1335
        jnz     .exit
1362 mikedld 1336
 
1391 mikedld 1337
        mov     eax, edi
1338
        sub     eax, window_data
1339
        shl     eax, 3
1340
        add     eax, SLOT_BASE
1362 mikedld 1341
 
1391 mikedld 1342
        lea     ebx, [edi + WDATA.box]
1343
        xchg    esp, ebx
1362 mikedld 1344
 
1391 mikedld 1345
        pop     [eax + APPDATA.saved_box.left] \
1346
                [eax + APPDATA.saved_box.top] \
1347
                [eax + APPDATA.saved_box.width] \
1348
                edx
1362 mikedld 1349
 
1391 mikedld 1350
        xchg    esp, ebx
1362 mikedld 1351
 
1391 mikedld 1352
        test    ch, WSTATE_ROLLEDUP
1353
        jnz     .exit
1362 mikedld 1354
 
1391 mikedld 1355
        mov     [eax + APPDATA.saved_box.height], edx
1362 mikedld 1356
 
1391 mikedld 1357
  .exit:
1358
        pop     esi ebx eax
1359
        ret
1362 mikedld 1360
 
1391 mikedld 1361
align 4
1362
;------------------------------------------------------------------------------
1363
window._.set_window_clientbox: ;///////////////////////////////////////////////
1364
;------------------------------------------------------------------------------
1365
;? 
1366
;------------------------------------------------------------------------------
1367
;> edi = pointer to WDATA struct
1368
;------------------------------------------------------------------------------
1369
        push    eax ecx edi
1362 mikedld 1370
 
1391 mikedld 1371
        mov     eax, [_skinh]
1372
        mov     [window_topleft + 8 * 3 + 4], eax
1373
        mov     [window_topleft + 8 * 4 + 4], eax
1362 mikedld 1374
 
1391 mikedld 1375
        mov     ecx, edi
1376
        sub     edi, window_data
1377
        shl     edi, 3
1378
        test    [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
1379
        jz      .whole_window
1362 mikedld 1380
 
1391 mikedld 1381
        movzx   eax, [ecx + WDATA.fl_wstyle]
1382
        and     eax, 0x0F
1383
        mov     eax, [eax * 8 + window_topleft + 0]
1384
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1385
        shl     eax, 1
1386
        neg     eax
1387
        add     eax, [ecx + WDATA.box.width]
1388
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1362 mikedld 1389
 
1391 mikedld 1390
        movzx   eax, [ecx + WDATA.fl_wstyle]
1391
        and     eax, 0x0F
1392
        push    [eax * 8 + window_topleft + 0]
1393
        mov     eax, [eax * 8 + window_topleft + 4]
1394
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1395
        neg     eax
1396
        sub     eax, [esp]
1397
        add     eax, [ecx + WDATA.box.height]
1398
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1399
        add     esp, 4
1400
        jmp     .exit
1362 mikedld 1401
 
1391 mikedld 1402
  .whole_window:
1403
        xor     eax, eax
1404
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
1405
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
1406
        mov     eax, [ecx + WDATA.box.width]
1407
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
1408
        mov     eax, [ecx + WDATA.box.height]
1409
        mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
1362 mikedld 1410
 
1391 mikedld 1411
  .exit:
1412
        pop     edi ecx eax
1413
        ret
1362 mikedld 1414
 
1391 mikedld 1415
align 4
1416
;------------------------------------------------------------------------------
1417
window._.sys_set_window: ;/////////////////////////////////////////////////////
1418
;------------------------------------------------------------------------------
1419
;? 
1420
;------------------------------------------------------------------------------
1421
;< edx = pointer to WDATA struct
1422
;------------------------------------------------------------------------------
1423
        mov     eax, [CURRENT_TASK]
1424
        shl     eax, 5
1425
        add     eax, window_data
1362 mikedld 1426
 
1391 mikedld 1427
        ; save window colors
1428
        mov     [eax + WDATA.cl_workarea], edx
1429
        mov     [eax + WDATA.cl_titlebar], esi
1430
        mov     [eax + WDATA.cl_frames], edi
1362 mikedld 1431
 
1391 mikedld 1432
        mov     edi, eax
1362 mikedld 1433
 
1391 mikedld 1434
        ; was it already defined before?
1435
        test    [edi + WDATA.fl_wdrawn], 1
1436
        jnz     .set_client_box
1362 mikedld 1437
 
1391 mikedld 1438
        ; NOTE: commented out since doesn't provide necessary functionality
1439
        ;       anyway, to be reworked
1440
;       mov     eax, [timer_ticks] ; [0xfdf0]
1441
;       add     eax, 100
1442
;       mov     [new_window_starting], eax
1443
 
1444
        ; no it wasn't, performing initial window definition
1445
        movzx   eax, bx
1362 mikedld 1446
        mov     [edi + WDATA.box.width], eax
1391 mikedld 1447
        movzx   eax, cx
1362 mikedld 1448
        mov     [edi + WDATA.box.height], eax
1391 mikedld 1449
        sar     ebx, 16
1450
        sar     ecx, 16
1451
        mov     [edi + WDATA.box.left], ebx
1452
        mov     [edi + WDATA.box.top], ecx
1362 mikedld 1453
 
1391 mikedld 1454
        call    window._.check_window_position
1362 mikedld 1455
 
1391 mikedld 1456
        push    ecx edi
1362 mikedld 1457
 
1391 mikedld 1458
        mov     cl, [edi + WDATA.fl_wstyle]
1459
        mov     eax, [edi + WDATA.cl_frames]
1362 mikedld 1460
 
1391 mikedld 1461
        sub     edi, window_data
1462
        shl     edi, 3
1463
        add     edi, SLOT_BASE
1362 mikedld 1464
 
1391 mikedld 1465
        and     cl, 0x0F
1466
        cmp     cl, 3
1467
        je      @f
1468
        cmp     cl, 4
1469
        je      @f
1362 mikedld 1470
 
1391 mikedld 1471
        xor     eax, eax
1362 mikedld 1472
 
1391 mikedld 1473
    @@: mov     [edi + APPDATA.wnd_caption], eax
1362 mikedld 1474
 
1391 mikedld 1475
        mov     esi, [esp]
1476
        add     edi, APPDATA.saved_box
1477
        movsd
1478
        movsd
1479
        movsd
1480
        movsd
1362 mikedld 1481
 
1391 mikedld 1482
        pop     edi ecx
1483
 
1484
        mov     esi, [CURRENT_TASK]
1485
        movzx   esi, word[WIN_STACK + esi * 2]
1486
        lea     esi, [WIN_POS + esi * 2]
1487
        call    waredraw
1488
 
1362 mikedld 1489
        mov     eax, [edi + WDATA.box.left]
1490
        mov     ebx, [edi + WDATA.box.top]
1491
        mov     ecx, [edi + WDATA.box.width]
1492
        mov     edx, [edi + WDATA.box.height]
1493
        add     ecx, eax
1494
        add     edx, ebx
1495
        call    calculatescreen
1496
 
1391 mikedld 1497
        mov     byte[KEY_COUNT], 0           ; empty keyboard buffer
1498
        mov     byte[BTN_COUNT], 0           ; empty button buffer
1362 mikedld 1499
 
1391 mikedld 1500
  .set_client_box:
1501
        ; update window client box coordinates
1502
        call    window._.set_window_clientbox
1362 mikedld 1503
 
1391 mikedld 1504
        ; reset window redraw flag and exit
1505
        mov     [edi + WDATA.fl_redraw], 0
1506
        mov     edx, edi
1507
        ret
1362 mikedld 1508
 
1391 mikedld 1509
align 4
1510
;------------------------------------------------------------------------------
1511
window._.check_window_position: ;//////////////////////////////////////////////
1512
;------------------------------------------------------------------------------
1513
;? Check if window is inside screen area
1514
;------------------------------------------------------------------------------
1515
;> edi = pointer to WDATA
1516
;------------------------------------------------------------------------------
1517
        push    eax ebx ecx edx esi
1362 mikedld 1518
 
1391 mikedld 1519
        mov     eax, [edi + WDATA.box.left]
1520
        mov     ebx, [edi + WDATA.box.top]
1521
        mov     ecx, [edi + WDATA.box.width]
1522
        mov     edx, [edi + WDATA.box.height]
1362 mikedld 1523
 
1391 mikedld 1524
        mov     esi, [Screen_Max_X]
1525
        cmp     ecx, esi
1526
        ja      .fix_width_high
1362 mikedld 1527
 
1391 mikedld 1528
  .check_left:
1529
        or      eax, eax
1530
        jl      .fix_left_low
1531
        add     eax, ecx
1532
        cmp     eax, esi
1533
        jg      .fix_left_high
1362 mikedld 1534
 
1391 mikedld 1535
  .check_height:
1536
        mov     esi, [Screen_Max_Y]
1537
        cmp     edx, esi
1538
        ja      .fix_height_high
1539
 
1540
  .check_top:
1541
        or      ebx, ebx
1542
        jl      .fix_top_low
1543
        add     ebx, edx
1544
        cmp     ebx, esi
1545
        jg      .fix_top_high
1546
 
1362 mikedld 1547
  .exit:
1391 mikedld 1548
        pop     esi edx ecx ebx eax
1362 mikedld 1549
        ret
1550
 
1391 mikedld 1551
  .fix_width_high:
1552
        mov     ecx, esi
1553
        mov     [edi + WDATA.box.width], esi
1554
        jmp     .check_left
1362 mikedld 1555
 
1391 mikedld 1556
  .fix_left_low:
1557
        xor     eax, eax
1558
        mov     [edi + WDATA.box.left], eax
1559
        jmp     .check_height
1560
 
1561
  .fix_left_high:
1562
        mov     eax, esi
1563
        sub     eax, ecx
1564
        mov     [edi + WDATA.box.left], eax
1565
        jmp     .check_height
1566
 
1567
  .fix_height_high:
1568
        mov     edx, esi
1569
        mov     [edi + WDATA.box.height], esi
1570
        jmp     .check_top
1571
 
1572
  .fix_top_low:
1573
        xor     ebx, ebx
1574
        mov     [edi + WDATA.box.top], ebx
1575
        jmp     .exit
1576
 
1577
  .fix_top_high:
1578
        mov     ebx, esi
1579
        sub     ebx, edx
1580
        mov     [edi + WDATA.box.top], ebx
1581
        jmp     .exit
1582
 
1362 mikedld 1583
align 4
1584
;------------------------------------------------------------------------------
1585
window._.get_titlebar_height: ;////////////////////////////////////////////////
1586
;------------------------------------------------------------------------------
1391 mikedld 1587
;? 
1588
;------------------------------------------------------------------------------
1362 mikedld 1589
;> edi = pointer to WDATA
1590
;------------------------------------------------------------------------------
1591
        mov     al, [edi + WDATA.fl_wstyle]
1592
        and     al, 0x0f
1593
        cmp     al, 0x03
1594
        jne     @f
1595
        mov     eax, [_skinh]
1596
        ret
1597
    @@: mov     eax, 21
1598
        ret
1599
 
1600
align 4
1601
;------------------------------------------------------------------------------
1602
window._.get_rolledup_height: ;////////////////////////////////////////////////
1603
;------------------------------------------------------------------------------
1391 mikedld 1604
;? 
1605
;------------------------------------------------------------------------------
1362 mikedld 1606
;> edi = pointer to WDATA
1607
;------------------------------------------------------------------------------
1608
        mov     al, [edi + WDATA.fl_wstyle]
1609
        and     al, 0x0f
1610
        cmp     al, 0x03
1611
        jb      @f
1612
        mov     eax, [_skinh]
1613
        add     eax, 3
1614
        ret
1615
    @@: or      al, al
1616
        jnz     @f
1617
        mov     eax, 21
1618
        ret
1619
    @@: mov     eax, 21 + 2
1620
        ret
1621
 
1622
align 4
1623
;------------------------------------------------------------------------------
1624
window._.set_screen: ;/////////////////////////////////////////////////////////
1625
;------------------------------------------------------------------------------
1626
;? Reserve window area in screen buffer
1627
;------------------------------------------------------------------------------
1628
;> eax = left
1629
;> ebx = top
1630
;> ecx = right
1631
;> edx = bottom
1632
;> esi = process number
1633
;------------------------------------------------------------------------------
1634
virtual at esp
1635
  ff_x     dd ?
1636
  ff_y     dd ?
1637
  ff_width dd ?
1638
  ff_xsz   dd ?
1639
  ff_ysz   dd ?
1640
  ff_scale dd ?
1641
end virtual
1642
 
1643
        pushad
1644
 
1645
        cmp     esi, 1
1646
        jz      .check_for_shaped_window
1647
        mov     edi, esi
1648
        shl     edi, 5
1649
        cmp     [window_data + edi + WDATA.box.width], 0
1650
        jnz     .check_for_shaped_window
1651
        cmp     [window_data + edi + WDATA.box.height], 0
1652
        jz      .exit
1653
 
1654
  .check_for_shaped_window:
1655
        mov     edi, esi
1656
        shl     edi, 8
1657
        add     edi, SLOT_BASE
1658
        cmp     [edi + APPDATA.wnd_shape], 0
1659
        jne     .shaped_window
1660
 
1661
        ; get x&y size
1662
        sub     ecx, eax
1663
        sub     edx, ebx
1664
        inc     ecx
1665
        inc     edx
1666
 
1667
        ; get WinMap start
1368 mikedld 1668
        push    esi
1362 mikedld 1669
        mov     edi, [Screen_Max_X]
1670
        inc     edi
1368 mikedld 1671
        mov     esi, edi
1362 mikedld 1672
        imul    edi, ebx
1673
        add     edi, eax
1674
        add     edi, [_WinMapAddress]
1368 mikedld 1675
        pop     eax
1676
        mov     ah, al
1677
        push    ax
1678
        shl     eax, 16
1679
        pop     ax
1362 mikedld 1680
 
1681
  .next_line:
1682
        push    ecx
1368 mikedld 1683
        shr     ecx, 2
1684
        rep     stosd
1685
        mov     ecx, [esp]
1686
        and     ecx, 3
1362 mikedld 1687
        rep     stosb
1688
        pop     ecx
1368 mikedld 1689
        add     edi, esi
1362 mikedld 1690
        sub     edi, ecx
1691
        dec     edx
1692
        jnz     .next_line
1693
 
1694
        jmp     .exit
1695
 
1696
  .shaped_window:
1697
        ;  for (y=0; y <= x_size; y++)
1698
        ;      for (x=0; x <= x_size; x++)
1699
        ;          if (shape[coord(x,y,scale)]==1)
1700
        ;             set_pixel(x, y, process_number);
1701
 
1702
        sub     ecx, eax
1703
        sub     edx, ebx
1704
        inc     ecx
1705
        inc     edx
1706
 
1707
        push    [edi + APPDATA.wnd_shape_scale]  ; push scale first -> for loop
1708
 
1709
        ; get WinMap start  -> ebp
1710
        push    eax
1711
        mov     eax, [Screen_Max_X] ; screen_sx
1712
        inc     eax
1713
        imul    eax, ebx
1714
        add     eax, [esp]
1715
        add     eax, [_WinMapAddress]
1716
        mov     ebp, eax
1717
 
1718
        mov     edi, [edi + APPDATA.wnd_shape]
1719
        pop     eax
1720
 
1721
        ; eax = x_start
1722
        ; ebx = y_start
1723
        ; ecx = x_size
1724
        ; edx = y_size
1725
        ; esi = process_number
1726
        ; edi = &shape
1727
        ;       [scale]
1728
        push    edx ecx ; for loop - x,y size
1729
 
1730
        mov     ecx, esi
1731
        shl     ecx, 5
1732
        mov     edx, [window_data + ecx + WDATA.box.top]
1733
        push    [window_data + ecx + WDATA.box.width]           ; for loop - width
1734
        mov     ecx, [window_data + ecx + WDATA.box.left]
1735
        sub     ebx, edx
1736
        sub     eax, ecx
1737
        push    ebx eax ; for loop - x,y
1738
 
1739
        add     [ff_xsz], eax
1740
        add     [ff_ysz], ebx
1741
 
1742
        mov     ebx, [ff_y]
1743
 
1744
  .ff_new_y:
1745
        mov     edx, [ff_x]
1746
 
1747
  .ff_new_x:
1748
        ; -- body --
1749
        mov     ecx, [ff_scale]
1750
        mov     eax, [ff_width]
1751
        inc     eax
1752
        shr     eax, cl
1753
        push    ebx edx
1754
        shr     ebx, cl
1755
        shr     edx, cl
1756
        imul    eax, ebx
1757
        add     eax, edx
1758
        pop     edx ebx
1759
        add     eax, edi
1760
        call    .read_byte
1761
        test    al,al
1762
        jz      @f
1763
        mov     eax, esi
1764
        mov     [ebp], al
1765
        ; -- end body --
1766
    @@: inc     ebp
1767
        inc     edx
1768
        cmp     edx, [ff_xsz]
1769
        jb      .ff_new_x
1770
 
1771
        sub     ebp, [ff_xsz]
1772
        add     ebp, [ff_x]
1773
        add     ebp, [Screen_Max_X]  ; screen.x
1774
        inc     ebp
1775
        inc     ebx
1776
        cmp     ebx, [ff_ysz]
1777
        jb      .ff_new_y
1778
 
1779
        add     esp, 24
1780
 
1781
  .exit:
1782
        popad
1783
        ret
1784
 
1785
  .read_byte:
1786
        ; eax - address
1787
        ; esi - slot
1788
        push    eax ecx edx esi
1789
        xchg    eax, esi
1790
        lea     ecx, [esp + 12]
1791
        mov     edx, 1
1792
        call    read_process_memory
1793
        pop     esi edx ecx eax
1794
        ret
1795
 
1796
align 4
1797
;------------------------------------------------------------------------------
1798
window._.window_activate: ;////////////////////////////////////////////////////
1799
;------------------------------------------------------------------------------
1800
;? Activate window
1801
;------------------------------------------------------------------------------
1802
;> esi = pointer to WIN_POS+ window data
1803
;------------------------------------------------------------------------------
1804
        push    eax ebx
1805
 
1806
        ; if type of current active window is 3 or 4, it must be redrawn
1368 mikedld 1807
        mov     ebx, [TASK_COUNT]
1808
        movzx   ebx, word[WIN_POS + ebx * 2]
1809
        shl     ebx, 5
1362 mikedld 1810
        add     eax, window_data
1368 mikedld 1811
        mov     al, [window_data + ebx + WDATA.fl_wstyle]
1812
        and     al, 0x0f
1813
        cmp     al, 0x03
1362 mikedld 1814
        je      .set_window_redraw_flag
1368 mikedld 1815
        cmp     al, 0x04
1816
        jne     .move_others_down
1362 mikedld 1817
 
1818
  .set_window_redraw_flag:
1368 mikedld 1819
        mov     [window_data + ebx + WDATA.fl_redraw], 1
1362 mikedld 1820
 
1821
  .move_others_down:
1822
        ; ax <- process no
1368 mikedld 1823
        movzx   ebx, word[esi]
1362 mikedld 1824
        ; ax <- position in window stack
1368 mikedld 1825
        movzx   ebx, word[WIN_STACK + ebx * 2]
1362 mikedld 1826
 
1827
        ; drop others
1368 mikedld 1828
        xor     eax, eax
1362 mikedld 1829
 
1830
  .next_stack_window:
1368 mikedld 1831
        cmp     eax, [TASK_COUNT]
1362 mikedld 1832
        jae     .move_self_up
1368 mikedld 1833
        inc     eax
1834
        cmp     [WIN_STACK + eax * 2], bx
1362 mikedld 1835
        jbe     .next_stack_window
1368 mikedld 1836
        dec     word[WIN_STACK + eax * 2]
1362 mikedld 1837
        jmp     .next_stack_window
1838
 
1839
  .move_self_up:
1368 mikedld 1840
        movzx   ebx, word[esi]
1362 mikedld 1841
        ; number of processes
1368 mikedld 1842
        mov     ax, [TASK_COUNT]
1362 mikedld 1843
        ; this is the last (and the upper)
1368 mikedld 1844
        mov     [WIN_STACK + ebx * 2], ax
1362 mikedld 1845
 
1846
        ; update on screen - window stack
1368 mikedld 1847
        xor     eax, eax
1362 mikedld 1848
 
1849
  .next_window_pos:
1368 mikedld 1850
        cmp     eax, [TASK_COUNT]
1362 mikedld 1851
        jae     .reset_vars
1368 mikedld 1852
        inc     eax
1853
        movzx   ebx, word[WIN_STACK + eax * 2]
1854
        mov     [WIN_POS + ebx * 2], ax
1362 mikedld 1855
        jmp     .next_window_pos
1856
 
1857
  .reset_vars:
1858
        mov     byte[KEY_COUNT], 0
1859
        mov     byte[BTN_COUNT], 0
1860
        mov     word[MOUSE_SCROLL_H], 0
1861
        mov     word[MOUSE_SCROLL_V], 0
1862
 
1863
        pop     ebx eax
1864
        ret
1865
 
1866
align 4
1867
;------------------------------------------------------------------------------
1868
window._.check_window_draw: ;//////////////////////////////////////////////////
1869
;------------------------------------------------------------------------------
1870
;? Check if window is necessary to draw
1871
;------------------------------------------------------------------------------
1872
;> edi = pointer to WDATA
1873
;------------------------------------------------------------------------------
1874
        mov     cl, [edi + WDATA.fl_wstyle]
1875
        and     cl, 0x0f
1391 mikedld 1876
        cmp     cl, 3
1362 mikedld 1877
        je      .exit.redraw      ; window type 3
1391 mikedld 1878
        cmp     cl, 4
1362 mikedld 1879
        je      .exit.redraw      ; window type 4
1880
 
1881
        push    eax ebx edx esi
1882
 
1883
        mov     eax, edi
1884
        sub     eax, window_data
1885
        shr     eax, 5
1886
 
1887
        movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
1888
        lea     esi, [WIN_POS + eax * 2]        ; get address of this process at 0xC400
1889
 
1890
  .next_window:
1891
        add     esi, 2
1892
 
1893
        mov     eax, [TASK_COUNT]
1894
        lea     eax, word[WIN_POS + eax * 2] ; number of the upper window
1895
 
1896
        cmp     esi, eax
1897
        ja      .exit.no_redraw
1898
 
1899
        movzx   edx, word[esi]
1900
        shl     edx, 5
1901
        cmp     [CURRENT_TASK + edx + TASKDATA.state], TSTATE_FREE
1902
        je      .next_window
1903
 
1904
        mov     eax, [edi + WDATA.box.top]
1905
        mov     ebx, [edi + WDATA.box.height]
1906
        add     ebx, eax
1907
 
1908
        mov     ecx, [window_data + edx + WDATA.box.top]
1909
        cmp     ecx, ebx
1910
        jge     .next_window
1911
        add     ecx, [window_data + edx + WDATA.box.height]
1912
        cmp     eax, ecx
1913
        jge     .next_window
1914
 
1915
        mov     eax, [edi + WDATA.box.left]
1916
        mov     ebx, [edi + WDATA.box.width]
1917
        add     ebx, eax
1918
 
1919
        mov     ecx, [window_data + edx + WDATA.box.left]
1920
        cmp     ecx, ebx
1921
        jge     .next_window
1922
        add     ecx, [window_data + edx + WDATA.box.width]
1923
        cmp     eax, ecx
1924
        jge     .next_window
1925
 
1926
        pop     esi edx ebx eax
1927
 
1928
  .exit.redraw:
1929
        xor     ecx, ecx
1930
        inc     ecx
1931
        ret
1932
 
1933
  .exit.no_redraw:
1934
        pop     esi edx ebx eax
1935
        xor     ecx, ecx
1936
        ret
1937
 
1938
align 4
1939
;------------------------------------------------------------------------------
1391 mikedld 1940
window._.draw_window_caption: ;////////////////////////////////////////////////
1362 mikedld 1941
;------------------------------------------------------------------------------
1391 mikedld 1942
;? 
1362 mikedld 1943
;------------------------------------------------------------------------------
1391 mikedld 1944
        inc     [mouse_pause]
1945
        call    [_display.disable_mouse]
1362 mikedld 1946
 
1391 mikedld 1947
        xor     eax, eax
1948
        mov     edx, [TASK_COUNT]
1949
        movzx   edx, word[WIN_POS + edx * 2]
1950
        cmp     edx, [CURRENT_TASK]
1951
        jne     @f
1952
        inc     eax
1953
    @@: mov     edx, [CURRENT_TASK]
1954
        shl     edx, 5
1955
        add     edx, window_data
1956
        movzx   ebx, [edx + WDATA.fl_wstyle]
1957
        and     bl, 0x0F
1958
        cmp     bl, 3
1959
        je      .draw_caption_style_3
1960
        cmp     bl, 4
1961
        je      .draw_caption_style_3
1362 mikedld 1962
 
1391 mikedld 1963
        jmp     .not_style_3
1362 mikedld 1964
 
1391 mikedld 1965
  .draw_caption_style_3:
1966
        push    edx
1967
        call    drawwindow_IV_caption
1968
        add     esp, 4
1969
        jmp     .2
1970
 
1971
  .not_style_3:
1972
        cmp     bl, 2
1973
        jne     .not_style_2
1974
 
1975
        call    drawwindow_III_caption
1976
        jmp     .2
1977
 
1978
  .not_style_2:
1979
        cmp     bl, 0
1980
        jne     .2
1981
 
1982
        call    drawwindow_I_caption
1983
 
1984
  .2:   mov     edi, [CURRENT_TASK]
1985
        shl     edi, 5
1986
        test    [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
1987
        jz      .exit
1988
        mov     edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
1989
        or      edx, edx
1990
        jz      .exit
1991
 
1992
        movzx   eax, [edi + window_data + WDATA.fl_wstyle]
1993
        and     al, 0x0F
1994
        cmp     al, 3
1995
        je      .skinned
1996
        cmp     al, 4
1997
        je      .skinned
1998
 
1999
        jmp     .not_skinned
2000
 
2001
  .skinned:
2002
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
2003
        mov     bp, word[edi + window_data + WDATA.box.top]
2004
        movzx   eax, word[edi + window_data + WDATA.box.width]
2005
        sub     ax, [_skinmargins.left]
2006
        sub     ax, [_skinmargins.right]
2007
        push    edx
2008
        cwde
2009
        cdq
2010
        mov     ebx, 6
2011
        idiv    ebx
2012
        pop     edx
2013
        or      eax, eax
2014
        js      .exit
2015
 
2016
        mov     esi, eax
2017
        mov     ebx, dword[_skinmargins.left - 2]
2018
        mov     bx, word[_skinh]
2019
        sub     bx, [_skinmargins.bottom]
2020
        sub     bx, [_skinmargins.top]
2021
        sar     bx, 1
2022
        adc     bx, 0
2023
        add     bx, [_skinmargins.top]
2024
        add     bx, -3
2025
        add     ebx, ebp
2026
        jmp     .dodraw
2027
 
2028
  .not_skinned:
2029
        cmp     al, 1
2030
        je      .exit
2031
 
2032
        mov     ebp, [edi + window_data + WDATA.box.left - 2]
2033
        mov     bp, word[edi + window_data + WDATA.box.top]
2034
        movzx   eax, word[edi + window_data + WDATA.box.width]
2035
        sub     eax, 16
2036
        push    edx
2037
        cwde
2038
        cdq
2039
        mov     ebx, 6
2040
        idiv    ebx
2041
        pop     edx
2042
        or      eax, eax
2043
        js      .exit
2044
 
2045
        mov     esi, eax
2046
        mov     ebx, 0x00080007
2047
        add     ebx, ebp
2048
 
2049
  .dodraw:
2050
        mov     ecx, [common_colours + 16]
2051
        or      ecx, 0x80000000
2052
        xor     edi, edi
2053
        call    dtext_asciiz_esi
2054
 
1362 mikedld 2055
  .exit:
1391 mikedld 2056
        dec     [mouse_pause]
2057
        call    [draw_pointer]
1362 mikedld 2058
        ret
2059
 
1391 mikedld 2060
align 4
2061
;------------------------------------------------------------------------------
2062
window._.draw_negative_box: ;//////////////////////////////////////////////////
2063
;------------------------------------------------------------------------------
2064
;? Draw negative box
2065
;------------------------------------------------------------------------------
2066
;> edi = pointer to BOX struct
2067
;------------------------------------------------------------------------------
2068
        push    eax ebx esi
2069
        mov     eax, [edi + BOX.left - 2]
2070
        mov     ax, word[edi + BOX.left]
2071
        add     ax, word[edi + BOX.width]
2072
        mov     ebx, [edi + BOX.top - 2]
2073
        mov     bx, word[edi + BOX.top]
2074
        add     bx, word[edi + BOX.height]
2075
        mov     esi, 0x01000000
2076
        call    draw_rectangle.forced
2077
        pop     esi ebx eax
2078
        ret