1 ; $Header: x:/prj/tech/libsrc/g2/RCS/lo816il.asm 1.1 1998/04/09 10:01:00 KEVIN Exp $
16 last_ltab
dd 0deadbeefh
17 last_mask_u
dd 0deadbeefh
18 last_mask_v
dd 0deadbeefh
19 last_p_src
dd 0deadbeefh
31 p_dest
equ G2S_POLY_PARAMS_P
32 row
equ G2S_POLY_PARAMS_CANVAS_ROW
33 dux
equ G2S_POLY_PARAMS_DUX
34 dvx
equ G2S_POLY_PARAMS_DVX
35 dix
equ G2S_POLY_PARAMS_DIX
36 u
equ G2S_POLY_PARAMS_LEFT_U
37 v
equ G2S_POLY_PARAMS_LEFT_V
38 i
equ G2S_POLY_PARAMS_LEFT_I
39 du
equ G2S_POLY_PARAMS_LEFT_DU
40 dv
equ G2S_POLY_PARAMS_LEFT_DV
41 i_left
equ G2S_POLY_PARAMS_LEFT_I
42 di_left
equ G2S_POLY_PARAMS_LEFT_DI
43 x_left
equ G2S_POLY_PARAMS_LEFT_X
44 dx_left
equ G2S_POLY_PARAMS_LEFT_DX
45 x_frac
equ G2S_POLY_PARAMS_LEFT_X_FRAC
46 dx_frac
equ G2S_POLY_PARAMS_LEFT_DX_FRAC
47 x_right
equ G2S_POLY_PARAMS_RIGHT_X
48 dx_right
equ G2S_POLY_PARAMS_RIGHT_DX
52 ;takes eax = poly params
54 _FUNCDEF opaque_lit_8to16_raster
, 2
76 mov ebx, x_right
[ebp] ; fixed point
77 mov ecx, x_left
[ebp] ; int
79 sar ebx, 16 ; convert to int
80 mov edi, p_dest
[ebp] ; beginning of canvas row
87 ;edx = num scanlines remaining
90 ;ebp = triangle_params
93 mov count
, edx ; number of scanlines remaining
95 sub ecx, ebx ; ecx = -num pixels in scanline
99 lea edi, [edi+2*ebx] ; point to end of scanline
104 mov ebx, eax ; two copies of u
105 mov ebp, esi ; two copies of v
116 shr eax, 16 ; convert u_temp to int
117 and esi, 0deadbeefh
; mask v_temp
120 shr esi, 0ffh
; set up for read from texture
122 and eax, 0deadbeefh
; mask u_temp
125 add ebx, dux_local
; increment u
126 add ebp, dvx_local
; increment v (note: 2 cycles on p5; 1 on p55c)
128 mov dl, 0deadbeefh
[esi+eax] ; read pixel from texture
139 mov eax, ebx ; copy u to u_temp
142 inc ecx ; increment count
144 mov dx, 0deadbeefh
[2*edx] ; read from ltab
146 mov esi, ebp ; copy v to v_temp
148 mov [edi+2*ecx-2], dx ; write pixel
149 jnz pixel_loop
; continue until done
151 ; update u, v, x_left (int), x_frac (fraction for x_left), x_right (fix), and p_dest.
152 ; maintain sub-pixel precision.
160 add ecx, dx_left
[ebp] ; update x_left
161 add edx, dx_frac
[ebp]
163 sbb ebx, ebx ; -1 if there was a carry
167 sub ecx, ebx ; adjust x_left for carry
173 add esi, di_left
[ebp]
175 and eax, ebx ; adjust di for carry
178 add esi, eax ; adjust i for carry
182 and eax, ebx ; adjust du for carry
185 add edx, eax ; adjust u for carry
190 and eax, ebx ; adjust dv for carry
193 mov ebx, x_right
[ebp]
196 add ebx, dx_right
[ebp]
199 add esi, eax ; adjust v for carry
200 mov x_right
[ebp], ebx
205 mov eax, row
[ebp] ; canvas row, that is
224 _FUNCDEF opaque_lit_8to16_il_init
, 1
228 mov edx, _grd_ltab816
232 mov ebx, GRS_BITMAP_BITS
[eax]
237 mov d
ds:[ltab
-4], edx
241 mov edx, GRS_BITMAP_W
[eax] ;width AND height
242 mov al, GRS_BITMAP_WLOG
[eax]
245 sub edx, 010001h ;convert to masks
247 sub cl, al ;v_shift = 16-bm->wlog
250 and edx, 0ffff0000h
;v_mask = fix_make(bm->h-1,0)
251 and eax, 0ffffh
;u_mask = bm->w -1
253 ;eax = mask_u, edx = mask_v, ebx = p_src, cl = shift_v
260 mov d
ds:[mask_u
-4], eax
266 mov d
ds:[mask_v
-4], edx
276 mov d
ds:[p_src
-4], ebx
282 mov b
ds:[shift_v
-1], cl