Rev 5175 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5153 | IgorA | 1 | |
2 | |||
3 | |||
4 | { |
||
5 | if TGL_FEATURE_RENDER_BITS eq 24 |
||
6 | mov ecx,[p2] |
||
7 | mov eax,[ecx+offs_zbup_r] |
||
8 | shr eax,8 |
||
9 | mov [colorR],eax ;colorR=p2.r>>8 |
||
10 | mov eax,[ecx+offs_zbup_g] |
||
11 | shr eax,8 |
||
12 | mov [colorG],eax ;colorG=p2.g>>8 |
||
13 | mov eax,[ecx+offs_zbup_b] |
||
14 | shr eax,8 |
||
15 | mov [colorB],eax ;colorB=p2.b>>8 |
||
16 | else |
||
17 | ; color=RGB_TO_PIXEL(p2->r,p2->g,p2->b); |
||
18 | end if |
||
19 | } |
||
20 | |||
21 | |||
22 | { |
||
23 | ; zz=z >> ZB_POINT_Z_FRAC_BITS; |
||
24 | ; if (zz >= pz[_a]) { |
||
25 | if TGL_FEATURE_RENDER_BITS eq 24 |
||
26 | ; pp[3 * _a]=colorR; |
||
27 | ; pp[3 * _a + 1]=colorG; |
||
28 | ; pp[3 * _a + 2]=colorB; |
||
29 | ; pz[_a]=zz; |
||
30 | else |
||
31 | ; pp[_a]=color; |
||
32 | ; pz[_a]=zz; |
||
33 | end if |
||
34 | ; } |
||
35 | ; z+=dzdx; |
||
36 | } |
||
37 | |||
38 | |||
39 | proc ZB_fillTriangleFlat, zb:dword, p0:dword, p1:dword, p2:dword |
||
40 | locals |
||
41 | if TGL_FEATURE_RENDER_BITS eq 24 |
||
42 | colorR db ? |
||
43 | colorG db ? |
||
44 | colorB db ? ;unsigned char |
||
45 | else |
||
46 | color dd ? ;int |
||
47 | end if |
||
48 | include 'ztriangle.inc' |
||
49 | ret |
||
50 | endp |
||
51 | |||
52 | |||
53 | ; Smooth filled triangle. |
||
54 | ; The code below is very tricky :) |
||
55 | ; |
||
56 | |||
57 | |||
58 | INTERP_RGB equ 1 |
||
59 | |||
60 | |||
61 | { |
||
62 | if TGL_FEATURE_RENDER_BITS eq 16 |
||
63 | ; _drgbdx=((drdx / (1<<6)) << 22) & 0xFFC00000; |
||
64 | ; _drgbdx|=(dgdx / (1<<5)) & 0x000007FF; |
||
65 | ; _drgbdx|=((dbdx / (1<<7)) << 12) & 0x001FF000; |
||
66 | end if |
||
67 | } |
||
68 | |||
69 | |||
70 | { |
||
71 | ; zz=z >> ZB_POINT_Z_FRAC_BITS; |
||
72 | if TGL_FEATURE_RENDER_BITS eq 24 |
||
73 | ; if (zz >= pz[_a]) { |
||
74 | ; pp[3 * _a]=or1 >> 8; |
||
75 | ; pp[3 * _a + 1]=og1 >> 8; |
||
76 | ; pp[3 * _a + 2]=ob1 >> 8; |
||
77 | ; pz[_a]=zz; |
||
78 | ; } |
||
79 | ; z+=dzdx; |
||
80 | ; og1+=dgdx; |
||
81 | ; or1+=drdx; |
||
82 | ; ob1+=dbdx; |
||
83 | elseif TGL_FEATURE_RENDER_BITS eq 16 |
||
84 | ; if (zz >= pz[_a]) { |
||
85 | ; tmp=rgb & 0xF81F07E0; |
||
86 | ; pp[_a]=tmp | (tmp >> 16); |
||
87 | ; pz[_a]=zz; |
||
88 | ; } |
||
89 | ; z+=dzdx; |
||
90 | ; rgb=(rgb+drgbdx) & ( ~ 0x00200800); |
||
91 | else |
||
92 | ; if (zz >= pz[_a]) { |
||
93 | ; pp[_a] = RGB_TO_PIXEL(or1, og1, ob1); |
||
94 | ; pz[_a]=zz; |
||
95 | ; } |
||
96 | ; z+=dzdx; |
||
97 | ; og1+=dgdx; |
||
98 | ; or1+=drdx; |
||
99 | ; ob1+=dbdx; |
||
100 | end if |
||
101 | } |
||
102 | |||
103 | |||
104 | { |
||
105 | if TGL_FEATURE_RENDER_BITS eq 16 |
||
106 | ; register unsigned short *pz; |
||
107 | ; register PIXEL *pp; |
||
108 | ; register unsigned int tmp,z,zz,rgb,drgbdx; |
||
109 | ; register int n; |
||
110 | ; n=(x2 >> 16) - x1; |
||
111 | ; pp=pp1+x1; |
||
112 | ; pz=pz1+x1; |
||
113 | ; z=z1; |
||
114 | ; rgb=(r1 << 16) & 0xFFC00000; |
||
115 | ; rgb|=(g1 >> 5) & 0x000007FF; |
||
116 | ; rgb|=(b1 << 5) & 0x001FF000; |
||
117 | ; drgbdx=_drgbdx; |
||
118 | ; while (n>=3) { |
||
119 | ; PUT_PIXEL(0); |
||
120 | ; PUT_PIXEL(1); |
||
121 | ; PUT_PIXEL(2); |
||
122 | ; PUT_PIXEL(3); |
||
123 | ; pz+=4; |
||
124 | ; pp+=4; |
||
125 | ; n-=4; |
||
126 | ; } |
||
127 | ; while (n>=0) { |
||
128 | ; PUT_PIXEL(0); |
||
129 | ; pz+=1; |
||
130 | ; pp+=1; |
||
131 | ; n-=1; |
||
132 | ; } |
||
133 | end if |
||
134 | if TGL_FEATURE_RENDER_BITS eq 24 |
||
135 | ; register unsigned short *pz; |
||
136 | ; register PIXEL *pp; |
||
137 | ; register unsigned int s,t,z,zz; |
||
138 | ; register int n,dsdx,dtdx; |
||
139 | ; float sz,tz,fz,zinv; |
||
140 | ; n=(x2>>16)-x1; |
||
141 | ; fz=(float)z1; |
||
142 | ; zinv=1.0 / fz; |
||
143 | ; pp=(pp1 + x1 * PSZB); |
||
144 | ; pz=pz1+x1; |
||
145 | ; z=z1; |
||
146 | ; sz=sz1; |
||
147 | ; tz=tz1; |
||
148 | ; while (n>=(NB_INTERP-1)) { |
||
149 | ; { |
||
150 | ; float ss,tt; |
||
151 | ; ss=(sz * zinv); |
||
152 | ; tt=(tz * zinv); |
||
153 | ; s=(int) ss; |
||
154 | ; t=(int) tt; |
||
155 | ; dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); |
||
156 | ; dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); |
||
157 | ; fz+=fndzdx; |
||
158 | ; zinv=1.0 / fz; |
||
159 | ; } |
||
160 | ; PUT_PIXEL(0); |
||
161 | ; PUT_PIXEL(1); |
||
162 | ; PUT_PIXEL(2); |
||
163 | ; PUT_PIXEL(3); |
||
164 | ; PUT_PIXEL(4); |
||
165 | ; PUT_PIXEL(5); |
||
166 | ; PUT_PIXEL(6); |
||
167 | ; PUT_PIXEL(7); |
||
168 | ; pz+=NB_INTERP; |
||
169 | ; pp=(pp + NB_INTERP * PSZB); |
||
170 | ; n-=NB_INTERP; |
||
171 | ; sz+=ndszdx; |
||
172 | ; tz+=ndtzdx; |
||
173 | ; } |
||
174 | ; { |
||
175 | ; float ss,tt; |
||
176 | ; ss=(sz * zinv); |
||
177 | ; tt=(tz * zinv); |
||
178 | ; s=(int) ss; |
||
179 | ; t=(int) tt; |
||
180 | ; dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); |
||
181 | ; dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); |
||
182 | ; } |
||
183 | ; while (n>=0) { |
||
184 | ; PUT_PIXEL(0); |
||
185 | ; pz+=1; |
||
186 | ; pp=(PIXEL *)((char *)pp + PSZB); |
||
187 | ; n-=1; |
||
188 | ; } |
||
189 | end if |
||
190 | } |
||
191 | |||
192 | |||
193 | proc ZB_fillTriangleSmooth, zb:dword, p0:dword, p1:dword, p2:dword |
||
194 | locals |
||
195 | if TGL_FEATURE_RENDER_BITS eq 16 |
||
196 | _drgbdx dd ? ;int |
||
197 | end if |
||
198 | include 'ztriangle.inc' |
||
199 | ret |
||
200 | endp |
||
201 | |||
202 | |||
203 | proc ZB_setTexture uses eax ebx, zb:dword, texture:dword |
||
204 | mov eax,[zb] |
||
205 | mov ebx,[texture] |
||
206 | mov dword[eax+offs_zbuf_current_texture],ebx |
||
207 | ret |
||
208 | endp |
||
209 | |||
210 | |||
211 | INTERP_ST equ 1 |
||
212 | |||
213 | |||
214 | { |
||
215 | ; texture=zb->current_texture; |
||
216 | } |
||
217 | |||
218 | |||
219 | { |
||
220 | ; zz=z >> ZB_POINT_Z_FRAC_BITS; |
||
221 | if TGL_FEATURE_RENDER_BITS eq 24 |
||
222 | ; unsigned char *ptr; |
||
223 | ; if (zz >= pz[_a]) { |
||
224 | ; ptr = texture + (((t & 0x3FC00000) | s) >> 14) * 3; |
||
225 | ; pp[3 * _a]= ptr[0]; |
||
226 | ; pp[3 * _a + 1]= ptr[1]; |
||
227 | ; pp[3 * _a + 2]= ptr[2]; |
||
228 | ; pz[_a]=zz; |
||
229 | ; } |
||
230 | else |
||
231 | ; if (zz >= pz[_a]) { |
||
232 | ; pp[_a]=texture[((t & 0x3FC00000) | s) >> 14]; |
||
233 | ; pz[_a]=zz; |
||
234 | ; } |
||
235 | end if |
||
236 | ; z+=dzdx; |
||
237 | ; s+=dsdx; |
||
238 | ; t+=dtdx; |
||
239 | } |
||
240 | |||
241 | |||
242 | proc ZB_fillTriangleMapping, zb:dword, p0:dword, p1:dword, p2:dword |
||
243 | locals |
||
244 | texture dd ? ;PIXEL* |
||
245 | include 'ztriangle.inc' |
||
246 | ret |
||
247 | endp |
||
248 | |||
249 | |||
250 | ; Texture mapping with perspective correction. |
||
251 | ; We use the gradient method to make less divisions. |
||
252 | ; TODO: pipeline the division |
||
253 | ; |
||
254 | if 1 |
||
255 | |||
256 | |||
257 | INTERP_STZ equ 1 |
||
258 | |||
259 | |||
260 | |||
261 | |||
262 | { |
||
263 | ; texture=zb->current_texture; |
||
264 | ; fdzdx=(float)dzdx; |
||
265 | ; fndzdx=NB_INTERP * fdzdx; |
||
266 | ; ndszdx=NB_INTERP * dszdx; |
||
267 | ; ndtzdx=NB_INTERP * dtzdx; |
||
268 | } |
||
269 | |||
270 | |||
271 | { |
||
272 | ; zz=z >> ZB_POINT_Z_FRAC_BITS; |
||
273 | if TGL_FEATURE_RENDER_BITS eq 24 |
||
274 | ; unsigned char *ptr; |
||
275 | ; if (zz >= pz[_a]) { |
||
276 | ; ptr = texture + (((t & 0x3FC00000) | (s & 0x003FC000)) >> 14) * 3; |
||
277 | ; pp[3 * _a]= ptr[0]; |
||
278 | ; pp[3 * _a + 1]= ptr[1]; |
||
279 | ; pp[3 * _a + 2]= ptr[2]; |
||
280 | ; pz[_a]=zz; |
||
281 | ; } |
||
282 | else |
||
283 | ; if (zz >= pz[_a]) { |
||
284 | ; pp[_a]=*(PIXEL *)((char *)texture+ |
||
285 | ; (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))); |
||
286 | ; pz[_a]=zz; |
||
287 | ; } |
||
288 | end if |
||
289 | ; z+=dzdx; |
||
290 | ; s+=dsdx; |
||
291 | ; t+=dtdx; |
||
292 | } |
||
293 | |||
294 | |||
295 | proc ZB_fillTriangleMappingPerspective, zb:dword, p0:dword, p1:dword, p2:dword |
||
296 | locals |
||
297 | ; PIXEL *texture; |
||
298 | ; float fdzdx,fndzdx,ndszdx,ndtzdx; |
||
299 | include 'ztriangle.inc' |
||
300 | ret |
||
301 | endp |
||
302 | |||
303 | |||
304 | |||
305 | |||
306 | |||
307 | |||
308 | ; bits) |
||
309 | |||
310 | |||
311 | INTERP_STZ equ 1 |
||
312 | |||
313 | |||
314 | { |
||
315 | ; texture=zb->current_texture; |
||
316 | } |
||
317 | |||
318 | |||
319 | { |
||
320 | ; float zinv; |
||
321 | ; int s,t; |
||
322 | ; zz=z >> ZB_POINT_Z_FRAC_BITS; |
||
323 | ; if (zz >= pz[_a]) { |
||
324 | ; zinv= 1.0 / (float) z; |
||
325 | ; s= (int) (sz * zinv); |
||
326 | ; t= (int) (tz * zinv); |
||
327 | ; pp[_a]=texture[((t & 0x3FC00000) | s) >> 14]; |
||
328 | ; pz[_a]=zz; |
||
329 | ; } |
||
330 | ; z+=dzdx; |
||
331 | ; sz+=dszdx; |
||
332 | ; tz+=dtzdx; |
||
333 | } |
||
334 | |||
335 | |||
336 | proc ZB_fillTriangleMappingPerspective, zb:dword, p0:dword, p1:dword, p2:dword |
||
337 | locals |
||
338 | texture dd ? ;PIXEL* |
||
339 | include 'ztriangle.inc' |
||
340 | ret |
||
341 | endp |
||
342 | |||
343 | |||
344 |