Subversion Repositories Kolibri OS

Rev

Rev 996 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
709 diamond 3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
431 serge 4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
593 mikedld 8
$Revision: 2971 $
9
 
10
 
41 mikedld 11
get_titlebar_height: ; edi = window draw_data pointer
415 heavyiron 12
	mov	al,[edi+WDATA.fl_wstyle]
13
	and	al,0x0F
14
	cmp	al,0x03
15
	jne	@f
16
	mov	eax,[_skinh]
17
	ret
18
    @@: mov	eax,21
19
	ret
41 mikedld 20
 
21
get_rolledup_height: ; edi = window draw_data pointer
415 heavyiron 22
	mov	al,[edi+WDATA.fl_wstyle]
23
	and	al,0x0F
24
	cmp	al,0x03
2971 Serge 25
	jb	@f
415 heavyiron 26
	mov	eax,[_skinh]
27
	add	eax,3
28
	ret
29
    @@: or	al,al
30
	jnz	@f
31
	mov	eax,21
32
	ret
33
    @@: mov	eax,21+2
34
	ret
41 mikedld 35
 
36
 
1 ha 37
setwindowdefaults:
415 heavyiron 38
	pushad
1 ha 39
 
415 heavyiron 40
	xor   eax,eax
41
	mov   ecx,WIN_STACK
1 ha 42
       @@:
415 heavyiron 43
	inc   eax
44
	add   ecx,2
45
	mov   [ecx+0x000],ax	      ; process no
46
	mov   [ecx+0x400],ax	      ; positions in stack
47
	cmp   ecx,WIN_POS-2	       ; the more high, the more surface
48
	jnz   @b
1 ha 49
 
415 heavyiron 50
	popad
51
	ret
1 ha 52
 
53
 
54
 
55
; eax = cx
56
; ebx = cy
57
; ecx = ex
58
; edx = ey
59
; идея: перебрать все окна, начиная с самого нижнего,
112 poddubny 60
;       и для попавших в заданную область
61
;       частей окон вызвать setscreen
1 ha 62
align 4
63
calculatescreen:
2971 Serge 64
        pushad
65
        pushfd
66
        cli
1 ha 67
 
2971 Serge 68
        push    edx ecx ebx eax
1 ha 69
 
2971 Serge 70
        mov esi, 1
71
        call    setscreen
112 poddubny 72
 
2971 Serge 73
        mov ebp, [TASK_COUNT]    ; number of processes
74
        cmp ebp, 1
75
        jbe .finish
996 serge 76
align 4
77
.new_wnd:
2971 Serge 78
        movzx   edi, word [WIN_POS + esi * 2]
79
        shl edi, 5
102 poddubny 80
 
2971 Serge 81
        cmp [CURRENT_TASK+edi+TASKDATA.state], byte 9
82
        je  .not_wnd
102 poddubny 83
 
2971 Serge 84
        add edi, window_data
85
        test    [edi+WDATA.fl_wstate], WSTATE_MINIMIZED
86
        jnz .not_wnd
112 poddubny 87
 
2971 Serge 88
        mov eax,[edi+WDATA.box.left]
89
        cmp eax, [esp+RECT.right]
90
        ja  .out_of_bounds
91
        mov ebx,[edi+WDATA.box.top]
92
        cmp ebx, [esp+RECT.bottom]
93
        ja  .out_of_bounds
94
        mov ecx,[edi+WDATA.box.width]
95
        add ecx, eax
96
        cmp ecx, [esp+RECT.left]
97
        jb  .out_of_bounds
98
        mov edx,[edi+WDATA.box.height]
99
        add edx, ebx
100
        cmp edx, [esp+RECT.top]
101
        jb  .out_of_bounds
112 poddubny 102
 
2971 Serge 103
        cmp     eax, [esp+RECT.left]
104
        jae @f
105
        mov eax, [esp+RECT.left]
996 serge 106
@@:
2971 Serge 107
        cmp     ebx, [esp+RECT.top]
108
        jae @f
109
        mov ebx, [esp+RECT.top]
996 serge 110
@@:
2971 Serge 111
        cmp     ecx, [esp+RECT.right]
112
        jbe @f
113
        mov ecx, [esp+RECT.right]
996 serge 114
@@:
2971 Serge 115
        cmp     edx, [esp+RECT.bottom]
116
        jbe @f
117
        mov edx, [esp+RECT.bottom]
996 serge 118
@@:
112 poddubny 119
 
2971 Serge 120
        push    esi
121
        movzx   esi, word [WIN_POS + esi * 2]
122
        call    setscreen
123
        pop esi
112 poddubny 124
 
996 serge 125
.not_wnd:
126
.out_of_bounds:
2971 Serge 127
        inc esi
128
        dec ebp
129
        jnz .new_wnd
996 serge 130
.finish:
112 poddubny 131
 
2971 Serge 132
        pop     eax ebx ecx edx
112 poddubny 133
 
2971 Serge 134
        popfd
135
        popad
996 serge 136
        ret
1 ha 137
 
138
 
139
 
140
virtual at esp
415 heavyiron 141
  ff_x	   dd ?
142
  ff_y	   dd ?
112 poddubny 143
  ff_width dd ?
1 ha 144
  ff_xsz   dd ?
145
  ff_ysz   dd ?
146
  ff_scale dd ?
147
end virtual
148
 
149
align 4
150
; резервирует место под окно заданного процесса
151
setscreen:
152
;  eax  x start
153
;  ebx  y start
154
;  ecx  x end
155
;  edx  y end
156
;  esi  process number
157
pushad
142 diamond 158
; \begin{diamond}[29.08.2006]
415 heavyiron 159
	cmp	esi, 1
160
	jz	@f
161
	mov	edi, esi
162
	shl	edi, 5
163
	cmp	[edi+window_data+WDATA.box.width], 0
164
	jnz	@f
165
	cmp	[edi+window_data+WDATA.box.height], 0
166
	jz	.ret
142 diamond 167
@@:
168
; \end{diamond}[29.08.2006]
415 heavyiron 169
	mov edi, esi ;;;word [esi*2+WIN_POS]
170
	shl   edi, 8
171
	add   edi, SLOT_BASE  ; address of random shaped window area
172
	cmp   [edi+APPDATA.wnd_shape], dword 0
173
	jne   .free_form
1 ha 174
 
415 heavyiron 175
	; get x&y size
2971 Serge 176
        sub   ecx, eax
177
        sub   edx, ebx
178
        inc   ecx
179
        inc   edx
1 ha 180
 
415 heavyiron 181
	; get WinMap start
753 serge 182
        mov   edi, [Screen_Max_X] ; screen_sx
2971 Serge 183
        inc   edi
184
        imul  edi, ebx
185
        add   edi, eax
840 serge 186
        add   edi, [_display_data]
1 ha 187
 
996 serge 188
.new_y:
2971 Serge 189
        push  ecx ; sx
190
        push  edx
1 ha 191
 
2971 Serge 192
        mov   edx, esi
415 heavyiron 193
	align 4
996 serge 194
.new_x:
2971 Serge 195
        mov   byte [edi], dl
196
        inc   edi
197
        dec   ecx
198
        jnz   .new_x
1 ha 199
 
2971 Serge 200
        pop   edx
201
        pop   ecx
753 serge 202
        add   edi, [Screen_Max_X]
2971 Serge 203
        inc   edi
204
        sub   edi, ecx
205
        dec   edx
206
        jnz   .new_y
142 diamond 207
.ret:
2971 Serge 208
        popad
209
        ret
1 ha 210
  .read_byte:
211
   ;eax - address
212
   ;esi - slot
415 heavyiron 213
	push  eax
214
	push  ebx
215
	push  ecx
216
	push  edx
217
	mov   edx,eax
218
	mov   eax,esi
219
	lea   ebx,[esp+12]
220
	mov   ecx,1
221
	call  read_process_memory
222
	pop   edx
223
	pop   ecx
224
	pop   ebx
225
	pop   eax
226
	ret
1 ha 227
  .free_form:
228
 
415 heavyiron 229
	;  for (y=0; y <= x_size; y++)
230
	;      for (x=0; x <= x_size; x++)
231
	;          if (shape[coord(x,y,scale)]==1)
232
	;             set_pixel(x, y, process_number);
1 ha 233
 
415 heavyiron 234
	sub  ecx, eax
235
	sub  edx, ebx
236
	inc  ecx
237
	inc  edx
1 ha 238
 
415 heavyiron 239
	push  dword [edi+APPDATA.wnd_shape_scale]  ; push scale first -> for loop
1 ha 240
 
415 heavyiron 241
	; get WinMap start  -> ebp
242
	push  eax
753 serge 243
        mov   eax, [Screen_Max_X] ; screen_sx
415 heavyiron 244
	inc   eax
245
	imul  eax, ebx
246
	add   eax, [esp]
840 serge 247
        add   eax, [_display_data]
415 heavyiron 248
	mov   ebp, eax
1 ha 249
 
415 heavyiron 250
	mov   edi, [edi+APPDATA.wnd_shape]
251
	pop   eax
1 ha 252
 
415 heavyiron 253
	; eax = x_start
254
	; ebx = y_start
255
	; ecx = x_size
256
	; edx = y_size
257
	; esi = process_number
258
	; edi = &shape
259
	;       [scale]
260
	push edx ecx ; for loop - x,y size
112 poddubny 261
 
415 heavyiron 262
	mov  ecx, esi
263
	shl  ecx, 5
264
	mov  edx, [window_data+ecx+WDATA.box.top]
265
	push [window_data+ecx+WDATA.box.width]	    ; for loop - width
266
	mov  ecx, [window_data+ecx+WDATA.box.left]
267
	sub  ebx, edx
268
	sub  eax, ecx
269
	push ebx eax ; for loop - x,y
112 poddubny 270
 
415 heavyiron 271
	add  [ff_xsz], eax
272
	add  [ff_ysz], ebx
112 poddubny 273
 
415 heavyiron 274
	mov  ebx, [ff_y]
112 poddubny 275
 
1 ha 276
      .ff_new_y:
415 heavyiron 277
	mov  edx, [ff_x]
112 poddubny 278
 
1 ha 279
      .ff_new_x:
415 heavyiron 280
	; -- body --
281
	mov  ecx, [ff_scale]
282
	mov  eax, [ff_width]
283
	inc  eax
284
	shr  eax, cl
285
	push ebx edx
286
	shr  ebx, cl
287
	shr  edx, cl
288
	imul eax, ebx
