1 ; $Header: x:/prj/tech/libsrc/g2/RCS/ptfloat.asm 1.1 1997/09/23 12:41:38 KEVIN Exp $
3 ; PORTAL Texture Mappers
7 ; Floating point routines to compute (u,v) and (du,dv)
8 ; from (a,b,c) and (c*da - a*dc, c*db - b*dc)
19 assume cs:_TEXT
, ds:_DATA
21 _DATA
segment para
public USE32
'DATA'
27 _g2pt_two_to_52_power
dd 059900000h
33 extq _g2pt_u_step_data
34 extq _g2pt_v_step_data
41 extd _g2pt_two_to_52_power
47 _TEXT
segment para
public USE32
'CODE'
49 extn g2tmap_float_uv_start_part_one
50 extn g2tmap_float_uv_start_part_two
51 extn g2tmap_float_uv_start_part_two_b
52 extn g2tmap_float_uv_start_part_two_c
53 extn g2tmap_float_uv_start
54 extn g2tmap_float_uv_iterate
55 extn g2tmap_float_uv_iterate_n
56 extn g2tmap_float_uv_cleanup
60 ; Compute U&V values using overlapped floating point ops
65 ; compute a single u,v value directly (no waiting),
66 ; and setup for next iterative step based on a passed-in
69 g2tmap_float_uv_start_part_one:
70 fld _g2pt_two_to_52_power
76 fld qword ptr 16[eax] ; c b a hack
78 fld _g2pt_one
; 1 c b a hack
80 fld st(1) ; c 1 c b a hack
81 fxch st(2) ; c 1 c b a hack
84 fxch st(3) ; a c b z hack
88 ; pass in eax == integer to multiply dc by
89 g2tmap_float_uv_start_part_two:
91 ; while waiting for the divide, prefetch
92 cmp eax,_g2pt_int_table
[eax*4] ; fetch it
93 lea eax,_g2pt_int_table
[eax*4] ; preaddress
95 fmul st,st(3) ; 1 u c b z hack
96 fxch st(1) ; c (1)u b z hack
98 fld st(0) ; 2 c c (1)u b z hack
99 fxch st(3) ; b c (1)u c z hack
101 fmulp st(4),st ; 3 c (1)u c (3)v hack
105 fmul dword ptr [eax] ; number of steps
107 fadd ; 4 (4)c' (1)u c (3)v hack
108 fxch st(1) ; (1)u (4)c' c (3)v hack
110 fadd _g2pt_u_offset
; 5 (5)iu (4)c' c (3)v hack
111 fxch st(3) ; (3)v (4)c' c (5)iu hack
113 fadd _g2pt_v_offset
; 6 (6)iv (4)c' c (5)iu hack
114 fxch st(1) ; (4)c' (6)iv c (5)iu hack
116 fmul st(2),st ; 7 (4)c' (6)iv (7)c*c' (5)iu hack
117 fxch st(1) ; (6)iv (4)c' (7)c*c' (5)iu hack
119 fld _g2pt_one
; 8 1 (6)iv (4)c' (7)c*c' (5)iu hack
120 fxch st(4) ; (5)iu (6)iv (4)c' (7)c*c' 1 hack
122 fstp _g2pt_float_buf
; 9 (6)iv c' (7)c*c' 1 hack
124 fstp _g2pt_float_buf2
; 11 c' (7)c*c' 1 hack
126 fxch st(2) ; 1 (7)c*c' c' hack
131 g2tmap_float_uv_start:
132 call g2tmap_float_uv_start_part_one
134 call g2tmap_float_uv_start_part_two
137 ; compute final u,v values,
138 ; and start next computation going
140 g2tmap_float_uv_iterate:
141 fld st(0) ; zz zz c hack
142 fxch st(2) ; c zz zz hack
144 fld st(0) ; c c zz zz hack
145 fxch st(2) ; zz c c zz hack
147 fmul _g2pt_u_step_data
; du c c zz hack
148 fxch st(1) ; c du c zz hack
150 fadd _g2pt_gdc
; c' du c zz hack
151 fxch st(3) ; zz du c c' hack
153 fmul _g2pt_v_step_data
; dv du c c' hack
154 fxch st(1) ; du dv c c' hack
156 fadd st,st(4) ; idu dv c c' hack
157 fxch st(2) ; c dv idu c' hack
159 fmul st,st(3) ; c*c' dv idu c' hack
160 fxch st(1) ; dv c*c' idu c' hack
162 fadd st,st(4) ; idv c*c' idu c' hack
163 fxch st(2) ; idu c*c' idv c' hack
165 fstp _g2pt_float_buf
; c*c' idv c' hack
167 fld _g2pt_one
; 1 c*c' idv c hack
168 fxch st(2) ; idv c*c' 1 c hack
170 fstp _g2pt_float_buf2
; c*c' 1 c' hack
176 g2tmap_float_uv_iterate_n:
177 fld st(0) ; zz zz c hack
178 fxch st(2) ; c zz zz hack
180 fld st(0) ; c c zz zz hack
181 fxch st(2) ; zz c c zz hack
183 fmul _g2pt_u_step_data
; du c c zz hack
184 fxch st(1) ; c du c zz hack
188 fmul dword ptr _g2pt_int_table
[eax*4]
190 fadd ; c' du c zz hack
191 fxch st(3) ; zz du c c' hack
193 fmul _g2pt_v_step_data
; dv du c c' hack
194 fxch st(1) ; du dv c c' hack
196 fadd st,st(4) ; idu dv c c' hack
197 fxch st(2) ; c dv idu c' hack
199 fmul st,st(3) ; c*c' dv idu c' hack
200 fxch st(1) ; dv c*c' idu c' hack
202 fadd st,st(4) ; idv c*c' idu c' hack
203 fxch st(2) ; idu c*c' idv c' hack
205 fstp _g2pt_float_buf
; c*c' idv c' hack
207 fld _g2pt_one
; 1 c*c' idv c hack
208 fxch st(2) ; idv c*c' 1 c hack
210 fstp _g2pt_float_buf2
; c*c' 1 c' hack
217 ; is this really necessary given the circular stack?
218 g2tmap_float_uv_cleanup: