Subversion Repositories Kolibri OS

Rev

Rev 6172 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6172 Rev 8069
Line 18... Line 18...
18
		jmp .end_f
18
		jmp .end_f
19
	@@:
19
	@@:
20
	mov edi,eax
20
	mov edi,eax
Line 21... Line 21...
21
 
21
 
22
	mov eax,[ysize]
22
	mov eax,[ysize]
23
	mov [edi+offs_zbuf_ysize],eax
23
	mov [edi+ZBuffer.ysize],eax
24
	mov eax,[xsize]
24
	mov eax,[xsize]
25
	mov [edi+offs_zbuf_xsize],eax
25
	mov [edi+ZBuffer.xsize],eax
26
	imul eax,PSZB
-
 
27
	add eax,3
-
 
28
	and eax,not 3
26
	imul eax,PSZB
29
	mov [edi+offs_zbuf_linesize],eax
27
	mov [edi+ZBuffer.linesize],eax
30
	mov eax,[mode]
28
	mov eax,[mode]
Line 31... Line 29...
31
	mov [edi+offs_zbuf_mode],eax
29
	mov [edi+ZBuffer.mode],eax
32
 
30
 
33
if TGL_FEATURE_32_BITS eq 1
31
if TGL_FEATURE_32_BITS eq 1
34
	cmp eax,ZB_MODE_RGBA
32
	cmp eax,ZB_MODE_RGBA
Line 39... Line 37...
39
	je .correct
37
	je .correct
40
end if
38
end if
41
	cmp eax,ZB_MODE_5R6G5B
39
	cmp eax,ZB_MODE_5R6G5B
42
	jne @f
40
	jne @f
43
	.correct:
41
	.correct:
44
		mov dword[edi+offs_zbuf_nb_colors],0
42
		mov dword[edi+ZBuffer.nb_colors],0
45
		jmp .end_s
43
		jmp .end_s
46
	@@: ;default:
44
	@@: ;default:
47
		stdcall dbg_print,f_zb_opn,err_3
45
		stdcall dbg_print,f_zb_opn,err_3
48
		jmp .error
46
		jmp .error
49
	.end_s:
47
	.end_s:
Line 50... Line 48...
50
 
48
 
51
	mov ecx,[edi+offs_zbuf_xsize]
49
	mov ecx,[edi+ZBuffer.xsize]
52
	imul ecx,[edi+offs_zbuf_ysize]
50
	imul ecx,[edi+ZBuffer.ysize]
Line 53... Line 51...
53
	shl ecx,1 ;*= sizeof(unsigned short)
51
	shl ecx,1 ;*= sizeof(unsigned short)
54
 
52
 
55
	stdcall gl_malloc, ecx
53
	stdcall gl_malloc, ecx
56
	mov [edi+offs_zbuf_zbuf],eax
54
	mov [edi+ZBuffer.zbuf],eax
57
	cmp eax,0
55
	cmp eax,0
58
	jne @f
56
	jne @f
59
		stdcall dbg_print,f_zb_opn,err_2
57
		stdcall dbg_print,f_zb_opn,err_2
Line 60... Line 58...
60
		jmp .error
58
		jmp .error
61
	@@:
59
	@@:
Line 62... Line 60...
62
 
60
 
Line 63... Line 61...
63
	mov dword[edi+offs_zbuf_frame_buffer_allocated],0
61
	mov dword[edi+ZBuffer.frame_buffer_allocated],0
64
	mov dword[edi+offs_zbuf_pbuf],0 ;NULL
62
	mov dword[edi+ZBuffer.pbuf],0 ;NULL
65
 
63
 
66
	mov dword[edi+offs_zbuf_current_texture],0 ;NULL
64
	mov dword[edi+ZBuffer.current_texture],0 ;NULL
Line 85... Line 83...
85
 
83
 
86
align 16
84
align 16
87
proc ZB_resize uses eax ebx ecx edi esi, zb:dword, frame_buffer:dword, xsize:dword, ysize:dword
85
proc ZB_resize uses eax ebx ecx edi esi, zb:dword, frame_buffer:dword, xsize:dword, ysize:dword
Line 88... Line -...
88
	mov ebx,[zb]
-
 
89
 
86
	mov ebx,[zb]
90
	; xsize must be a multiple of 4
-
 
91
	mov edi,[xsize]
87
 
Line 92... Line 88...
92
	and edi,not 3
88
	mov edi,[xsize]
93
	mov esi,[ysize]
89
	mov esi,[ysize]