289
	add  eax, edx
290
	pop  edx ebx
291
	add  eax, edi
292
	call .read_byte
293
	test al,al
294
	jz   @f
295
	mov  eax, esi
296
	mov  [ebp], al
1 ha 297
       @@:
415 heavyiron 298
	; -- end body --
299
	inc  ebp
300
	inc  edx
301
	cmp  edx, [ff_xsz]
302
	jb   .ff_new_x
303
	sub  ebp, [ff_xsz]
304
	add  ebp, [ff_x]
753 serge 305
        add  ebp, [Screen_Max_X]  ; screen.x
415 heavyiron 306
	inc  ebp
307
	inc  ebx
308
	cmp  ebx, [ff_ysz]
309
	jb   .ff_new_y
1 ha 310
 
415 heavyiron 311
	add  esp, 24
1 ha 312
popad
313
ret
314
 
315
 
316
display_settings:
317
 
318
;    eax = 0         ; DISPLAY redraw
319
;          ebx = 0   ; all
320
;
321
;    eax = 1         ; BUTTON type
322
;          ebx = 0   ; flat
323
;          ebx = 1   ; 3D
324
;    eax = 2         ; set WINDOW colours
325
;          ebx = pointer to table
326
;          ecx = number of bytes define
327
;    eax = 3         ; get WINDOW colours
328
;          ebx = pointer to table
329
;          ecx = number of bytes wanted
330
;    eax = 4         ; get skin height
331
;          input  : nothing
332
;          output : eax = skin height in pixel
41 mikedld 333
;    eax = 5         ; get screen workarea
334
;          input  : nothing
335
;          output : eax = [left]*65536+[right]
336
;                   ebx = [top]*65536+[bottom]
337
;    eax = 6         ; set screen workarea
338
;          input  : ecx = [left]*65536+[right]
339
;                   edx = [top]*65536+[bottom]
340
;          output : nothing
52 mikedld 341
;    eax = 7         ; get skin margins
342
;          input  : nothing
343
;          output : eax = [left]*65536+[right]
344
;                   ebx = [top]*65536+[bottom]
345
;    eax = 8         ; set window skin
346
;          input  : ecx = pointer to file info block
347
;          output : eax = FS error code
1 ha 348
 
349
 
350
     pushad
351
 
415 heavyiron 352
     test eax, eax	; redraw display
1 ha 353
     jnz  dspl0
354
     test ebx, ebx
355
     jnz  dspl0
356
     cmp  [windowtypechanged],dword 1
357
     jne  dspl00
358
     mov  [windowtypechanged],dword 0
41 mikedld 359
  redraw_screen_direct:
1 ha 360
     mov  [dlx],dword 0
361
     mov  [dly],dword 0
753 serge 362
     mov  eax,[Screen_Max_X]
1 ha 363
     mov  [dlxe],eax
753 serge 364
     mov  eax,[Screen_Max_Y]
1 ha 365
     mov  [dlye],eax
366
     mov  eax,window_data
367
     call redrawscreen
368
   dspl00:
369
     popad
370
     ret
371
   dspl0:
372
 
373
     cmp  eax,1       ; button type
374
     jne  dspl1
375
     and  ebx,1
376
     cmp  ebx,[buttontype]
377
     je   dspl9
378
     mov  [buttontype],ebx
379
     mov  [windowtypechanged],dword 1
380
    dspl9:
381
     popad
382
     ret
383
   dspl1:
384
 
385
     cmp  eax,2       ; set common window colours
386
     jne  no_com_colours
387
     mov  [windowtypechanged],dword 1
379 serge 388
     mov  esi,[TASK_BASE]
115 poddubny 389
     add  esi,TASKDATA.mem_start
54 mikedld 390
     add  ebx,[esi]
391
     mov  esi,ebx
1 ha 392
     mov  edi,common_colours
393
     and  ecx,127
394
     cld
395
     rep  movsb
396
     popad
397
     ret
398
   no_com_colours:
399
 
400
     cmp  eax,3       ; get common window colours
401
     jne  no_get_com
379 serge 402
     mov  esi,[TASK_BASE]
115 poddubny 403
     add  esi,TASKDATA.mem_start
1 ha 404
     add  ebx,[esi]
405
     mov  edi,ebx
406
     mov  esi,common_colours
407
     and  ecx,127
408
     cld
409
     rep  movsb
410
     popad
411
     ret
412
   no_get_com:
413
 
414
     cmp  eax,4       ; get skin height
415
     jne  no_skin_height
416
     popad
417
     mov  eax,[_skinh]
418
     mov  [esp+36],eax
419
     ret
420
   no_skin_height:
421
 
415 heavyiron 422
	cmp	eax,5	    ; get screen workarea
423
	jne	no_get_workarea
424
	popad
425
	mov	eax,[screen_workarea.left-2]
426
	mov	ax,word[screen_workarea.right]
427
	mov	[esp+36],eax
428
	mov	eax,[screen_workarea.top-2]
429
	mov	ax,word[screen_workarea.bottom]
430
	mov	[esp+24],eax
431
	ret
41 mikedld 432
   no_get_workarea:
433
 
415 heavyiron 434
	cmp	eax,6	    ; set screen workarea
435
	jne	no_set_workarea
436
	movsx	eax,word[esp+16+2]
437
	movsx	ebx,word[esp+16]
438
	cmp	eax,ebx
439
	jge	.lp1
753 serge 440
        or      eax,eax;[Screen_Max_X]
415 heavyiron 441
	jl	@f
442
	mov	[screen_workarea.left],eax
753 serge 443
    @@: cmp     ebx,[Screen_Max_X]
415 heavyiron 444
	jg	.lp1
445
	mov	[screen_workarea.right],ebx
446
  .lp1: movsx	eax,word[esp+24+2]
447
	movsx	ebx,word[esp+24]
448
	cmp	eax,ebx
449
	jge	.lp2
450
	or	eax,eax;[0xFE04]
451
	jl	@f
452
	mov	[screen_workarea.top],eax
753 serge 453
    @@: cmp     ebx,[Screen_Max_Y]
415 heavyiron 454
	jg	.lp2
455
	mov	[screen_workarea.bottom],ebx
456
  .lp2: call	repos_windows
457
	mov	eax, 0
458
	mov	ebx, 0
753 serge 459
        mov     ecx, [Screen_Max_X]
460
        mov     edx, [Screen_Max_Y]
117 mario79 461
    call    calculatescreen
462
;    jmp    redraw_screen_direct
49 mikedld 463
    .exit:
415 heavyiron 464
	popad
465
	ret
49 mikedld 466
   no_set_workarea:
41 mikedld 467
 
415 heavyiron 468
	cmp	eax,7	    ; get skin margins
469
	jne	no_get_skinmargins
470
	popad
471
	mov	eax,dword[_skinmargins+0]
472
	mov	[esp+36],eax
473
	mov	eax,dword[_skinmargins+4]
474
	mov	[esp+24],eax
475
	ret
52 mikedld 476
   no_get_skinmargins:
477
 
415 heavyiron 478
	cmp	eax,8	    ; set window skin
479
	jne	no_set_skin
523 diamond 480
        call    read_skin_file
481
        mov     [esp+32+36], eax
482
        test    eax, eax
483
        jnz     .ret
484
        xor     eax, eax
485
        xor     ebx, ebx
753 serge 486
        mov     ecx, [Screen_Max_X]
487
        mov     edx, [Screen_Max_Y]
523 diamond 488
        call    calculatescreen
415 heavyiron 489
	jmp	redraw_screen_direct
523 diamond 490
.ret:
491
        popad
492
        ret
52 mikedld 493
   no_set_skin:
494
 
49 mikedld 495
     popad
496
     ret
497
 
498
 
499
repos_windows:
415 heavyiron 500
	mov	ecx,[TASK_COUNT]
996 serge 501
    mov edi, window_data+0x20*2
709 diamond 502
	call    force_redraw_background
415 heavyiron 503
	dec	ecx
504
	jge    @f
505
	ret
506
    @@: mov	[edi+WDATA.fl_redraw],1
507
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
508
	jz	.lp2
509
	mov	eax,[screen_workarea.left]
510
	mov	[edi+WDATA.box.left],eax
511
	sub	eax,[screen_workarea.right]
512
	neg	eax
513
	mov	[edi+WDATA.box.width],eax
514
	mov	eax,[screen_workarea.top]
515
	mov	[edi+WDATA.box.top],eax
516
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
517
	jnz	.lp1
518
	sub	eax,[screen_workarea.bottom]
519
	neg	eax
520
	mov	[edi+WDATA.box.height],eax
150 diamond 521
  .lp1:
389 serge 522
 
415 heavyiron 523
	call	set_window_clientbox
524
	add	edi,0x20
525
	loop	@b
526
	ret
527
  .lp2: mov	eax,[edi+WDATA.box.left]
528
	add	eax,[edi+WDATA.box.width]
753 serge 529
    mov    ebx,[Screen_Max_X]
117 mario79 530
;    inc    ebx
531
    cmp    eax,ebx
532
    jle    .lp4
415 heavyiron 533
	mov	eax,[edi+WDATA.box.width]
117 mario79 534
    sub    eax,ebx
535
    jle    .lp3
415 heavyiron 536
	mov	[edi+WDATA.box.width],ebx
537
  .lp3: sub	ebx,[edi+WDATA.box.width]
538
	mov	[edi+WDATA.box.left],ebx
539
  .lp4: mov	eax,[edi+WDATA.box.top]
540
	add	eax,[edi+WDATA.box.height]
753 serge 541
    mov    ebx,[Screen_Max_Y]
117 mario79 542
;    inc    ebx
543
    cmp    eax,ebx
544
    jle    .lp6
415 heavyiron 545
	mov	eax,[edi+WDATA.box.height]
117 mario79 546
    sub    eax,ebx
547
    jle    .lp5
415 heavyiron 548
	mov	[edi+WDATA.box.height],ebx
549
  .lp5: sub	ebx,[edi+WDATA.box.height]
550
	mov	[edi+WDATA.box.top],ebx
551
  .lp6: jmp	.lp1
41 mikedld 552
 
1 ha 553
uglobal
554
  common_colours:
555
     times 128 db 0x0
556
endg
557
 
558
 
559
 
560
check_window_position:
561
 
415 heavyiron 562
    pushad			     ; window inside screen ?
1 ha 563
 
860 serge 564
    mov   eax, [edi+WDATA.box.left]
