convert line ends
[canaan.git] / prj / tech / libsrc / g2 / fl8lo2wi.asm
blob60ec7201b1dc2caedf8ced6954e78908a5342f02
2 ; $Source: x:/prj/tech/libsrc/g2/RCS/fl8lo2wi.asm $
3 ; $Revision: 1.7 $
4 ; $Author: TOML $
5 ; $Date: 1996/11/04 13:57:15 $
7 ; Inner loop of opaque linear mapping primitive.
9 ; This file is part of the g2 library.
12 .386
13 include type.inc
14 include cseg.inc
15 include dseg.inc
16 include grs.inc
17 include tmaps.inc
18 include tmapd.inc
19 include msmacros.inc
21 assume ds:_DATA
22 _DATA segment
23 public _g2d_o2wi_mask_u
24 public _g2d_o2wi_mask_v
25 public _g2d_o2wi_shift_v
26 public _g2d_o2wi_p_src
28 public _g2d_o2wi_last_mask_u
29 _g2d_o2wi_last_mask_u dd 0deadbeefh
30 public _g2d_o2wi_last_mask_v
31 _g2d_o2wi_last_mask_v dd 0deadbeefh
32 public _g2d_o2wi_last_p_src
33 _g2d_o2wi_last_p_src dd 0deadbeefh
34 public _g2d_o2wi_last_shift_v
35 _g2d_o2wi_last_shift_v db 0ffh
37 public _g2d_ltab_dither0
38 public _g2d_ltab_dither1
40 buffer_end equ _g2d_tmap_buffer[G2C_TMAP_BUFFER_SIZE]
41 ltab equ _g2d_tmap_info[G2S_TMAP_LTAB]
42 p_dest equ _g2d_tmap_info[G2S_TMAP_P_DEST]
43 du equ _g2d_tmap_info[G2S_TMAP_DUX]
44 dv equ _g2d_tmap_info[G2S_TMAP_DVX]
45 i_delta equ _g2d_tmap_info[G2S_TMAP_DIX]
46 i equ _g2d_tmap_info[G2S_TMAP_I]
47 drow equ _g2d_tmap_info[G2S_TMAP_DROW]
49 _DATA ends
51 _TEXT segment
52 ; takes eax=-count, ebx:u, ecx:v
53 ; NOT C callable
54 public flat8_flat8_opaque_p2_wrap_il_chained_
55 public _flat8_flat8_opaque_p2_wrap_il_chained
56 _flat8_flat8_opaque_p2_wrap_il_chained:
57 flat8_flat8_opaque_p2_wrap_il_chained_:
58 mov edx, ecx ;v_temp = v
59 mov esi, ebx ;u_temp = u
60 mov edi, dv ;get dv
61 mov ebp, du ;get du
63 ;eax count
64 ;ebx u
65 ;ecx v
66 ;edx v_temp
67 ;esi u_temp
68 ;edi dv
69 ;ebp du
71 pix_loop:
72 shr esi, 16
73 and edx, 0deadbeefh
74 _g2d_o2wi_mask_v:
76 shr edx, 0ffh
77 _g2d_o2wi_shift_v:
78 and esi, 0deadbeefh
79 _g2d_o2wi_mask_u:
81 add ebx, ebp
82 add ecx, edi
84 mov dl, 0deadbeefh[esi+edx]
85 _g2d_o2wi_p_src:
86 mov esi, ebx
88 mov buffer_end[eax], dl
89 mov edx, ecx
91 inc eax
92 jnz pix_loop
94 ret
96 ;eax = -count
97 ;edx = u
98 ;ebx = v
99 _FUNCDEF flat8_flat8_opaque_p2_wrap_il_chain_from_c, 3
100 push ecx
101 push ebp
102 push esi
103 push edi
104 mov ecx, ebx ; ecx = v
105 mov ebx, edx ; ebx = u
106 call flat8_flat8_opaque_p2_wrap_il_chained_
107 pop edi
108 pop esi
109 pop ebp
110 pop ecx
113 punt:
114 pop ebp
115 pop esi
116 pop edi
119 _FUNCDEF flat8_flat8_lit_opaque_p2_wrap_il, 3
120 push edi
121 mov edi, p_dest
123 push esi
124 push ebp
126 lea esi, [edi+eax]
127 mov ebp, drow
129 add edi, ebp
130 sub eax, edx
132 mov p_dest, edi
133 jns punt
135 push eax ;-count
136 push esi ;p_dest
138 call flat8_flat8_opaque_p2_wrap_il_chained_
139 pop ebp ;p_dest
141 pop esi ;-count
142 mov edi, ltab
144 inc esi
145 mov ebx, i_delta
147 ror ebx, 16
148 mov eax, i
150 ror eax, 16
151 xor edx, edx
153 mov dh, al
154 test esi, esi
156 jz one_pix
157 add eax, ebx
159 mov al, [ebp] ;read cache line
161 mov ecx, 0 ;don't xor! need to preserve flags
162 mov al, dh
164 ; eax i high 16 = frac; al = int
165 ; ebx di high 16 = frac; bl = int
166 ; ecx temp
167 ; edx temp
168 ; esi source
169 ; edi ltab
170 ; ebp dest
172 light_loop:
173 adc eax, ebx
174 lea ebp, [ebp+2]
176 mov ch, al
177 mov dl, buffer_end[esi]-1
179 adc eax, ebx
180 mov cl, buffer_end[esi]
182 mov dl, [edi+edx]
183 inc esi
185 mov dh, [edi+ecx]
186 inc esi
188 mov [ebp-2], dl
189 mov [ebp-1], dh
191 mov dh, al
192 js light_loop
194 jnz done
195 mov dh, al
197 one_pix:
198 mov dl, buffer_end-1
199 mov dl, [edi+edx]
200 mov [ebp], dl
202 done:
203 pop ebp
204 pop esi
205 pop edi
208 _FUNCDEF flat8_flat8_lit_opaque_p2_wrap_dither_il, 3
209 push edi
210 mov edi, p_dest
212 push esi
213 push ebp
215 lea esi, [edi+eax]
216 mov ebp, drow
218 add edi, ebp
219 sub eax, edx
221 mov p_dest, edi
222 jns punt
224 push eax ;-count
225 push esi ;p_dest
227 call flat8_flat8_opaque_p2_wrap_il_chained_
228 pop edi ;p_dest
229 pop esi ;-count
231 xor ebp, ebp ;error
232 mov ebx, i_delta
234 mov eax, i
235 inc esi
237 jz last_pix_hack
238 ; eax i
239 ; ebx di
240 ; ecx temp
241 ; edx temp
242 ; esi source
243 ; edi p_dest
244 ; ebp mask
246 dithered_light_loop:
247 add ebp, eax
248 add eax, ebx
250 mov edx, ebp
251 and ebp, 0ffffh
253 shr edx, 8
254 add ebp, eax
256 mov ecx, ebp
257 mov dl, buffer_end[esi]-1
259 shr ecx, 8
260 add eax, ebx
262 mov dl, 0deadbeefh[edx]
263 _g2d_ltab_dither0:
264 mov cl, buffer_end[esi]
266 and ebp, 0ffffh
267 mov [edi], dl
269 add esi, 2
270 read_ltab:
271 mov dh, 0deadbeefh[ecx]
272 _g2d_ltab_dither1:
274 mov [edi+1], dh
275 lea edi, [edi+2]
277 js dithered_light_loop
279 jz last_pix_hack
281 pop ebp
282 pop esi
283 pop edi
286 last_pix_hack:
287 mov ecx, eax
288 dec edi
290 shr ecx, 8
291 mov cl, buffer_end-1
293 inc esi ;set zf=0, sf=0
294 jmp read_ltab
297 _TEXT ends