Subversion Repositories Kolibri OS

Rev

Rev 6141 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6141 Rev 6243
Line 131... Line 131...
131
proc ZB_fillTriangleSmooth, zb:dword, p0:dword, p1:dword, p2:dword
131
proc ZB_fillTriangleSmooth, zb:dword, p0:dword, p1:dword, p2:dword
132
locals
132
locals
133
include 'ztriangle.inc'
133
include 'ztriangle.inc'
Line 134... Line 134...
134
 
134
 
135
align 16
135
align 16
-
 
136
proc ZB_setTexture uses eax ebx, zb:dword, texture:dword,\
136
proc ZB_setTexture uses eax ebx, zb:dword, texture:dword
137
	s_bound:dword, t_bound:dword, s_log2:dword
137
	mov eax,[zb]
138
	mov eax,[zb]
138
	mov ebx,[texture]
139
	mov ebx,[texture]
-
 
140
	mov dword[eax+offs_zbuf_current_texture],ebx
-
 
141
	mov ebx,[s_log2]
-
 
142
	mov dword[eax+offs_zbuf_s_log2],ebx
-
 
143
	mov ebx,[s_bound]
-
 
144
	mov dword[eax+offs_zbuf_s_bound],ebx
-
 
145
	mov ebx,[t_bound]
139
	mov dword[eax+offs_zbuf_current_texture],ebx
146
	mov dword[eax+offs_zbuf_t_bound],ebx
140
	ret
147
	ret
Line 141... Line 148...
141
endp
148
endp
142
 
149
 
Line 143... Line 150...
143
INTERP_Z equ 1
150
INTERP_Z equ 1
144
INTERP_ST equ 1
151
INTERP_ST equ 1
145
 
152
 
146
macro DRAW_INIT
153
macro DRAW_INIT
147
{
154
{
-
 
155
	mov eax,[zb]
-
 
156
	mov ebx,[eax+offs_zbuf_current_texture]
-
 
157
	mov [texture],ebx
-
 
158
	mov ebx,[eax+offs_zbuf_s_log2]
-
 
159
	mov [s_log2],ebx ;s_log2 = zb.s_log2
-
 
160
	mov ebx,[eax+offs_zbuf_s_bound]
148
	mov eax,[zb]
161
	mov [s_bound],ebx ;s_bound = zb.s_bound
Line 149... Line 162...
149
	mov eax,[eax+offs_zbuf_current_texture]
162
	mov ebx,[eax+offs_zbuf_t_bound]
150
	mov [texture],eax
163
	mov [t_bound],ebx ;t_bound = zb.t_bound
151
}
164
}
Line 159... Line 172...
159
	jl .end_0
172
	jl .end_0
160
		;edi = pp
173
		;edi = pp
161
		mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение
174
		mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение
162
if TGL_FEATURE_RENDER_BITS eq 24
175
if TGL_FEATURE_RENDER_BITS eq 24
163
		mov ebx,[t]
176
		mov ebx,[t]
164
		and ebx,0x3fc00000
177
		and ebx,[t_bound]
-
 
178
		mov ecx,[s_log2]
-
 
179
		shr ebx,cl ;(t & t_bound) >> s_log2
165
		mov eax,[s]
180
		mov eax,[s]
166
		and eax,0x003fc000
181
		and eax,[s_bound]
-
 
182
		shr eax,ZB_POINT_TEXEL_SIZE
167
		or ebx,eax
183
		or ebx,eax
168
		shr ebx,14
-
 
169
		imul ebx,3
184
		imul ebx,3
170
		add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | s) >> 14) * 3
185
		add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | s) >> 14) * 3
171
		mov ax,word[ebx]
186
		mov ax,word[ebx]
172
		mov word[edi+3*_a],ax ;pp[3 * _a]= ptr[0,1]
187
		mov word[edi+3*_a],ax ;pp[3 * _a]= ptr[0,1]
173
		mov al,byte[ebx+2]
188
		mov al,byte[ebx+2]
Line 186... Line 201...
186
 
201
 
187
align 16
202
align 16
188
proc ZB_fillTriangleMapping, zb:dword, p0:dword, p1:dword, p2:dword
203
proc ZB_fillTriangleMapping, zb:dword, p0:dword, p1:dword, p2:dword
189
locals
204
locals
-
 
205
	texture dd ? ;PIXEL*
-
 
206
	s_log2 dd ? ;unsigned int
-
 
207
	s_bound dd ? ;unsigned int
190
	texture dd ? ;PIXEL*
208
	t_bound dd ? ;unsigned int
Line 191... Line 209...
191
include 'ztriangle.inc'
209
include 'ztriangle.inc'
192
 
210
 
193
;
211
;
194
; Texture mapping with perspective correction.
212
; Texture mapping with perspective correction.
195
; We use the gradient method to make less divisions.
213
; We use the gradient method to make less divisions.
196
; TODO: pipeline the division
-
 
Line 197... Line 214...
197
;
214
; TODO: pipeline the division
198
if 1
215
;
Line 199... Line 216...
199
 
216
 
Line 200... Line 217...
200
INTERP_Z equ 1
217
INTERP_Z equ 1
201
INTERP_STZ equ 1
218
INTERP_STZ equ 1
202
 
219
 
203
NB_INTERP equ 8
220
NB_INTERP equ 8
204
 
221
 
-
 
222
macro DRAW_INIT
-
 