Line 94... Line 90...
94
	
90
	
95
	mov [ebx+offs_zbuf_xsize], edi
91
	mov [ebx+ZBuffer.xsize], edi
96
	mov [ebx+offs_zbuf_ysize], esi
-
 
97
 
-
 
98
	mov eax,edi
92
	mov [ebx+ZBuffer.ysize], esi
Line 99... Line 93...
99
	imul eax,PSZB
93
 
100
	add eax,3
94
	mov eax,edi
101
	and eax,not 3
95
	imul eax,PSZB
Line 102... Line 96...
102
	mov [ebx+offs_zbuf_linesize],eax ;zb.linesize = (xsize * PSZB + 3) & ~3
96
	mov [ebx+ZBuffer.linesize],eax ;zb.linesize = (xsize * PSZB + 3) & ~3
103
 
97
 
104
	mov ecx,edi
98
	mov ecx,edi
Line 105... Line 99...
105
	imul ecx,esi
99
	imul ecx,esi
106
	shl ecx,1 ;*= sizeof(unsigned short)
100
	shl ecx,1 ;*= sizeof(unsigned short)
107
 
101
 
108
	stdcall gl_free,dword[ebx+offs_zbuf_zbuf]
102
	stdcall gl_free,dword[ebx+ZBuffer.zbuf]
Line 109... Line 103...
109
	stdcall gl_malloc,ecx
103
	stdcall gl_malloc,ecx
110
	mov [ebx+offs_zbuf_zbuf],eax
104
	mov [ebx+ZBuffer.zbuf],eax
111
 
105
 
112
	cmp dword[ebx+offs_zbuf_frame_buffer_allocated],0
106
	cmp dword[ebx+ZBuffer.frame_buffer_allocated],0
113
	je @f
107
	je @f
114
		stdcall gl_free,dword[ebx+offs_zbuf_pbuf]
108
		stdcall gl_free,dword[ebx+ZBuffer.pbuf]
115
	@@:
109
	@@:
116
 
110
 
117
	cmp dword[frame_buffer],0
111
	cmp dword[frame_buffer],0
118
	jne .els_0
112
	jne .els_0
119
		inc esi
113
		inc esi
120
		imul esi,dword[ebx+offs_zbuf_linesize]
114
		imul esi,dword[ebx+ZBuffer.linesize]
121
		stdcall gl_malloc,esi
115
		stdcall gl_malloc,esi
122
		mov dword[ebx+offs_zbuf_pbuf],eax
116
		mov dword[ebx+ZBuffer.pbuf],eax
123
		mov dword[ebx+offs_zbuf_frame_buffer_allocated],1
117
		mov dword[ebx+ZBuffer.frame_buffer_allocated],1
Line 124... Line 118...
124
		jmp @f
118
		jmp @f
Line 432... Line 426...
432
	mov edi,[adr]
426
	mov edi,[adr]
433
	rep stosd
427
	rep stosd
434
	ret
428
	ret
435
endp
429
endp
Line -... Line 430...
-
 
430
 
436
 
431
;input:
437
; count must be a multiple of 4 and >= 4
432
; count - число пикселей RGB для закраски
438
;destroy:
433
;destroy:
439
; edi, esi
434
; eax, ecx, edi, esi
440
align 16
435
align 16
441
proc memset_RGB24 uses eax ecx, adr:dword, r:dword, g:dword, b:dword, count:dword
436
proc memset_RGB24, adr:dword, r:dword, g:dword, b:dword, count:dword
442
	mov esi,[adr]
437
	mov esi,[adr]
443
	mov eax,[r] ;копируем в буфер первые 12 байт (минимальное число кратное 3 и 4)
438
	mov eax,[r] ;копируем в буфер первые 12 байт (минимальное число кратное 3 и 4)
444
	mov byte[esi],al
439
	mov byte[esi],al
445
	mov byte[esi+3],al
440
	mov byte[esi+3],al
Line 459... Line 454...
459
	mov ecx,[count]
454
	mov ecx,[count]
460
	shr ecx,2
455
	shr ecx,2
461
	cmp ecx,1
456
	cmp ecx,1
462
	jle .end_f ;если ширина буфера меньше 12 байт, то выходим
457
	jle .end_f ;если ширина буфера меньше 12 байт, то выходим
463
	dec ecx
458
	dec ecx
464
	mov edi,esi
459
	lea edi,[esi+12]
465
	add edi,12
-
 
Line 466... Line 460...
466
 
460
 
467
	mov eax,[esi]
