Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
5153 IgorA 1
;
2
; Z buffer
3
;
4
 
5
include 'zfeatures.inc'
6
 
7
ZB_Z_BITS equ 16
8
 
9
ZB_POINT_Z_FRAC_BITS equ 14
10
 
6243 IgorA 11
ZB_POINT_TEXEL_SIZE equ 12 ;точность множителя для вычисления координат текселя
12
	;влияет на максимальный размер текстуры
5153 IgorA 13
 
5213 IgorA 14
ZB_POINT_RED_MIN equ (1 shl 8)
15
ZB_POINT_RED_MAX equ ( (1 shl 16)-1 )
16
ZB_POINT_GREEN_MIN equ (1 shl 8)
17
ZB_POINT_GREEN_MAX equ ( (1 shl 16)-1 )
18
ZB_POINT_BLUE_MIN equ (1 shl 8)
19
ZB_POINT_BLUE_MAX equ ( (1 shl 16)-1 )
5153 IgorA 20
 
21
; display modes
22
ZB_MODE_5R6G5B equ 1  ; true color 16 bits
23
ZB_MODE_INDEX  equ 2  ; color index 8 bits
24
ZB_MODE_RGBA   equ 3  ; 32 bit rgba mode
25
ZB_MODE_RGB24  equ 4  ; 24 bit rgb mode
26
ZB_NB_COLORS   equ 225 ; number of colors for 8 bit display
27
 
6243 IgorA 28
if TGL_FEATURE_RENDER_BITS eq 24
5153 IgorA 29
 
30
macro RGB_TO_PIXEL r,g,b
31
{
32
	mov eax,b
33
	shr eax,8
34
	push eax
35
		mov eax,g
36
		and eax,0xff00
37
		or dword[esp],eax
38
		mov eax,r
39
		shl eax,8
40
		or dword[esp],eax
41
	pop eax
42
}
43
 
44
;typedef unsigned char PIXEL;
45
PSZB equ 3
46
PSZSH equ 5
47
 
48
else if TGL_FEATURE_RENDER_BITS eq 32
49
 
50
;#define RGB_TO_PIXEL(r,g,b) \
51
;  ((((r) << 8) & 0xff0000) | ((g) & 0xff00) | ((b) >> 8))
52
;typedef unsigned int PIXEL;
53
;PSZB equ 4
54
;PSZSH equ 5
55
 
56
else
57
 
58
;#error Incorrect number of bits per pixel
59
 
60
end if
61
 
62
struct ZBuffer
63
	xsize dd ? ;int
64
	ysize dd ? ;int
65
	linesize dd ? ;int ;line size, in bytes
8069 IgorA 66
		dd ? ;fix old error offset
5153 IgorA 67
	mode dd ? ;int
68
 
69
	zbuf dd ? ;*unsigned short
70
	pbuf dd ? ;*PIXEL
71
	frame_buffer_allocated dd ? ;int
72
 
73
	nb_colors dd ? ;int
74
	dctable dd ? ;*unsigned char
75
	ctable dd ? ;*int
76
	current_texture dd ? ;*PIXEL
6243 IgorA 77
	s_log2 dd ? ;unsigned int
78
	s_bound dd ? ;unsigned int
79
	t_bound dd ? ;unsigned int
5153 IgorA 80
ends
81
 
82
struct ZBufferPoint
83
	x dd ? ;int ;integer coordinates in the zbuffer
84
	y dd ? ;int
85
	z dd ? ;int
86
	s dd ? ;int ;coordinates for the mapping
87
	t dd ? ;int
88
	r dd ? ;int ;color indexes
89
	g dd ? ;int
90
	b dd ? ;int
91
 
92
	fsz dd ? ;float ;temporary coordinates for mapping
93
	tz dd ? ;float
94
ends
95
 
96
; ztriangle.c
97
 
98
;
99
; Memory allocator for TinyGL
100
;
101
 
102
; modify these functions so that they suit your needs
103
 
104
align 4
5218 IgorA 105
proc gl_free uses eax ebx ecx, mptr:dword
5153 IgorA 106
	mov ecx,[mptr]
107
	or ecx,ecx
108
	jz @f
5218 IgorA 109
		mcall 68, 13
110
	@@:
5153 IgorA 111
	ret
112
endp
113
 
114
;description:
115
; выделение памяти
116
align 4
117
proc gl_malloc uses ebx ecx, size:dword
118
	mcall 68, 12, [size]
119
	ret
120
endp
121
 
122
;description:
123
; выделение очищеной памяти
124
align 4
125
proc gl_zalloc uses ebx ecx edi, size:dword
126
	mov ecx,[size]
127
	stdcall gl_malloc,ecx
5218 IgorA 128
	or eax,eax
129
	jz @f
5153 IgorA 130
		mov ebx,eax
131
		mov edi,eax
132
		xor eax,eax
133
		shr ecx,2
134
		rep stosd ;очистка памяти (пишем везде 0)
135
		mov eax,ebx
136
	@@:
137
	ret
138
endp