565
    mov   ebx, [edi+WDATA.box.top]
566
    mov   ecx, [edi+WDATA.box.width]
567
    mov   edx, [edi+WDATA.box.height]
1 ha 568
 
768 heavyiron 569
    cmp   ecx,[Screen_Max_X]	      ; check x size
1 ha 570
    jbe   x_size_ok
753 serge 571
    mov   ecx,[Screen_Max_X]
115 poddubny 572
    mov   [edi+WDATA.box.width],ecx
768 heavyiron 573
 
1 ha 574
  x_size_ok:
575
 
768 heavyiron 576
    cmp   edx,[Screen_Max_Y]	      ; check y size
1 ha 577
    jbe   y_size_ok
753 serge 578
    mov   edx,[Screen_Max_Y]
115 poddubny 579
    mov   [edi+WDATA.box.height],edx
768 heavyiron 580
 
1 ha 581
  y_size_ok:
582
 
768 heavyiron 583
    cmp   eax,0	      ; check x pos
584
    jnle  @f
585
    xor   eax,eax
586
    mov   [edi+WDATA.box.left],eax
587
    jmp   x_pos_ok
588
  @@:
589
    add   eax,ecx
590
    cmp   eax,[Screen_Max_X]
591
    jbe   x_pos_ok
592
    mov   eax,[Screen_Max_X]
593
    sub   eax,ecx
594
    mov   [edi+WDATA.box.left],eax
595
 
596
  x_pos_ok:
597
 
598
    cmp   ebx,0	      ; check x pos
599
    jnle  @f
600
    xor   ebx,ebx
601
    mov   [edi+WDATA.box.top],ebx
602
    jmp   y_pos_ok
603
  @@:
604
    add   ebx,edx
605
    cmp   ebx,[Screen_Max_Y]
606
    jbe   y_pos_ok
607
    mov   ebx,[Screen_Max_Y]
608
    sub   ebx,edx
609
    mov   [edi+WDATA.box.top],ebx
610
 
611
  y_pos_ok:
612
 
1 ha 613
    popad
614
 
615
    ret
616
 
617
 
114 mikedld 618
drawwindow_I_caption:
619
 
415 heavyiron 620
	mov   ecx,[edx+WDATA.cl_titlebar]   ; grab bar
621
	push  ecx
622
	mov   esi,edx
623
	mov   edx,[esi+WDATA.box.top]
624
	add   edx,1
625
	mov   ebx,[esi+WDATA.box.top]
626
	add   ebx,21
627
	mov   eax,[esi+WDATA.box.top]
628
	add   eax,[esi+WDATA.box.height]
629
	cmp   ebx,eax
630
	jb    .wdsizeok
631
	mov   ebx,eax
996 serge 632
.wdsizeok:
415 heavyiron 633
	push  ebx
996 serge 634
.drwi:
415 heavyiron 635
	mov   ebx,edx
636
	shl   ebx,16
637
	add   ebx,edx
638
	mov   eax,[esi+WDATA.box.left]
639
	inc   eax
640
	shl   eax,16
641
	add   eax,[esi+WDATA.box.left]
642
	add   eax,[esi+WDATA.box.width]
643
	sub   eax,1
644
	push  edx
645
	mov   edx,0x80000000
646
	mov   ecx,[esi+WDATA.cl_titlebar]
647
	and   ecx,edx
648
	cmp   ecx,edx
649
	jnz   .nofa
650
	mov   ecx,[esi+WDATA.cl_titlebar]
651
	sub   ecx,0x00040404
652
	mov   [esi+WDATA.cl_titlebar],ecx
653
	and   ecx,0x00ffffff
654
	jmp   .faj
996 serge 655
.nofa:
415 heavyiron 656
	mov   ecx,[esi+WDATA.cl_titlebar]
657
	and   ecx,0x00ffffff
996 serge 658
.faj:
415 heavyiron 659
	pop   edx
660
	mov   edi,0
661
	call  [draw_line]
662
	inc   edx
663
	cmp   edx,[esp]
664
	jb    .drwi
665
	add   esp,4
666
	pop   ecx
667
	mov   [esi+WDATA.cl_titlebar],ecx
1 ha 668
 
415 heavyiron 669
	ret
114 mikedld 670
 
671
 
672
drawwindow_I:
673
 
415 heavyiron 674
	pushad
675
	or	[edx+WDATA.fl_wdrawn], 4
114 mikedld 676
 
415 heavyiron 677
	mov   esi,[edx+WDATA.cl_frames]   ; rectangle
678
	mov   eax,[edx+WDATA.box.left]
679
	shl   eax,16
680
	add   eax,[edx+WDATA.box.left]
681
	add   eax,[edx+WDATA.box.width]
682
	mov   ebx,[edx+WDATA.box.top]
683
	shl   ebx,16
684
	add   ebx,[edx+WDATA.box.top]
685
	add   ebx,[edx+WDATA.box.height]
686
	call  draw_rectangle
114 mikedld 687
 
415 heavyiron 688
	and	[edx+WDATA.fl_wdrawn], not 4
689
	test	[edx+WDATA.fl_wdrawn], 2
690
	jz	@f
691
	call	drawwindowframes2
186 diamond 692
@@:
693
 
415 heavyiron 694
	call	drawwindow_I_caption
114 mikedld 695
 
415 heavyiron 696
	mov   edx,[esi+WDATA.box.top]	   ; inside work area
697
	add   edx,21+5
698
	mov   ebx,[esi+WDATA.box.top]
699
	add   ebx,[esi+WDATA.box.height]
700
	cmp   edx,ebx
701
	jg    noinside
702
	mov   eax,1
703
	mov   ebx,21
704
	mov   ecx,[esi+WDATA.box.width]
705
	mov   edx,[esi+WDATA.box.height]
706
	mov   edi,[esi+WDATA.cl_workarea]
303 mikedld 707
	test  edi,0x40000000
708
	jnz   noinside
415 heavyiron 709
	call  [drawbar]
996 serge 710
noinside:
1 ha 711
 
415 heavyiron 712
	popad
1 ha 713
 
415 heavyiron 714
	ret
1 ha 715
 
716
 
717
draw_rectangle:
718
 
719
r_eax equ [esp+28]   ; x start
720
r_ax  equ [esp+30]   ; x end
721
r_ebx equ [esp+16]   ; y start
722
r_bx  equ [esp+18]   ; y end
723
;esi                 ; color
724
 
415 heavyiron 725
	pushad
1 ha 726
 
415 heavyiron 727
	mov   ecx,esi	       ; yb,xb -> yb,xe
728
	mov   eax, r_eax
729
	rol   eax, 16
730
	mov   ebx,r_ebx
731
	shl   ebx,16
732
	mov   bx,r_ebx
733
	xor   edi, edi
734
	call  [draw_line]
1 ha 735
 
415 heavyiron 736
	mov   ebx,r_bx	       ; ye,xb -> ye,xe
737
	shl   ebx,16
738
	mov   bx,r_bx
739
	call  [draw_line]
1 ha 740
 
415 heavyiron 741
	mov   ecx,esi	       ; ya,xa -> ye,xa
742
	mov   eax,r_eax
743
	shl   eax,16
744
	mov   ax,r_eax
745
	mov   ebx,r_ebx
746
	shl   ebx,16
747
	mov   bx,r_bx
748
	mov   edi,0
749
	call  [draw_line]
1 ha 750
 
415 heavyiron 751
	mov   eax,r_ax	     ; ya,xe -> ye,xe
752
	shl   eax,16
753
	mov   ax,r_ax
754
	call  [draw_line]
1 ha 755
 
415 heavyiron 756
	popad
757
	ret
1 ha 758
 
759
 
114 mikedld 760
drawwindow_III_caption:
1 ha 761
 
415 heavyiron 762
	mov   ecx,[edx+WDATA.cl_titlebar]			; GRAB BAR
763
	push  ecx
764
	mov   esi,edx
765
	mov   edx,[esi+WDATA.box.top]
766
	add   edx,4
767
	mov   ebx,[esi+WDATA.box.top]
768
	add   ebx,20
769
	mov   eax,[esi+WDATA.box.top]
770
	add   eax,[esi+WDATA.box.height]
771
	cmp   ebx,eax
772
	jb    .wdsizeok
773
	mov   ebx,eax
996 serge 774
.wdsizeok:
415 heavyiron 775
	push  ebx
996 serge 776
.drwi:
415 heavyiron 777
	mov   ebx,edx
778
	shl   ebx,16
779
	add   ebx,edx
780
	mov   eax,[esi+WDATA.box.left]
781
	shl   eax,16
782
	add   eax,[esi+WDATA.box.left]
783
	add   eax,[esi+WDATA.box.width]
784
	add   eax,4*65536-4
785
	mov   ecx,[esi+WDATA.cl_titlebar]
786
	test  ecx,0x40000000
787
	jz    .nofa
788
	add   ecx,0x040404
996 serge 789
.nofa:
415 heavyiron 790
	test  ecx,0x80000000
791
	jz    .nofa2
792
	sub   ecx,0x040404
996 serge 793
.nofa2:
415 heavyiron 794
	mov   [esi+WDATA.cl_titlebar],ecx
795
	and   ecx,0xffffff
796
	xor   edi, edi
797
	call  [draw_line]
798
	inc   edx
799
	cmp   edx,[esp]
800
	jb    .drwi
801
	add   esp,4
802
	pop   ecx
803
	mov   [esi+WDATA.cl_titlebar],ecx
1 ha 804
 
415 heavyiron 805
	ret
114 mikedld 806
 
807
 
808
drawwindow_III:
809
 
415 heavyiron 810
	pushad
114 mikedld 811
 
415 heavyiron 812
	mov   edi,edx				   ; RECTANGLE
813
	mov   eax,[edi+WDATA.box.left]
814
	shl   eax,16
117 mario79 815
    mov   ax, word [edi+WDATA.box.left]
816
    add   ax, word [edi+WDATA.box.width]
415 heavyiron 817
	mov   ebx,[edi+WDATA.box.top]
818
	shl   ebx,16
117 mario79 819
    mov   bx, word [edi+WDATA.box.top]
820
    add   bx, word [edi+WDATA.box.height]
415 heavyiron 821
	mov   esi,[edi+WDATA.cl_frames]
822
	shr   esi,1
823
	and   esi,0x007f7f7f
824
	push  esi
825
	or	[edi+WDATA.fl_wdrawn], 4
826
	call  draw_rectangle
