Table 6-3: BLTCON1 Code Bits for Octant Line Drawing BLTCON1 Code Bits Octant # 0 1 1 2 1 1 1 3 1 0 1 4 0 1 0 5 0 0 0 6 1 0 0 7 We initialize BLTCON1 bits 4 through 2 according to the above Table. Now, we introduce the variables dx and dy, and set them to the absolute values of the difference between the x coordinates and the y coordinates of the endpoints of the line, respectively. dx = abs (x2 - x1) dy = abs (y2 - y1) Now, we rearrange them if necessary so dx is greater than dy. if (dx { temp = dx; dx = dy; dy = temp; } Alternately, set dx and dy as follows:
dx = max(abs(x2 - x1), abs(y2 - y1)) ; dy = min(abs(x2 - x1), abs(y2 - y1)) ; These calculations have the effect of "normalizing" our line into octant 0; since we have already informed the blitter of the real octant to use, it has no difficulty drawing the line. We initialize the A pointer register to 4 * dy - 2 * dx. If this value is negative, we set the sign bit (SIGNFLAG in BLTCONl), otherwise we clear it. We set the A modulo register to 4 * (dy - dx) and the B modulo register to 4 * dy. The A data register should be preloaded with $8000. Both word masks should be set to $ The A shift value should be set to the x coordinate of the first point (x1) modulo 15.
The B data register should be initialized with the line texture pattern, if any, or $FFFF for a solid line. The B shift value should be set to the bit number at which to start the line texture (zero means the last significant bit.) - Blitter Hardware 185 -