Subversion Repositories Kolibri OS

Rev

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

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