827
	and	[edi+WDATA.fl_wdrawn], not 4
828
	test	[edi+WDATA.fl_wdrawn], 2
829
	jz	@f
830
	call	drawwindowframes2
186 diamond 831
@@:
415 heavyiron 832
	mov   ecx,3
996 serge 833
dw3l:
415 heavyiron 834
	add   eax,1*65536-1
835
	add   ebx,1*65536-1
836
	mov   esi,[edi+WDATA.cl_frames]
837
	call  draw_rectangle
838
	dec   ecx
839
	jnz   dw3l
840
	pop   esi
841
	add   eax,1*65536-1
842
	add   ebx,1*65536-1
843
	call  draw_rectangle
114 mikedld 844
 
415 heavyiron 845
	call	drawwindow_III_caption
114 mikedld 846
 
415 heavyiron 847
	mov   edx,[esi+WDATA.box.top]			    ; WORK AREA
848
	add   edx,21+5
849
	mov   ebx,[esi+WDATA.box.top]
850
	add   ebx,[esi+WDATA.box.height]
851
	cmp   edx,ebx
852
	jg    noinside2
853
	mov   eax,5
854
	mov   ebx,20
855
	mov   ecx,[esi+WDATA.box.width]
856
	mov   edx,[esi+WDATA.box.height]
857
	sub   ecx,4
858
	sub   edx,4
859
	mov   edi,[esi+WDATA.cl_workarea]
303 mikedld 860
	test  edi,0x40000000
861
	jnz   noinside2
415 heavyiron 862
	call  [drawbar]
996 serge 863
noinside2:
415 heavyiron 864
	popad
1 ha 865
 
415 heavyiron 866
	ret
1 ha 867
 
868
 
869
 
870
; activate window
871
align 4
872
windowactivate:
873
 
415 heavyiron 874
	; esi = abs mem position in stack 0xC400+
1 ha 875
 
415 heavyiron 876
	pushad
102 poddubny 877
 
878
     ; if type of current active window is 3,
879
     ; it must be redrawn
415 heavyiron 880
	mov   eax, [TASK_COUNT]
881
	movzx eax, word [WIN_POS + eax*2]
882
	shl   eax, 5
883
	add   eax, window_data
884
	mov   ebx, [eax + WDATA.cl_workarea]
885
	and   ebx, 0x0f000000
886
	cmp   ebx, 0x03000000
549 spraid 887
	je   .set_WDATA_fl_redraw   ; for 3 and 4 style
888
	cmp   ebx, 0x04000000
889
	je   .set_WDATA_fl_redraw
890
	jmp @f
891
	.set_WDATA_fl_redraw:
415 heavyiron 892
	mov   [eax + WDATA.fl_redraw], byte 1
102 poddubny 893
     @@:
894
 
415 heavyiron 895
	push   esi
1 ha 896
      movzx   eax, word [esi] ; ax <- process no
380 serge 897
      movzx   eax, word [WIN_STACK+eax*2] ; ax <- position in window stack
1 ha 898
 
415 heavyiron 899
	xor   esi, esi	      ; drop others
928 serge 900
waloop:
415 heavyiron 901
	cmp   esi, dword [TASK_COUNT]
902
	jae   wacont
903
	inc   esi
904
	lea   edi, [WIN_STACK + esi*2]
905
	mov   bx, [edi] ; position of the current process
906
	cmp   bx, ax
907
	jbe   @f
908
	dec   bx       ; upper? => drop!
909
	mov   [edi], bx
1 ha 910
      @@:
415 heavyiron 911
	jmp   waloop
928 serge 912
wacont:
415 heavyiron 913
			    ; set to no 1
914
	pop   esi	    ;   esi = pointer at 0xC400
1 ha 915
 
928 serge 916
    movzx   eax, word [esi]
415 heavyiron 917
	mov   bx, [TASK_COUNT]	; number of processes
918
	mov   [WIN_STACK+eax*2], bx	; this is the last (and the upper)
1 ha 919
 
415 heavyiron 920
	; update on screen -window stack
921
	xor   esi, esi
928 serge 922
waloop2:
415 heavyiron 923
	mov   edi, [TASK_COUNT]
924
	cmp   esi, edi
925
	jae   wacont2
926
	inc   esi
927
	movzx ebx, word [esi*2 + WIN_STACK]
928
	mov   [ebx*2 + WIN_POS], si
929
	jmp   waloop2
928 serge 930
wacont2:
931
    mov   [KEY_COUNT],  0         ; empty keyboard buffer
932
    mov   [BTN_COUNT],  0             ; empty button buffer
933
    mov   [mouse_scroll_h],  0        ; zero mouse z-index
934
    mov   [mouse_scroll_v],  0        ; zero mouse z-index
415 heavyiron 935
	popad
936
	ret
1 ha 937
 
938
 
939
; check if window is necessary to draw
940
 
941
checkwindowdraw:
942
 
415 heavyiron 943
	; edi = position in window_data+
1 ha 944
 
415 heavyiron 945
	mov   eax, [edi + WDATA.cl_workarea]
946
	and   eax, 0x0f000000
947
	cmp   eax, 0x03000000
948
	je    .return_yes      ; window type 3
549 spraid 949
	cmp   eax, 0x04000000
950
	je    .return_yes      ; window type 4
102 poddubny 951
 
415 heavyiron 952
	mov   esi, edi
953
	sub   esi, window_data
954
	shr   esi, 5
1 ha 955
 
415 heavyiron 956
	; esi = process number
1 ha 957
 
415 heavyiron 958
	movzx eax, word [WIN_STACK + esi * 2] ; get value of the curr process
959
	lea   esi, [WIN_POS + eax * 2]	    ; get address of this process at 0xC400
1 ha 960
 
415 heavyiron 961
	push  esi
1 ha 962
 
996 serge 963
.new_check:
1 ha 964
 
415 heavyiron 965
	pop   esi
966
	add   esi, 2
967
	push  esi
1 ha 968
 
415 heavyiron 969
	mov   eax, [TASK_COUNT]
970
	lea   eax, word [WIN_POS + eax * 2] ; number of the upper window
1 ha 971
 
415 heavyiron 972
	cmp   esi, eax
973
	ja    .all_wnds_to_top
1 ha 974
 
415 heavyiron 975
	movzx eax, word [esi]
976
	shl   eax, 5
977
	cmp   [CURRENT_TASK + eax + TASKDATA.state], byte 9
978
	je    .new_check		    ; skip dead windows
1 ha 979
 
415 heavyiron 980
	lea   esi, [eax+window_data]
102 poddubny 981
 
415 heavyiron 982
	mov   ebx, [edi+WDATA.box.top]	; y0
983
	mov   edx, [edi+WDATA.box.height]
984
	add   edx, ebx	    ; y0e
1 ha 985
 
415 heavyiron 986
	mov   ecx, [esi+WDATA.box.top]	; y  ; y check
987
	cmp   ecx, edx
988
	jae   .new_check     ; y < y0e
989
	mov   eax, [esi+WDATA.box.height]
990
	add   ecx, eax	     ; ye
991
	cmp   ebx, ecx	     ; y0 >= ye
992
	ja    .new_check
1 ha 993
 
415 heavyiron 994
	mov   eax, [edi+WDATA.box.left]   ; x0
995
	mov   ecx, [edi+WDATA.box.width]
996
	add   ecx, eax	     ; x0e
1 ha 997
 
415 heavyiron 998
	mov   edx, [esi+WDATA.box.left]   ; x ; x check
999
	cmp   edx, ecx
1000
	jae   .new_check     ; x < x0e
1001
	mov   ecx, [esi+WDATA.box.width]
1002
	add   edx, ecx
1003
	cmp   eax, edx
1004
	ja    .new_check
1 ha 1005
 
415 heavyiron 1006
	pop   esi
102 poddubny 1007
  .return_yes:
415 heavyiron 1008
	mov   ecx,1   ; overlap some window
1009
	ret
1 ha 1010
 
1011
  .all_wnds_to_top:
1012
 
415 heavyiron 1013
	pop   esi
1 ha 1014
 
415 heavyiron 1015
	xor   ecx, ecx	     ; passed all windows to top
1016
	ret
1 ha 1017
 
1018
 
1019
waredraw:     ; if redraw necessary at activate
1020
 
415 heavyiron 1021
	pushad
1 ha 1022
 
415 heavyiron 1023
	call  checkwindowdraw	   ; draw window on activation ?
1024
	test  ecx, ecx
1025
	jz    .do_not_draw
1 ha 1026
 
415 heavyiron 1027
	popad
1028
	call  windowactivate
1 ha 1029
 
415 heavyiron 1030
	; update screen info
1031
	pushad
1032
	mov   edi, [TASK_COUNT] ; the last process (number)
1033
	movzx esi, word [WIN_POS + edi * 2]
1034
	shl   esi, 5
1035
	add   esi, window_data
1 ha 1036
 
415 heavyiron 1037
	; coordinates of the upper window
1038
    mov   eax, [esi + WDATA.box.left]	; cx
1039
    mov   ebx, [esi + WDATA.box.top]	; cy
1040
    mov   ecx, [esi + WDATA.box.width]	; sx
117 mario79 1041
    mov   edx, [esi + WDATA.box.height] ; sy
1 ha 1042
 
415 heavyiron 1043
	add   ecx, eax	     ; ecx = x_end
1044
	add   edx, ebx	     ; edx = y_end
1 ha 1045
 
415 heavyiron 1046
	mov   edi, [TASK_COUNT]
1047
	movzx esi, word [WIN_POS + edi * 2]
1048
	call  setscreen
1049
	popad
1 ha 1050
 
117 mario79 1051
    mov   [edi + WDATA.fl_redraw], 1  ; redraw flag for app
1 ha 1052
 
415 heavyiron 1053
	ret
1 ha 1054
 
996 serge 1055
.do_not_draw:
1 ha 1056
 
415 heavyiron 1057
	popad
1 ha 1058
 
415 heavyiron 1059
	call  windowactivate
996 serge 1060
    ret
1 ha 1061
 
1062
 
105 poddubny 1063
; eax = window number on screen
1064
; corrupts registers and [dl*]
1065
minimize_window:
415 heavyiron 1066
	movzx eax, word [WIN_POS+eax*2]
1067
	shl   eax, 5
1068
	add   eax, window_data
1069
	test  [eax+WDATA.fl_wstate], WSTATE_MINIMIZED
1070
	jnz   .skip_redrawings
1071
	pushfd
1072
	cli
