convert line ends
[canaan.git] / prj / tech / libsrc / g2 / fl8o2ni.asm
blob08daac9653316e2a862ae0e1de572000112958e1
2 ; $Source: x:/prj/tech/libsrc/g2/RCS/fl8o2ni.asm $
3 ; $Revision: 1.2 $
4 ; $Author: TOML $
5 ; $Date: 1996/10/16 16:07:24 $
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
19 assume ds:_DATA
20 _DATA segment
21 extern _g2d_tmap_info:dword
23 temp:
24 dd ?
25 ones dd ?
26 dest dd ?
28 public _g2d_tm_wlog
29 _DATA ends
31 _TEXT segment
33 ; takes:
34 ; eax = x_left
35 ; edx = x_right
36 ; ebx = u
37 ; ecx = v
39 ; returns:
40 ; ecx = length
41 ; edx = u_frac
42 ; ebx = v_frac
43 ; esi = p_src
44 ; edi = p_dst
45 g2_flat8_tmap_setup:
46 mov esi, ecx ; v_fix
47 mov edi, _g2d_tmap_info[G2S_TMAP_P_DEST]
48 ; get p_dest
50 sal ecx, 16 ; v_frac
51 sub edx, eax ; get length
53 sar esi, 16 ; v_int
54 add eax, edi ; p_dest + x_left
56 sal esi, 0ffh ; v_int<<wlog
57 _g2d_tm_wlog:
58 add edi, _g2d_tmap_info[G2S_TMAP_DROW]
59 ; p_dest += drow
61 mov _g2d_tmap_info[G2S_TMAP_P_DEST], edi
62 ; save next p_dest
63 mov edi, eax ; edi = p_dest *
65 mov ebp, ebx ; u_fix
66 sar ebx, 16 ; u_int
68 mov eax, _g2d_tmap_info[G2S_TMAP_BM]
69 ; bitmap pointer
70 sal ebp, 16 ; u_frac
72 add esi, ebx ; offset = u_int + v_int<<wlog
73 mov ebx, ecx ; ebx = v_frac *
75 mov ecx, edx ; length *
76 mov edx, ebp ; u_frac *
78 add esi, GRS_BITMAP_BITS[eax]
79 ; p_src = bm->bits + offset *
80 ret
82 o_ones:
83 test ecx, ecx
84 jz o_ones_done
85 o_ones_loop:
86 mov bl,[esi]
87 add edx,ebp
88 adc esi,_g2d_tmap_info[G2S_TMAP_DSRC][4*eax]
89 add ebx,_g2d_tmap_info[G2S_TMAP_DV_FRAC]
90 sbb eax,eax
91 mov [edi],bl
92 inc edi
93 dec ecx
95 jnz o_ones_loop
96 o_ones_done:
97 ret
99 ; takes eax=x_left, edx=x_right, ebx:u, ecx:v
100 public flat8_flat8_opaque_p2_nowrap_il_
101 flat8_flat8_opaque_p2_nowrap_il_:
102 push esi
103 push edi
104 push ebp
106 ; takes eax=x_left, edx=x_right, ebx=u, ecx=v
107 ; returns ecx = length, edi=p_dst, esi=p_src, edx=u_frac, ebx=v_frac
108 call g2_flat8_tmap_setup
110 add ebx, _g2d_tmap_info[G2S_TMAP_DV_FRAC]
111 sbb eax, eax
113 cmp ecx, 7
114 jae o_normal
116 mov ebp, _g2d_tmap_info[G2S_TMAP_DU_FRAC]
117 call o_ones
118 pop ebp
119 pop edi
120 pop esi
123 o_normal:
124 mov ebp, edi
125 mov dest, edi
127 neg edi
128 add ebp, ecx
130 and ebp, 3
131 and edi, 3
133 mov ones, ebp
134 sub ecx, ebp
136 shr ecx, 2
137 mov ebp, _g2d_tmap_info[G2S_TMAP_DU_FRAC]
139 mov dl, cl
140 mov ecx, edi
142 mov edi, dest
143 call o_ones
145 mov dest, edi
146 mov ecx, _g2d_tmap_info[G2S_TMAP_DV_FRAC]
148 ;eax:v_carry
149 ;edx:u_frac
150 ;ebx:v_frac
151 ;ecx:dv_frac
152 ;esi:p_src
153 ;edi:scratch
154 ;ebp:du_frac
156 o_main_loop:
157 mov bl,[esi]
158 add edx,ebp
159 mov edi,_g2d_tmap_info[G2S_TMAP_DSRC][4*eax]
160 mov b ds:[temp],bl
161 adc esi,edi
162 add ebx,ecx
164 sbb eax,eax
165 mov bl,[esi]
166 add edx,ebp
167 mov edi,_g2d_tmap_info[G2S_TMAP_DSRC][4*eax]
168 adc esi,edi
169 add ebx,ecx
171 sbb eax,eax
172 mov b ds:1[temp],bl
173 mov bl,[esi]
174 add edx,ebp
175 mov b ds:2[temp],bl
176 mov edi,_g2d_tmap_info[G2S_TMAP_DSRC][4*eax]
178 adc esi,edi
179 add ebx,ecx
180 sbb eax,eax
181 mov bl,[esi]
182 add edx,ebp
183 mov edi,_g2d_tmap_info[G2S_TMAP_DSRC][4*eax]
185 adc esi,edi
186 add ebx,ecx
188 mov b ds:3[temp],bl
190 sbb eax,eax
191 mov edi,dest
193 add edi,4
194 mov ecx,d ds:[temp]
195 mov dest,edi
196 dec dl
197 mov [edi-4],ecx
198 mov ecx, _g2d_tmap_info[G2S_TMAP_DV_FRAC]
199 jnz o_main_loop
201 mov ecx, ones
202 call o_ones
204 pop ebp
205 pop edi
206 pop esi
209 _TEXT ends