int
draw_vert_line (int x)
{
unsigned char buf[SCROLL_Y_DIM]; /* buffer for graphical image of line */
unsigned char* addr; /* address of first pixel in build */
/* buffer (without plane offset) */
int p_off; /* offset of plane of first pixel */
int i; /* loop index over pixels */
/* Check whether requested line falls in the logical view window. */
if (x < 0 || x >= SCROLL_X_DIM)
return -1;
/* Adjust x to the logical col value. */
x += show_x;
/* Get the image of the line. */
(*vert_line_fn) (x, show_y, buf);
/* Calculate starting address in build buffer. */
addr = img3 + show_y * SCROLL_X_WIDTH + (x >> 2);
/* Calculate plane offset of first pixel. */
p_off = (3 - (show_x & 3));
/* Copy image data into appropriate planes in build buffer. */
for (i = 0; i < SCROLL_Y_DIM; i++) {
addr[p_off * SCROLL_SIZE] = buf[i];
if (--p_off < 0) {
p_off = 3;
addr++;
}
}
/* Return success. */
return 0;
}
/*
* draw_horiz_line
* DESCRIPTION: Draw a horizontal map line into the build buffer. The
* line should be offset from the top of the logical view
* window screen by the given number of pixels.
* INPUTS: y -- the 0-based pixel row number of the line to be drawn
* within the logical view window (equivalent to the number
* of pixels from the top pixel to the line to be drawn)
* OUTPUTS: none
* RETURN VALUE: Returns 0 on success. If y is outside of the valid
* SCROLL range, the function returns -1.
* SIDE EFFECTS: draws into the build buffer
*/
int
draw_horiz_line (int y)
{
unsigned char buf[SCROLL_X_DIM]; /* buffer for graphical image of line */
unsigned char* addr; /* address of first pixel in build */
/* buffer (without plane offset) */
int p_off; /* offset of plane of first pixel */
int i; /* loop index over pixels */
/* Check whether requested line falls in the logical view window. */
if (y < 0 || y >= SCROLL_Y_DIM)
return -1;
/* Adjust y to the logical row value. */
y += show_y;
/* Get the image of the line. */
(*horiz_line_fn) (show_x, y, buf);
/* Calculate starting address in build buffer. */
addr = img3 + (show_x >> 2) + y * SCROLL_X_WIDTH;
/* Calculate plane offset of first pixel. */
p_off = (3 - (show_x & 3));
/* Copy image data into appropriate planes in build buffer. */
for (i = 0; i < SCROLL_X_DIM; i++) {
addr[p_off * SCROLL_SIZE] = buf[i];
if (--p_off < 0) {
p_off = 3;
addr++;
}
}
/* Return success. */
return 0;
}