223
{
-
 
224
	mov eax,[zb]
-
 
225
	mov ebx,[eax+offs_zbuf_current_texture]
-
 
226
	mov [texture],ebx
-
 
227
	mov ebx,[eax+offs_zbuf_s_log2]
205
macro DRAW_INIT
228
	mov [s_log2],ebx ;s_log2 = zb.s_log2
206
{
229
	mov ebx,[eax+offs_zbuf_s_bound]
207
	mov eax,[zb]
230
	mov [s_bound],ebx ;s_bound = zb.s_bound
208
	mov eax,[eax+offs_zbuf_current_texture]
231
	mov ebx,[eax+offs_zbuf_t_bound]
209
	mov [texture],eax
232
	mov [t_bound],ebx ;t_bound = zb.t_bound
Line 229... Line 252...
229
	jl .end_0
252
	jl .end_0
230
		;edi = pp
253
		;edi = pp
231
		mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение
254
		mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение
232
if TGL_FEATURE_RENDER_BITS eq 24
255
if TGL_FEATURE_RENDER_BITS eq 24
233
		mov ebx,[t]
256
		mov ebx,[t]
234
		and ebx,0x3fc00000
257
		and ebx,[t_bound]
-
 
258
		mov ecx,[s_log2]
-
 
259
		shr ebx,cl ;(t & t_bound) >> s_log2
235
		mov eax,[s]
260
		mov eax,[s]
236
		and eax,0x003fc000
261
		and eax,[s_bound]
-
 
262
		shr eax,ZB_POINT_TEXEL_SIZE
237
		or ebx,eax
263
		or ebx,eax
238
		shr ebx,14
-
 
239
		imul ebx,3
264
		imul ebx,3
240
		add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | (s & 0x003FC000)) >> 14) * 3
265
		add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | (s & 0x003FC000)) >> 14) * 3
241
		mov ax,word[ebx]
266
		mov ax,word[ebx]
242
		mov word[edi+3*_a],ax ;pp[3 * _a]= ptr[0,1]
267
		mov word[edi+3*_a],ax ;pp[3 * _a]= ptr[0,1]
243
		mov al,byte[ebx+2]
268
		mov al,byte[ebx+2]
Line 365... Line 390...
365
	fndzdx dd ? ;float
390
	fndzdx dd ? ;float
366
	ndszdx dd ? ;float
391
	ndszdx dd ? ;float
367
	ndtzdx dd ? ;float
392
	ndtzdx dd ? ;float
368
	zinv dd ? ;float
393
	zinv dd ? ;float
369
	f_z dd ? ;float - переменная отвечающая за геометрию текстуры
394
	f_z dd ? ;float - переменная отвечающая за геометрию текстуры
-
 
395
	s_log2 dd ? ;unsigned int
-
 
396
	s_bound dd ? ;unsigned int
-
 
397
	t_bound dd ? ;unsigned int
370
include 'ztriangle.inc'
398
include 'ztriangle.inc'
371
 
-
 
372
end if
-
 
373
 
-
 
374
if 0
-
 
375
 
-
 
376
; slow but exact version (only there for reference, incorrect for 24
-
 
377
; bits)
-
 
378
 
-
 
379
INTERP_Z equ 1
-
 
380
INTERP_STZ equ 1
-
 
381
 
-
 
382
macro DRAW_INIT
-
 
383
{
-
 
384
	mov eax,[zb]
-
 
385
	mov eax,[eax+offs_zbuf_current_texture]
-
 
386
	mov [texture],eax
-
 
387
}
-
 
388
 
-
 
389
macro PUT_PIXEL _a
-
 
390
{
-
 
391
local .end_0
-
 
392
	mov eax,[z]
-
 
393
	shr eax,ZB_POINT_Z_FRAC_BITS
-
 
394
	cmp ax,word[esi+2*_a] ;if (zz >= pz[_a])
-
 
395
	jl .end_0
-
 
396
		;edi = pp
-
 
397
		mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение
-
 
398
		fild dword[z]
-
 
399
		fld dword[s_z]
-
 
400
		fdiv st0,st1
-
 
401
		fistp dword[esp-4] ;s = (int) (s_z / (float) z)
-
 
402
		fld dword[t_z]
-
 
403
		fdiv st0,st1
-
 
404
		fistp dword[esp-8] ;t = (int) (t_z / (float) z)
-
 
405
		mov eax,dword[esp-8]
-
 
406
		and eax,0x3FC00000
-
 
407
		or eax,dword[esp-4]
-
 
408
		shr eax,12 ;14
-
 
409
		add eax,[texture]
-
 
410
		mov eax,[eax]
-
 
411
		stosd ;pp[_a] = texture[((t & 0x3FC00000) | s) >> 14]
-
 
412
		sub edi,4
-
 
413
	.end_0:
-
 
414
	mov eax,[dzdx]
-
 
415
	add [z],eax
-
 
416
	fld dword[dszdx]
-
 
417
	fadd dword[s_z]
-
 
418
	fstp dword[s_z]
-
 
419
	fld dword,[dtzdx]
-
 
420
	fadd dword[t_z]
-
 
421
	fstp dword[t_z]
-
 
422
}
-
 
423
 
-
 
424
align 16
-
 
425
proc ZB_fillTriangleMappingPerspective, zb:dword, p0:dword, p1:dword, p2:dword
-
 
426
locals
-
 
427
	texture dd ? ;PIXEL*
-
 
428
include 'ztriangle.inc'
-
 
429
 
-
 
430
end if
-