1073
	or    [eax+WDATA.fl_wstate], WSTATE_MINIMIZED
1074
	mov   edi, eax
1075
	;call  calculatescreen
1076
	mov   eax, [edi+WDATA.box.left]
1077
	mov   [dlx], eax
1078
	mov   ecx, eax
1079
	add   ecx, [edi+WDATA.box.width]
1080
	mov   [dlxe], ecx
1081
	mov   ebx, [edi+WDATA.box.top]
1082
	mov   [dly], ebx
1083
	mov   edx, ebx
1084
	add   edx, [edi+WDATA.box.height]
1085
	mov   [dlye], edx
1086
	call  calculatescreen
1087
	xor   esi, esi
1088
	xor   eax, eax
1089
	call  redrawscreen
1090
	popfd
105 poddubny 1091
.skip_redrawings:
415 heavyiron 1092
	ret
105 poddubny 1093
 
1094
; eax = window number on screen
1095
; corrupts registers and [dl*]
1096
restore_minimized_window:
415 heavyiron 1097
	pushfd
1098
	cli
1099
	movzx esi, word [WIN_POS+eax*2]
1100
	mov   edi, esi
1101
	shl   edi, 5
1102
	add   edi, window_data
1103
	test  [edi+WDATA.fl_wstate], WSTATE_MINIMIZED
1104
	jz    .skip_redrawings
1105
	mov   [edi+WDATA.fl_redraw], 1
1106
	and   [edi+WDATA.fl_wstate], not WSTATE_MINIMIZED
1107
	cmp   eax, [TASK_COUNT] ; the uppermost window
1108
	jnz   .no_uppermost
1109
	mov   eax, [edi+WDATA.box.left]
1110
	mov   ebx, [edi+WDATA.box.top]
1111
	mov   ecx, eax
1112
	mov   edx, ebx
1113
	add   ecx, [edi+WDATA.box.width]
1114
	add   edx, [edi+WDATA.box.height]
1115
	call  setscreen
1116
	jmp   .done
105 poddubny 1117
.no_uppermost:
415 heavyiron 1118
	mov   eax, [edi+WDATA.box.left]
1119
	mov   ebx, [edi+WDATA.box.top]
1120
	mov   ecx, eax
1121
	mov   edx, ebx
1122
	add   ecx, [edi+WDATA.box.width]
1123
	add   edx, [edi+WDATA.box.height]
1124
	call  calculatescreen
105 poddubny 1125
.done:
1126
.skip_redrawings:
415 heavyiron 1127
	popfd
1128
	ret
105 poddubny 1129
 
1130
 
2971 Serge 1131
;iglobal
1132
;  window_moving   db 'K : Window - move/resize',13,10,0
1133
;  window_moved	  db 'K : Window - done',13,10,0
1134
;endg
1 ha 1135
 
1136
; check window touch
1137
align 4
1138
checkwindows:
415 heavyiron 1139
	pushad
1 ha 1140
 
415 heavyiron 1141
	cmp   [window_minimize], 0
1142
	je    .no_minimizing
1143
	mov   eax, [TASK_COUNT]       ; the uppermost window
1144
	mov   bl, 0
1145
	xchg  [window_minimize], bl
1146
	cmp   bl, 1
1147
	jne   .restore
1148
	call  minimize_window
1149
	jmp   .continue
996 serge 1150
.restore:
415 heavyiron 1151
	call  restore_minimized_window
996 serge 1152
.continue:
1153
.no_minimizing:
1 ha 1154
 
928 serge 1155
    cmp  byte [btn_down],   0    ; mouse buttons pressed ?
415 heavyiron 1156
	jne  .mouse_buttons_pressed
1157
;..................................... start 1/4 : modified by vhanla .................
1158
	mov [bPressedMouseXY_W],0
1159
;..................................... end 1/4 : modified by vhanla ...................
1160
	popad
1161
	ret
996 serge 1162
.mouse_buttons_pressed:
2971 Serge 1163
;..................................... start 2/4 : modified by vhanla .................
1164
uglobal
1165
	bPressedMouseXY_W db 0x0
1166
endg
1167
;..................................... end 2/4 : modified by vhanla ...................
415 heavyiron 1168
	mov   esi,[TASK_COUNT]
1169
	inc   esi
1 ha 1170
 
415 heavyiron 1171
;..................................... start 3/4 : modified by vhanla .................
2971 Serge 1172
	cmp [bPressedMouseXY_W],1
1173
	ja  @f
1174
	inc [bPressedMouseXY_W]
1175
	jnc @f
1176
	;mov ax,[MOUSE_X]
1177
	;mov [mx],ax
1178
	;mov ax,[MOUSE_Y]
1179
	;mov [my],ax
1180
	mov eax,dword[MOUSE_X]
1181
	mov dword[mx],eax
1182
      @@:
415 heavyiron 1183
;..................................... end 3/4 : modified by vhanla ...................
1 ha 1184
 
2971 Serge 1185
      cwloop:
1186
	cmp   esi,2
1187
	jb   .exit
105 poddubny 1188
 
2971 Serge 1189
	dec   esi
1190
	movzx edi, word [WIN_POS + esi * 2] ; ebx
415 heavyiron 1191
	shl   edi, 5
1192
	add   edi, window_data
2971 Serge 1193
;        mov   edi, ebx
1194
    mov   ecx, [edi + WDATA.box.left]
1195
    mov   edx, [edi + WDATA.box.top]
1 ha 1196
 
2971 Serge 1197
	mov   eax,ecx
1198
	mov   ebx,edx
1199
	test	[edi+WDATA.fl_wstate],WSTATE_MINIMIZED
1200
	jnz	cwloop
1 ha 1201
 
2971 Serge 1202
;..................................... start 4/4 : modified by vhanla .................
1203
       movzx  eax, word [mx]; movzx eax,word[MOUSE_X]
1204
       movzx  ebx, word [my]; movzx ebx,word[MOUSE_Y]
1205
;..................................... endt 4/4 : modified by vhanla ..................
1206
	cmp   ecx, eax
1207
	jae   cwloop
1208
	cmp   edx, ebx
1209
	jae   cwloop
1210
    add   ecx, [edi + WDATA.box.width]
1211
    add   edx, [edi + WDATA.box.height]
1212
	cmp   eax, ecx
1213
	jae   cwloop
1214
	cmp   ebx, edx
1215
	jae   cwloop
1216
 
415 heavyiron 1217
	pushad
2971 Serge 1218
    mov   eax, esi
415 heavyiron 1219
	mov   ebx, [TASK_COUNT]
1220
	cmp   eax, ebx	    ; is this window active?
1221
	jz    .move_resize_window
1 ha 1222
 
2971 Serge 1223
	cmp   [bPressedMouseXY_W], 1
1224
	ja    .exit_popa
1225
 
415 heavyiron 1226
	; eax = position in windowing stack
1227
	; redraw must ?
1228
	lea   esi, [WIN_POS + esi * 2]
1229
	call  waredraw
2971 Serge 1230
.exit_popa:
415 heavyiron 1231
	add   esp, 32
1 ha 1232
 
996 serge 1233
.exit:
415 heavyiron 1234
	popad
1235
	ret
1 ha 1236
 
996 serge 1237
.move_resize_window:    ; MOVE OR RESIZE WINDOW
415 heavyiron 1238
	popad
1 ha 1239
 
415 heavyiron 1240
	; Check for user enabled fixed window
117 mario79 1241
    mov   edx, [edi + WDATA.cl_titlebar]
415 heavyiron 1242
	and   edx, 0x0f000000
1243
	cmp   edx, 0x01000000
1244
	jne   .window_move_enabled_for_user
1245
	popad
1246
	ret
996 serge 1247
.window_move_enabled_for_user:
1 ha 1248
 
117 mario79 1249
    test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
415 heavyiron 1250
	jnz	.no_resize_2
41 mikedld 1251
 
415 heavyiron 1252
	mov   [do_resize_from_corner],byte 0   ; resize for skinned window
117 mario79 1253
    mov   edx, [edi + WDATA.cl_workarea]
415 heavyiron 1254
	and   edx, 0x0f000000
549 spraid 1255
	cmp   edx, 0x00000000						;{test for resized}
1256
	je    .no_resize_2
1257
	cmp   edx, 0x01000000						;{test for resized}
1258
	je    .no_resize_2
753 serge 1259
	cmp   edx, 0x04000000						;{test for resized}
549 spraid 1260
	je    .no_resize_2
1261
;	jb    .no_resize_2 ; not type 2 wnd
1 ha 1262
 
117 mario79 1263
    mov   edx, [edi + WDATA.box.top]
1264
    add   edx, [edi + WDATA.box.height]
415 heavyiron 1265
	sub   edx, 6	   ; edx = y_end - 6
1266
	cmp   ebx, edx	   ; ebx = mouse_y
1267
	jb    .no_resize_2
1268
	mov   [do_resize_from_corner],byte 1
1269
	jmp   .continue
1 ha 1270
      .no_resize_2:
1271
 
415 heavyiron 1272
	push	eax
1273
	call	get_titlebar_height
117 mario79 1274
    add     eax,[edi + WDATA.box.top]
415 heavyiron 1275
	cmp	ebx,eax
1276
	pop	eax
1277
	jae	.exit
1 ha 1278
 
1279
     .continue:
1280
 
2971 Serge 1281
;	push  esi
1282
;	mov   esi, window_moving
1283
;	call  sys_msg_board_str
1284
;	pop   esi
1 ha 1285
 
415 heavyiron 1286
	mov   ecx, [timer_ticks]     ; double-click ?
1287
	mov   edx, ecx
1288
	sub   edx, [latest_window_touch]
1289
	mov   [latest_window_touch], ecx
1290
	mov   [latest_window_touch_delta], edx
1 ha 1291
 
928 serge 1292
    mov   cl, byte  [btn_down]     ; save for shade check
415 heavyiron 1293
	mov   [do_resize], cl
1 ha 1294
     no_emulation_righ_button:
117 mario79 1295
    mov   ecx, [edi + WDATA.box.left]
1296
    mov   edx, [edi + WDATA.box.top]
1 ha 1297
 
415 heavyiron 1298
	push  eax ecx edx
1299
	mov   [dlx], ecx      ; save for drawlimits
1300
	mov   [dly], edx
117 mario79 1301
    mov   eax, [edi + WDATA.box.width]
415 heavyiron 1302
	add   ecx, eax
117 mario79 1303
    mov   eax, [edi + WDATA.box.height]
