1 ; $Header: r:/t2repos/thief2/libsrc/portold/ptmap.asm,v 1.5 1996/12/07 20:31:14 buzzard Exp $
3 ; PORTAL Texture Mappers
18 assume cs:_TEXT
, ds:_DATA
22 extd _pt_tmap_mask
,_pt_tmap_row
,_pt_tmap_ptr
32 _DATA
segment para
public USE32
'DATA'
40 externdef
dlight_8:dword
55 externdef
pt_dest:dword
57 start_len_table
db 8,7,6,9,8,7,6,9
62 externdef
_u_step_data:qword
63 externdef
_v_step_data:qword
65 externdef
_dc_table:dword
66 externdef
float_buf:qword
67 externdef
float_buf2:qword
72 _TEXT
segment para
public USE32
'CODE'
79 extn ptmap_float_duv_b
80 extn ptmap_float_duv_c
81 extn ptmap_float_duv_d
83 extn ptmap_setup_duv
; currently desupported
84 extn ptmap_setup_uvduv
88 ; get u,v values from our iterative process
89 ; and arrange them in registers for mapping
92 mov ebx,dword ptr float_buf
93 mov ecx,dword ptr float_buf2
99 ; arrange u,v values into registers
102 ; we output into ebx, esi, eax
109 ror ebx,16 ; align fraction high and integer low
118 mov ecx,_pt_tmap_mask
120 and ebx,ecx ; mask to stay wrapped in texture map
124 mov eax,ecx ; eax = v
125 mov esi,_pt_tmap_row
; esi = row
127 sar eax,16 ; eax = v_hi
129 imul
eax,esi ; eax = v_hi * row
131 shl ecx,16 ; ecx = v_lo
132 mov esi,ebx ; esi = u
134 sar ebx,16 ; ebx = u_hi
136 shl esi,16 ; esi = u_lo
137 add ebx,eax ; ebx = u_hi + v_hi*row
139 mov eax,ecx ; eax = v_lo
140 mov ecx,_pt_tmap_ptr
; ecx = texture
142 add ebx,ecx ; ebx = texture + u_hi + v_hi*row
147 ; get results of last FP computation
148 ; and use them to compute our deltas
149 ; and arrange them in registers
156 mov edx,dword ptr float_buf
157 mov ebp,dword ptr float_buf2
162 mov ecx,dword ptr float_buf2
170 ; pt_step_table[0] = ((dv_hi+1) * row) + (du_hi)
171 ; pt_step_table[1] = ((dv_hi * row) + (du_hi)
177 ; EBX = source + u_hi + v_hi * source_row
181 mov edx,dword ptr float_buf2
; edx = dv
183 sar edx,16 ; edx = dv_hi
184 mov eax,dword ptr float_buf
; eax = du
186 sar eax,16 ; eax = du_hi
187 mov ebp,_pt_tmap_row
; ebp = row
189 mov edx,_pt_row_table
[edx*4+32*4] ; edx = dv_hi * row
191 add edx,eax ; edx = dv_hi * row + du_hi
194 mov _pt_step_table
+4,edx ; pt_step_table[1] = dv*row+du
195 add edx,ebp ; edx = (dv_hi+1) * row + du_hi
197 mov _pt_step_table
,edx ; pt_step_table[0] = ...
198 mov edx,dword ptr float_buf
; edx = du
200 shl edx,16 ; edx = du_lo
201 mov ebp,dword ptr float_buf2
; ebp = dv
203 shl ebp,16 ; ebp = dv_lo
208 ; arrange du,dv values into registers
211 ; we output into edx, edx, ebp
225 ; arrange u,v,du,dv values into registers
243 mov ecx,_pt_tmap_mask
247 and ebx,ecx ; mask to stay wrapped in texture map
253 ; compute lighting values
257 ; computes n values of lighting found in al
258 ; preserves all registers except ecx
270 jnz compute_light_dither_n
281 lea edi,_pt_lit_buffer
293 ; clean up to compute final value
306 compute_light_dither_n:
313 lea edi,_pt_lit_buffer
343 ; computes 8 values of lighting
351 jnz compute_light_dither_8
359 mov byte ptr _pt_lit_buffer
,cl
364 mov byte ptr _pt_lit_buffer
+1,cl
369 mov byte ptr _pt_lit_buffer
+2,cl
374 mov byte ptr _pt_lit_buffer
+3,cl
379 mov byte ptr _pt_lit_buffer
+4,cl
384 mov byte ptr _pt_lit_buffer
+5,cl
389 mov byte ptr _pt_lit_buffer
+6,cl
394 mov byte ptr _pt_lit_buffer
+7,cl
399 compute_light_dither_8:
408 mov byte ptr _pt_lit_buffer
,cl
413 mov byte ptr _pt_lit_buffer
+1,cl
418 mov byte ptr _pt_lit_buffer
+2,cl
423 mov byte ptr _pt_lit_buffer
+3,cl
428 mov byte ptr _pt_lit_buffer
+4,cl
433 mov byte ptr _pt_lit_buffer
+5,cl
438 mov byte ptr _pt_lit_buffer
+6,cl
443 mov byte ptr _pt_lit_buffer
+7,cl