461
	mov eax,[esi]
468
	cmp eax,[esi+4]
462
	cmp eax,[esi+4]
469
	jne @f
463
	jne @f
470
		;если r=g и g=b и b=r
-
 
471
		mov esi,ecx
-
 
472
		shl ecx,2
464
		;если r=g и g=b и b=r
473
		sub ecx,esi ;ecx*=3
465
		lea ecx,[ecx+2*ecx] ;ecx*=3
-
 
466
		rep stosd
-
 
467
		mov ecx,[count]
-
 
468
		and ecx,3
-
 
469
		cmp ecx,0
-
 
470
		je .end_f
-
 
471
		lea ecx,[ecx+2*ecx] ;ecx*=3
474
		rep stosd
472
		rep stosb
475
		jmp .end_f
473
		jmp .end_f
476
align 16
474
align 16
477
	@@: ;если r!=g или g!=b или b!=r
475
	@@: ;если r!=g или g!=b или b!=r
478
		movsd
476
		movsd
479
		movsd
477
		movsd
480
		movsd
478
		movsd
481
		sub esi,12
479
		sub esi,12
-
 
480
	loop @b
-
 
481
		mov ecx,[count]
-
 
482
		and ecx,3
-
 
483
		cmp ecx,0
-
 
484
		je .end_f
-
 
485
		lea ecx,[ecx+2*ecx] ;ecx*=3
482
	loop @b
486
		rep movsb
483
	.end_f:
487
	.end_f:
484
	ret
488
	ret
Line 485... Line 489...
485
endp
489
endp
Line 492... Line 496...
492
;end if
496
;end if
Line 493... Line 497...
493
 
497
 
494
	mov eax,[zb]
498
	mov eax,[zb]
495
	cmp dword[clear_z],0
499
	cmp dword[clear_z],0
496
	je @f
500
	je @f
497
		mov ebx,[eax+offs_zbuf_xsize]
501
		mov ebx,[eax+ZBuffer.xsize]
498
		imul ebx,[eax+offs_zbuf_ysize]
502
		imul ebx,[eax+ZBuffer.ysize]
499
		stdcall memset_s, [eax+offs_zbuf_zbuf],[z],ebx
503
		stdcall memset_s, [eax+ZBuffer.zbuf],[z],ebx
500
	@@:
504
	@@:
501
	cmp dword[clear_color],0
505
	cmp dword[clear_color],0
-
 
506
	je @f
-
 
507
if TGL_FEATURE_RENDER_BITS eq 32
-
 
508
		;color = RGB_TO_PIXEL(r, g, b)
-
 
509
		;memset_l(ebx, color, zb->xsize)
502
	je @f
510
end if
503
if TGL_FEATURE_RENDER_BITS eq 24
511
if TGL_FEATURE_RENDER_BITS eq 24
-
 
512
		mov ebx,[eax+ZBuffer.xsize]
504
		mov ebx,[eax+offs_zbuf_xsize]
513
		imul ebx,[eax+ZBuffer.ysize]
505
		push ebx
514
		push ebx
506
		mov ebx,[b]
515
		mov ebx,[b]
507
		shr ebx,8
516
		shr ebx,8
508
		push ebx
517
		push ebx
509
		mov ebx,[g]
518
		mov ebx,[g]
510
		shr ebx,8
519
		shr ebx,8
511
		push ebx
520
		push ebx
512
		mov ebx,[r]
521
		mov ebx,[r]
513
		shr ebx,8
522
		shr ebx,8
514
		push ebx
-
 
515
		add esp,16
-
 
516
end if
-
 
517
		mov ebx,[eax+offs_zbuf_pbuf]
-
 
518
		mov ecx,[eax+offs_zbuf_ysize]
-
 
519
align 4
-
 
520
		.cycle_0:
-
 
521
if TGL_FEATURE_RENDER_BITS eq 32
-
 
522
			;color = RGB_TO_PIXEL(r, g, b)
-
 
523
			;memset_l(ebx, color, zb->xsize)
-
 
524
end if
-
 
525
if TGL_FEATURE_RENDER_BITS eq 24
-
 
526
			sub esp,16
523
		push ebx
527
			stdcall memset_RGB24,ebx
524
		stdcall memset_RGB24, [eax+ZBuffer.pbuf]
528
end if
-
 
529
			add ebx,[eax+offs_zbuf_linesize]
-
 
530
		loop .cycle_0
525
end if
531
	@@:
526
	@@:
532
	ret
527
	ret