415 heavyiron 1304
	add   edx, eax
1305
	mov   [dlxe], ecx
1306
	mov   [dlye], edx
1307
	pop   edx ecx eax
1 ha 1308
 
415 heavyiron 1309
	sub   eax, ecx
1310
	sub   ebx, edx
1 ha 1311
 
928 serge 1312
    mov   esi, dword [MOUSE_X]
415 heavyiron 1313
	mov   [WIN_TEMP_XY], esi
1 ha 1314
 
415 heavyiron 1315
	pushad		 ; wait for putimages to finish
684 diamond 1316
;        mov   ebx,5
1 ha 1317
;        call  delay_hs
117 mario79 1318
    mov   eax,[edi + WDATA.box.left]
415 heavyiron 1319
	mov   [npx],eax
117 mario79 1320
    mov   eax,[edi + WDATA.box.top]
415 heavyiron 1321
	mov   [npy],eax
1322
	popad
1 ha 1323
 
415 heavyiron 1324
	push eax		  ; save old coordinates
117 mario79 1325
    mov   ax, word [edi + WDATA.box.left]
415 heavyiron 1326
	mov   word [oldc+BOX.left],ax
117 mario79 1327
    mov   ax, word [edi + WDATA.box.top]
415 heavyiron 1328
	mov   word [oldc+BOX.top],ax
117 mario79 1329
    mov   ax, word [edi + WDATA.box.width]
415 heavyiron 1330
	mov   word [oldc+BOX.width],ax
1331
	mov   word [npxe],ax
117 mario79 1332
    mov   ax, word [edi + WDATA.box.height]
415 heavyiron 1333
	mov   word [oldc+BOX.height],ax
1334
	mov   word [npye],ax
1335
	pop eax
1 ha 1336
 
415 heavyiron 1337
	call  drawwindowframes
1 ha 1338
 
415 heavyiron 1339
	mov   [reposition],0
2971 Serge 1340
	mov   [MOUSE_DOWN],byte 1   ; no reaction to mouse up/down
1 ha 1341
 
415 heavyiron 1342
	; move window
1 ha 1343
 
996 serge 1344
newchm:
1 ha 1345
 
415 heavyiron 1346
	call  checkidle
1 ha 1347
 
415 heavyiron 1348
	call  checkVga_N13
1 ha 1349
 
2971 Serge 1350
	mov   [MOUSE_BACKGROUND],byte 0
1 ha 1351
 
415 heavyiron 1352
	call  [draw_pointer]
1 ha 1353
 
415 heavyiron 1354
	pushad
1355
	call   stack_handler
1356
	popad
1 ha 1357
 
415 heavyiron 1358
	mov   esi,[WIN_TEMP_XY]
2971 Serge 1359
	cmp   esi,[MOUSE_X]
415 heavyiron 1360
	je    cwb
1 ha 1361
 
415 heavyiron 1362
	mov   cx,[MOUSE_X]
1363
	mov   dx,[MOUSE_Y]
1364
	sub   cx,ax
1365
	sub   dx,bx
1 ha 1366
 
415 heavyiron 1367
	push  ax
1368
	push  bx
1 ha 1369
 
415 heavyiron 1370
	call  drawwindowframes
1 ha 1371
 
928 serge 1372
        mov   ax, word [Screen_Max_X]
1373
        mov   bx, word [Screen_Max_Y]
1 ha 1374
 
415 heavyiron 1375
	cmp   [do_resize_from_corner],1
1376
	je    no_new_position
1 ha 1377
 
415 heavyiron 1378
	mov   word [npx],word 0     ; x repos ?
1379
	cmp   ax,cx
1380
	jb    noreposx
1381
	mov   [reposition],1
1382
	sub   ax,word [npxe]
1383
	mov   word [npx],ax
1384
	cmp   ax,cx
1385
	jb    noreposx
1386
	mov   word [npx],cx
1 ha 1387
      noreposx:
1388
 
415 heavyiron 1389
	mov   word [npy],word 0     ; y repos ?
1390
	cmp   bx,dx
1391
	jb    noreposy
1392
	mov   [reposition],1
1393
	sub   bx,word [npye]
1394
	mov   word [npy],bx
1395
	cmp   bx,dx
1396
	jb    noreposy
1397
	mov   word [npy],dx
1 ha 1398
      noreposy:
1399
 
1400
      no_new_position:
1401
 
415 heavyiron 1402
	cmp   [do_resize_from_corner],0    ; resize from right corner
1403
	je    norepos_size
1404
	pushad
1 ha 1405
 
996 serge 1406
    mov   edx, edi
1407
    sub   edx, window_data
415 heavyiron 1408
	;shr   edx,5
1409
	;shl   edx,8
1410
	;add   edx,0x80000                 ; process base at 0x80000+
380 serge 1411
    lea   edx, [SLOT_BASE + edx*8]
1 ha 1412
 
415 heavyiron 1413
	movzx eax,word [MOUSE_X]
117 mario79 1414
    cmp   eax,[edi + WDATA.box.left]
415 heavyiron 1415
	jb    nnepx
117 mario79 1416
    sub   eax,[edi + WDATA.box.left]
415 heavyiron 1417
	cmp   eax,32 ; [edx+0x90+8]
1418
	jge   nnepx2
1419
	mov   eax,32 ; [edx+0x90+8]
1 ha 1420
      nnepx2:
415 heavyiron 1421
	mov   [npxe],eax
1 ha 1422
      nnepx:
1423
 
415 heavyiron 1424
	call	get_rolledup_height
1425
	mov	ebx,eax
1426
	movzx eax,word [MOUSE_Y]
117 mario79 1427
    cmp   eax,[edi + WDATA.box.top]
415 heavyiron 1428
	jb    nnepy
117 mario79 1429
    sub   eax,[edi + WDATA.box.top]
415 heavyiron 1430
	cmp	eax,ebx ; [edx+0x90+12]
1431
	jge	nnepy2
1432
	mov	eax,ebx ; [edx+0x90+12]
1 ha 1433
      nnepy2:
415 heavyiron 1434
	mov   [npye],eax
1 ha 1435
      nnepy:
1436
 
415 heavyiron 1437
	mov   [reposition],1
1 ha 1438
 
415 heavyiron 1439
	popad
2971 Serge 1440
      norepos_size:
1 ha 1441
 
415 heavyiron 1442
	pop   bx
1443
	pop   ax
1444
	call  drawwindowframes
1 ha 1445
 
928 serge 1446
    mov   esi, dword [MOUSE_X]
415 heavyiron 1447
	mov   [WIN_TEMP_XY],esi
1 ha 1448
 
1449
      cwb:
928 serge 1450
    cmp  byte [btn_down], 0
415 heavyiron 1451
	jne   newchm
1452
				     ; new position done
996 serge 1453
    mov cl,0
415 heavyiron 1454
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1455
	jnz	@f
1456
	mov	cl,[reposition]
1457
	call	drawwindowframes
1 ha 1458
 
415 heavyiron 1459
	mov   eax,[npx]
117 mario79 1460
    mov   [edi + WDATA.box.left],eax
415 heavyiron 1461
	mov   eax,[npy]
117 mario79 1462
    mov   [edi + WDATA.box.top],eax
415 heavyiron 1463
	mov   eax,[npxe]
117 mario79 1464
    mov   [edi + WDATA.box.width],eax
415 heavyiron 1465
	mov   eax,[npye]
117 mario79 1466
    mov   [edi + WDATA.box.height],eax
415 heavyiron 1467
	call	set_window_clientbox
1 ha 1468
 
415 heavyiron 1469
    @@: mov	[reposition],cl
41 mikedld 1470
 
415 heavyiron 1471
	cmp   [reposition],1	     ; save new position and size
1472
	jne   no_bounds_save
1473
	push  esi edi ecx
1474
	mov   esi,edi
1475
	mov   ecx,2
