Intel i86W Manual page 191

Table of Contents

Advertisement

PROGRAMMING EXAMPLES
9.13.3.2 ACCUMULATOR INITIALIZATION
When the first pixel of the line segment is not at an 8-byte boundary, initial values
placed in the accumulators (aZ, aB, aG, and aR) must be selected so that Zl, Red1,
Gm1, and Btu1 correspond to the correct pixel. The desired result is that shown by
Table 9-2. However, each value is a composite of two terms: one that is constant for each
edge pair (n*mZ, n*mR, n*mG, n*mB) and one that can vary with each scan line (Zl,
Red1, Gm1, Btul). The example assumes that the constant values have all been calcu-
lated and stored in a memory table of the format shown by Table 9-3. At the beginning
of each line segment the values appropriate to the alignment of the line segment are
retrieved from the table and added to the initial Z and color values, as shown in
Example 9-20.
9.13.4 The Inner Loop
Once the proper preparations have been made, only a minimal amount of code is
needed to render each scanline segment of a polygon. The code shown in Example 9-21
operates on four pixels in each loop. The left and right ends of the line segment go
through different logic paths so that the Z-buffer masks can be applied by the
form
instruction. All the interior points are handled by the tight inner loop.
The controlling variable
dX
is zero-relative and is expressed as a number of pixels. The
value of
dX
also indicates alignment of the end-points with respect to the 4-pixel groups.
Unaligned left-end pixels are subtracted from
dX
before entering the inner loop; there-
fore, subsequent values of
dX
indicate the alignment of the right end. A value that is 3
mod 4 indicates that the right end is aligned, which explains the test for a value of - 5
near the end of the loop (- 5 mod 4 = 3). The fact that the value - 5 is loaded into
register
Rb
on every execution of the loop does not represent a programming ineffi-
ciency, because there is nothing else for the core unit to do at that point anyway.
Table 9-2. Accumulator Initial Values
Alignment
Initial Z Accumulator Values
0
Z1 - 1*mZ
Z1 - 3*mZ
2
Z1 - 2*mZ
Z1 - 4*mZ
4
Z1 - 3*mZ
Z1 - 5*mZ
6
Z1 - 4*mZ
Z1 - 6*mZ
Alignment
Initial Color Accumulator Values
C
=
R, G, B
0
C1 - 1*mC
C1 - 2*mC
C1 - 3*mC
C1 - 4*mC
2
C1 - 2*mC
C1 - 3*mC
C1 - 4*mC
C1 - 5*mC
4
C1 - 3*mC
C1 - 4*mC
C1 - 5*mC
C1 - 6*mC
6
C1 - 4*mC
C1 - 5*mC
C1 - 6*mC
C1 - 7*mC
9-29

Advertisement

Table of Contents
loading

Table of Contents