1476
	test  [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP or WSTATE_MAXIMIZED
1477
	jnz   @f
1478
	add   ecx,2
996 serge 1479
@@:
1480
    sub   edi,window_data
415 heavyiron 1481
	shr   edi,5
1482
	shl   edi,8
1483
	add   edi,SLOT_BASE+APPDATA.saved_box
1484
	cld
1485
	rep   movsd
1486
	pop   ecx edi esi
52 mikedld 1487
      no_bounds_save:
1 ha 1488
 
415 heavyiron 1489
	pushad				   ; WINDOW SHADE/FULLSCREEN
1 ha 1490
 
549 spraid 1491
	;{doule click not worked for 4 type window}
1492
    mov   edx, [edi + WDATA.cl_workarea]
1493
	and   edx, 0x0f000000
1494
	cmp   edx, 0x00000000
1495
	je    no_fullscreen_restore
1496
	cmp   edx, 0x01000000
1497
	je    no_fullscreen_restore
1498
 
415 heavyiron 1499
	cmp   [reposition],1
1500
	je    no_window_sizing
1501
	mov   edx,edi
1502
	sub   edx,window_data
1503
	shr   edx,5
1504
	shl   edx,8
1505
	add   edx,SLOT_BASE		    ; process base at 0x80000+
1 ha 1506
 
415 heavyiron 1507
	cmp   [do_resize],2		  ; window shade ?
1508
	jne   no_window_shade
1509
	mov   [reposition],1
1 ha 1510
 
415 heavyiron 1511
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1512
	jnz	wnd_rolldown
41 mikedld 1513
  wnd_rollup:
415 heavyiron 1514
	or	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1515
	call	get_rolledup_height
1516
	jmp	@f
41 mikedld 1517
  wnd_rolldown:
415 heavyiron 1518
	and	[edi+WDATA.fl_wstate],not WSTATE_ROLLEDUP
117 mario79 1519
    mov     eax,[edx + APPDATA.saved_box.height] ; 0x90+BOX.height
415 heavyiron 1520
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1521
	jz	@f
1522
	mov	eax,[screen_workarea.bottom]
1523
	sub	eax,[screen_workarea.top]
1524
    @@: mov	[edi+WDATA.box.height],eax
679 diamond 1525
        add     eax, [edi+WDATA.box.top]
753 serge 1526
        cmp     eax, [Screen_Max_Y]
679 diamond 1527
        jbe     @f
753 serge 1528
        mov     eax, [Screen_Max_Y]
679 diamond 1529
        sub     eax, [edi+WDATA.box.height]
1530
        mov     [edi+WDATA.box.top], eax
1531
    @@: call    check_window_position
415 heavyiron 1532
	call	set_window_clientbox
1 ha 1533
 
996 serge 1534
no_window_shade:
1 ha 1535
 
599 spraid 1536
	push edx
1537
	mov   edx, [edi + WDATA.cl_workarea]
1538
	and   edx, 0x0f000000
1539
	cmp   edx, 0x04000000
1540
	pop edx
1541
	je    no_fullscreen_restore
1542
 
415 heavyiron 1543
	cmp   [do_resize],1		  ; fullscreen/restore ?
1544
	jne   no_fullscreen_restore
1545
	cmp   [latest_window_touch_delta],dword 50
1546
	jg    no_fullscreen_restore
1547
	mov   [reposition],1
1548
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1549
	jnz	restore_from_fullscreen
1550
	or	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1551
	mov	eax,[screen_workarea.left]
1552
	mov	[edi+WDATA.box.left],eax
1553
	sub	eax,[screen_workarea.right]
1554
	neg	eax
1555
	mov	[edi+WDATA.box.width],eax
1556
	mov	eax,[screen_workarea.top]
1557
	mov	[edi+WDATA.box.top],eax
1558
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1559
	jnz	@f
1560
	sub	eax,[screen_workarea.bottom]
1561
	neg	eax
1562
	mov	[edi+WDATA.box.height],eax
41 mikedld 1563
    @@:
415 heavyiron 1564
	jmp	restore_from_fullscreen.clientbox
1 ha 1565
      restore_from_fullscreen:
415 heavyiron 1566
	and	[edi+WDATA.fl_wstate],not WSTATE_MAXIMIZED
1567
	push	[edi+WDATA.box.height]
1568
	push  edi			  ; restore
1569
	lea   esi, [edx + APPDATA.saved_box]
1570
	mov   ecx,4
1571
	cld
1572
	rep   movsd
1573
	pop   edi
1574
	pop	eax
1575
	test	[edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
1576
	jz	@f
1577
	mov	[edi+WDATA.box.height],eax
41 mikedld 1578
    @@:
150 diamond 1579
    .clientbox:
415 heavyiron 1580
	call	set_window_clientbox
1 ha 1581
 
1582
      no_fullscreen_restore:
1583
 
415 heavyiron 1584
	mov   eax,[edi+WDATA.box.top]		      ; check Y inside screen
1585
	add   eax,[edi+WDATA.box.height]
753 serge 1586
        cmp   eax,[Screen_Max_Y]
415 heavyiron 1587
	jbe   no_window_sizing
1588
	mov   eax,[edi+WDATA.box.left]		       ; check X inside screen
1589
	add   eax,[edi+WDATA.box.width]
753 serge 1590
        cmp   eax,[Screen_Max_X]
415 heavyiron 1591
	jbe   no_window_sizing
753 serge 1592
        mov   eax,[Screen_Max_X]
415 heavyiron 1593
	sub   eax,[edi+WDATA.box.width]
1594
	mov   [edi+WDATA.box.left],eax
753 serge 1595
        mov   eax,[Screen_Max_Y]
415 heavyiron 1596
	sub   eax,[edi+WDATA.box.height]
1597
	mov   [edi+WDATA.box.top],eax
1598
	call  set_window_clientbox
996 serge 1599
no_window_sizing:
1 ha 1600
 
415 heavyiron 1601
	popad
1 ha 1602
 
415 heavyiron 1603
	cmp   [reposition],0
1604
	je    retwm
1 ha 1605
 
415 heavyiron 1606
	push  eax ebx ecx edx
1607
	mov   eax,[edi+WDATA.box.left]
1608
	mov   ebx,[edi+WDATA.box.top]
1609
	mov   ecx,[edi+WDATA.box.width]
1610
	mov   edx,[edi+WDATA.box.height]
1611
	add   ecx,eax
1612
	add   edx,ebx
1613
	call  calculatescreen
112 poddubny 1614
 
415 heavyiron 1615
	mov   eax,[oldc+BOX.left]
1616
	mov   ebx,[oldc+BOX.top]
1617
	mov   ecx,[oldc+BOX.width]
1618
	mov   edx,[oldc+BOX.height]
1619
	add   ecx,eax
1620
	add   edx,ebx
1621
	call  calculatescreen
1622
	pop   edx ecx ebx eax
1 ha 1623
 
415 heavyiron 1624
	mov   eax,edi
1625
	call  redrawscreen
1 ha 1626
 
112 poddubny 1627
 
415 heavyiron 1628
	mov	[edi+WDATA.fl_redraw],1
112 poddubny 1629
 
415 heavyiron 1630
	mov   ecx,100	      ; wait to avoid mouse residuals
996 serge 1631
waitre2:
1632
    call  checkidle
415 heavyiron 1633
	cmp	[edi+WDATA.fl_redraw],0
1634
	jz    retwm
1635
	loop  waitre2
1 ha 1636
 
996 serge 1637
retwm:
1 ha 1638
 
2971 Serge 1639
;	mov    esi,window_moved
1640
;	call   sys_msg_board_str
1 ha 1641
 
415 heavyiron 1642
	popad
1 ha 1643
 
415 heavyiron 1644
	ret
1 ha 1645
 
1646
 
1647
uglobal
2971 Serge 1648
  add_window_data            dd  0
1 ha 1649
  do_resize_from_corner      db  0x0
2971 Serge 1650
  reposition                 db  0x0
415 heavyiron 1651
  latest_window_touch	     dd  0x0
1 ha 1652
  latest_window_touch_delta  dd  0x0
1653
 
1654
  do_resize db 0x0
1655
 
415 heavyiron 1656
  oldc	  dd 0x0,0x0,0x0,0x0
1 ha 1657
 
415 heavyiron 1658
  dlx	  dd 0x0
1659
  dly	  dd 0x0
1660
  dlxe	  dd 0x0
1661
  dlye	  dd 0x0
1 ha 1662
 
415 heavyiron 1663
  npx	  dd 0x0
1664
  npy	  dd 0x0
1665
  npxe	  dd 0x0
1666
  npye	  dd 0x0
1 ha 1667
 
415 heavyiron 1668
  mpx	  dd 0x0
1669
  mpy	  dd 0x0
1 ha 1670
endg
1671
 
1672
 
1673
; draw negative window frames
186 diamond 1674
drawwindowframes2:
415 heavyiron 1675
	pushad
1676
	cli
1677
	jmp	drawwindowframes.do
1 ha 1678
drawwindowframes:
415 heavyiron 1679
	pushad
1680
	cli
1 ha 1681
 
415 heavyiron 1682
	test	[edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
1683
	jnz	.ret
1684
	mov	eax, [npx]
1685
	cmp	eax, [edi+WDATA.box.left]
1686
	jnz	.nowndframe
1687
	mov	eax, [npxe]
1688
	cmp	eax, [edi+WDATA.box.width]
1689
	jnz	.nowndframe
1690
	mov	eax, [npy]
1691
	cmp	eax, [edi+WDATA.box.top]
1692
	jnz	.nowndframe
1693
	mov	eax, [npye]
1694
	cmp	eax, [edi+WDATA.box.height]
1695
	jnz	.nowndframe
1696
	xor	[edi+WDATA.fl_wdrawn], 2
1697
	test	[edi+WDATA.fl_wdrawn], 4
1698
	jnz	.ret
163 diamond 1699
 
186 diamond 1700
.nowndframe:
1701
.do:
415 heavyiron 1702
	mov	edi, 1
1703
	mov	ecx, 0x01000000
1704
	mov   eax,[npx]
1705
	shl   eax,16
1706
	add   eax,[npx]
1707
	add   eax,[npxe]
1708
	add   eax,65536*1-1
1709
	mov   ebx,[npy]
1710
	shl   ebx,16
1711
	add   ebx,[npy]
1712
	call  [draw_line]
1 ha 1713
 
415 heavyiron 1714
	mov   eax,[npx]
1715
	shl   eax,16
1716
	add   eax,[npx]
1717
	add   eax,[npxe]
1718
	add   eax,65536*1-1
1719
	mov   ebx,[npy]
1720
	add   ebx,[npye]
1721
	shl   ebx,16
1722
	add   ebx,[npy]
1723
	add   ebx,[npye]
1724
	call  [draw_line]
1 ha 1725
 
415 heavyiron 1726
	mov   eax,[npx]
1727
	shl   eax,16
1728
	add   eax,[npx]
1729
	mov   ebx,[npy]
1730
	shl   ebx,16
1731
	add   ebx,[npy]
1732
	add   ebx,[npye]
1733
	call  [draw_line]
1 ha 1734
 
415 heavyiron 1735
	mov   eax,[npx]
1736
	add   eax,[npxe]
1737
	shl   eax,16
1738
	add   eax,[npx]
1739
	add   eax,[npxe]
1740
	mov   ebx,[npy]
1741
	shl   ebx,16
1742
	add   ebx,[npy]
1743
	add   ebx,[npye]
1744
	call  [draw_line]
1 ha 1745
 
186 diamond 1746
.ret:
415 heavyiron 1747
	sti
1748
	popad
1749
	ret
1 ha 1750
 
1751
 
1752
 
1753
random_shaped_window:
1754
 
1755
;
1756
;  eax = 0    giving address of data area
1757
;      ebx    address
115 poddubny 1758
;  eax = 1    shape area scale
1 ha 1759
;      ebx    2^ebx scale
1760
 
1761
     test eax, eax
1762
     jne  rsw_no_address
465 serge 1763
     mov  eax,[current_slot]
1764
     mov  [eax+APPDATA.wnd_shape],ebx
1765
rsw_no_address:
1 ha 1766
 
1767
     cmp  eax,1
1768
     jne  rsw_no_scale
465 serge 1769
     mov  eax,[current_slot]
1770
     mov  byte [eax+APPDATA.wnd_shape_scale], bl
1771
rsw_no_scale:
1 ha 1772
 
1773
     ret
1774
 
1775
 
2971 Serge 1776
;ebx x
1777
;eax y
1778
;ecx width
1779
;edx height
1780
;esi slot
1781
 
1782
align 4
1783
_set_screen:
1784
        push edx
1785
        add   ebx, [_display_data]
1786
        mul   [_screen_width]
1787
        lea   ebx, [eax+ebx]
1788
 
1789
        mov eax, esi
1790
        mov ah, al
1791
        mov esi, eax
1792
        shl eax, 16
1793
        or eax, esi
1794
 
1795
        pop edx
1796
        mov esi, ecx
1797
.row:
1798
 
1799
        mov edi, ebx
1800
        add ebx, [_screen_width]
1801
 
1802
        mov ecx, esi
1803
 
1804
        dec edx
1805
        js .done
1806
.16:
1807
        cmp ecx, 16
1808
        jb .8
1809
 
1810
        mov [edi],   eax
1811
        mov [edi+4], eax
1812
        mov [edi+8], eax
1813
        mov [edi+12], eax
1814
        add edi, 16
1815
        sub ecx, 16
1816
        jmp .16
1817
.8:
1818
        shr ecx, 2
1819
        rep stosd
1820
        mov ecx, esi
1821
        and ecx, 3
1822
        rep stosb
1823
        jmp .row
1824
.done:
1825
        ret
1826
 
1827
;[esp+4]    ebp
1828
;[esp+8]    x
1829
;[esp+12]   y
1830
;[esp+16]   w
1831
;[esp+20]   h
1832
;[esp+24]   color
1833
 
1834
;ebx      disp data
1835
;edx      dest
1836
 
1837
public _int_draw_bar
1838
align 4
1839
_int_draw_bar:
1840
 
1841
        lea ecx, [esp+4]
1842
        call lock_cursor
1843
 
1844
        sub esp, 4
1845
        mov [esp], ebp
1846
 
1847
        mov ebx, [esp+8]
1848
        mov eax, [esp+12]
1849
        mul [_screen_width]
1850
        add ebx, [_display_data]
1851
        lea ebx, [eax+ebx]
1852
 
1853
        mov edi, [esp+8]
1854
        mov eax, [esp+12]
1855
        mul [BytesPerScanLine]
1856
 
1857
        cmp byte [ScreenBPP], 24
1858
        je  .24
1859
 
1860
        lea ecx, [LFB_BASE+eax+edi*4]
1861
 
1862
        mov eax, [esp+24]
1863
        mov edx, [CURRENT_TASK]
1864
.row32:
1865
        mov edi, ecx
1866
        mov esi, ebx
1867
 
1868
        add ecx, [BytesPerScanLine]
1869
        add ebx, [_screen_width]
1870
 
1871
        dec dword [esp+20]
1872
        js .done
1873
 
1874
        mov ebp, [esp+16]
1875
 
1876
align 16
1877
.draw32:
1878
        cmp dl, byte [esi]
1879
        jne @f
1880
 
1881
        stosd
1882
@@:
1883
        inc esi
1884
        dec ebp
1885
        jnz .draw32
1886
        jmp .row32
1887
.done:
1888
        call unlock_cursor
1889
 
1890
        mov ebp, [esp]
1891
        add esp, 4
1892
        ret
1893
 
1894
.24:
1895
        lea ecx, [LFB_BASE+edi*3]
1896
        add ecx, eax
1897
 
1898
        mov eax, [esp+24]
1899
        mov edx, eax
1900
        shr edx, 8
1901
        mov dl, [CURRENT_TASK]
1902
.row24:
1903
        mov edi, ecx
1904
        mov esi, ebx
1905
 
1906
        add ecx, [BytesPerScanLine]
1907
        add ebx, [_screen_width]
1908
 
1909
        dec dword [esp+20]
1910
        js .done
1911
 
1912
        mov ebp, [esp+16]
1913
 
1914
align 16
1915
.draw24:
1916
        cmp dl, byte [esi]
1917
        jne @f
1918
 
1919
        mov [edi], ax
1920
        mov [edi+2], dh
1921
@@:
1922
        add edi, 3
1923
        inc esi
1924
        dec ebp
1925
        jnz .draw24
1926
        jmp .row24
1927
 
1928
 
1929
 
1930
;[esp+4]    x
1931
;[esp+8]    y
1932
;[esp+12]   w
1933
;[esp+16]   color
1934
 
1935
;esi      disp data
1936
;edi      dest
1937
 
1938
 
1939
public _int_hline
1940
align 4
1941
_int_hline:
1942
 
1943
           mov esi, [esp+4]
1944
           mov eax, [esp+8]
1945
           mov ecx, [esp+12]
1946
 
1947
           mul [_screen_width]
1948
           add esi, [_display_data]
1949
           add esi, eax
1950
 
1951
           mov edi, [esp+4]
1952
           mov eax, [esp+8]
1953
           mul [BytesPerScanLine]
1954
 
1955
           cmp byte [ScreenBPP], 24
1956
           je  .24
1957
 
1958
           lea edi, [LFB_BASE+eax+edi*4]
1959
 
1960
           mov eax, [esp+16]
1961
 
1962
.32_kernel:
1963
           mov edx, [CURRENT_TASK]
1964
 
1965
align 16
1966
.draw32:
1967
           cmp dl, byte [esi]
1968
           jne @f
1969
 
1970
           stosd
1971
@@:
1972
           inc esi
1973
           dec ecx
1974
           jnz .draw32
1975
 
1976
           ret
1977
.24:
1978
           lea edi, [LFB_BASE+edi*3]
1979
           add edi, eax
1980
 
1981
           mov eax, [esp+16]
1982
 
1983
.24_kernel:
1984
           mov edx, eax
1985
           shr edx, 8
1986
           mov dl, [CURRENT_TASK]
1987
 
1988
align 16
1989
.draw24:
1990
           cmp dl, byte [esi]
1991
           jne @f
1992
 
1993
           mov [edi], ax
1994
           mov [edi+2], dh
1995
@@:
1996
           add edi, 3
1997
           inc esi
1998
           dec ecx
1999
           jnz .draw24
2000
 
2001
           ret
2002
 
2003
 
2004
;[esp+4]    x
2005
;[esp+8]    y
2006
;[esp+12]   h
2007
;[esp+16]   color
2008
 
2009
;esi      disp data
2010
;edi      dest
2011
 
2012
public _int_vline
2013
align 4
2014
_int_vline:
2015
 
2016
           mov esi, [esp+4]
2017
           mov eax, [esp+8]
2018
           mov ecx, [esp+12]
2019
 
2020
           mul [_screen_width]
2021
           add esi, [_display_data]
2022
           add esi, eax
2023
 
2024
           mov edi, [esp+4]
2025
           mov eax, [esp+8]
2026
           mul [BytesPerScanLine]
2027
 
2028
           cmp byte [ScreenBPP], 24
2029
           je  .24
2030
 
2031
           lea edi, [LFB_BASE+eax+edi*4]
2032
 
2033
           mov eax, [esp+16]
2034
 
2035
.32_kernel:
2036
           mov edx, [CURRENT_TASK]
2037
 
2038
align 16
2039
.draw32:
2040
           cmp dl, byte [esi]
2041
           jne @f
2042
 
2043
           mov [edi], eax
2044
@@:
2045
           add esi, [_screen_width]
2046
           add edi, [BytesPerScanLine]
2047
           dec ecx
2048
           jnz .draw32
2049
 
2050
           ret
2051
.24:
2052
           lea edi, [LFB_BASE+edi*3]
2053
           add edi, eax
2054
 
2055
           mov eax, [esp+16]
2056
 
2057
.24_kernel:
2058
           mov edx, eax
2059
           shr edx, 8
2060
           mov dl, [CURRENT_TASK]
2061
 
2062
align 16
2063
.draw24:
2064
           cmp dl, byte [esi]
2065
           jne @f
2066
 
2067
           mov [edi], ax
2068
           mov [edi+2], dh
2069
@@:
2070
           add esi, [_screen_width]
2071
           add edi, [BytesPerScanLine]
2072
           dec ecx
2073
           jnz .draw24
2074
 
2075
           ret
2076
 
2077
;[esp]      dst
2078
;[esp+4]    mask
2079
 
2080
;[esp+12]   x
2081
;[esp+16]   y
2082
;[esp+20]   w
2083
;[esp+24]   h
2084
;[esp+32]   color
2085
 
2086
public _int_rectangle
2087
align 4
2088
_int_rectangle:
2089
 
2090
.dst       equ (esp)
2091
.mask      equ (esp+4)
2092
 
2093
.x         equ (esp+12)
2094
.y         equ (esp+16)
2095
.w         equ (esp+20)
2096
.h         equ (esp+24)
2097
.color     equ (esp+28)
2098
 
2099
           sub esp, 8
2100
 
2101
           mov esi, [.x]
2102
           mov eax, [.y]
2103
           mul [_screen_width]
2104
           add esi, [_display_data]
2105
           add esi, eax
2106
           mov [.mask], esi
2107
 
2108
           mov edi, [.x]
2109
           mov eax, [.y]
2110
           mul [BytesPerScanLine]
2111
 
2112
           cmp byte [ScreenBPP], 24
2113
           je  .24
2114
 
2115
           lea edi, [LFB_BASE+eax+edi*4]
2116
 
2117
           mov [.dst],  edi
2118
 
2119
           mov ecx, [.w]
2120
           mov eax, [.color]
2121
           call _int_hline.32_kernel
2122
 
2123
           sub edi, 4
2124
           dec esi
2125
 
2126
           mov ecx, [.h]
2127
           call _int_vline.32_kernel
2128
 
2129
           mov edi, [.dst]
2130
           mov esi, [.mask]
2131
           mov ecx, [.h]
2132
           call _int_vline.32_kernel
2133
 
2134
           mov ecx, [.w]
2135
           sub esi, [_screen_width]
2136
           sub edi, [BytesPerScanLine]
2137
           call _int_hline.32_kernel
2138
 
2139
           add esp, 8
2140
           ret
2141
.24:
2142
           lea edi, [LFB_BASE+edi*3]
2143
           add edi, eax
2144
 
2145
           mov [.dst],  edi
2146
 
2147
           mov ecx, [.w]
2148
           mov eax, [.color]
2149
           call _int_hline.24_kernel
2150
 
2151
           sub edi, 3
2152
           dec esi
2153
 
2154
           mov ecx, [.h]
2155
           call _int_vline.24_kernel
2156
 
2157
           mov edi, [.dst]
2158
           mov esi, [.mask]
2159
           mov ecx, [.h]
2160
           call _int_vline.24_kernel
2161
 
2162
           mov ecx, [.w]
2163
           sub esi, [_screen_width]
2164
           sub edi, [BytesPerScanLine]
2165
           call _int_hline.24_kernel
2166
 
2167
restore   .dst
2168
restore   .mask
2169
 
2170
restore   .x
2171
restore   .y
2172
restore   .w
2173
restore   .h
2174
restore   .color
2175
 
2176
           add esp, 8
2177
           ret