home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name viwrsect -- Write rectangular region directly to
- * the current display page
- *
- * Synopsis num_writ = viwrsect(u_row,u_col,l_row,l_col,
- * buffer,gap,fore,back,option);
- *
- * int num_writ Number of character cells actually
- * written (0 if graphics mode)
- * int u_row Top row to write (0 = top of screen)
- * int u_col Leftmost column to write (0 = left edge)
- * int l_row Bottom row to write
- * int l_col Rightmost column to write
- * const char *buffer
- * Space containing the data to write
- * unsigned gap Gap (expressed in character cells)
- * between successive rows in the buffer.
- * int fore If CHARS_ONLY is specified, a value
- * between 0 and 15 specifies a new
- * foreground attribute,
- * unless both fore and back are -1, in which
- * case existing attributes are preserved.
- * int back If CHARS_ONLY is specified, a value
- * between 0 and 15 specifies a new
- * background attribute,
- * unless both fore and back are -1, in which
- * case existing attributes are preserved.
- * int option One bit in the option value tells VIWRSECT
- * how the buffer is constructed. The two
- * possible values for this bit are:
- *
- * Value Meaning
- * ----------- ------------------------------------
- * CHARS_ONLY Buffer contains characters only.
- * The values of fore and back are used
- * as attributes, unless they are both -1,
- * in which case the existing screen
- * attributes are left unchanged.
- * CHAR_ATTR Buffer contains (char,attr) pairs.
- * The values of fore and back are ignored.
- *
- * Description This function fills a rectangular region on the current
- * display page with characters from a buffer with or
- * without their corresponding video attributes. The data
- * is written row by row. The cursor is not moved.
- *
- * In contrast to VIWRRECT, this function can handle a
- * section of a buffer that represents a larger rectangular
- * region. For example, you can represent a rectangular
- * region of characters by a contiguous buffer of bytes;
- * this function can write a rectangular subsection of the
- * buffer to the screen. The "gap" argument indicates the
- * number of character cells in the buffer to skip between
- * rows written to the screen.
- *
- * This function works only for standard text modes (0, 1,
- * 2, 3, and 7).
- *
- * The upper left corner of the region is (u_row,u_col),
- * where (0,0) represents the upper left corner of the
- * entire screen. The lower right corner of the region is
- * (l_row,l_col), where (24,79) is the lower right corner
- * of an 80-by-25 screen.
- *
- * The returned value reports the number of "character
- * cells" written, where "character cells" means the number
- * of physical spaces on the screen. (If CHAR_ATTR is
- * specified, twice this number of bytes will be used from
- * the buffer.)
- *
- * Be aware that this function does NOT recognize NULs
- * ('\0') or any other special characters.
- *
- * Returns num_writ Number of character cells written
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1986,1987,1989
- *
- **/
-
- #include <bscreens.h>
- #include <bvideo.h>
-
- int viwrsect(u_row,u_col,l_row,l_col,buffer,gap,fore,back,option)
- int u_row,u_col,l_row,l_col;
- const char *buffer;
- unsigned gap;
- int fore,back,option;
- {
- int device,mode,act_page,last_row,columns;
- int height,width;
- int command;
- const char far *pbuf;
- char far *pscreen;
-
- device = scmode(&mode,&columns,&act_page);
- if (mode > 3 && mode != 7)
- return 0;
- last_row = scrows() - 1;
-
- utbound(u_row,0,last_row) /* Force reasonable values */
- utbound(l_row,u_row,last_row)
- utbound(u_col,0,columns - 1)
- utbound(l_col,u_col,columns - 1)
- height = l_row - u_row + 1;
- width = l_col - u_col + 1;
-
- pbuf = buffer;
- pscreen = viptr(u_row,u_col);
-
- if (option & CHAR_ATTR)
- command = 14; /* (char,attr) pairs */
- else
- if (fore == -1 && back == -1)
- command = 13; /* Preserve attributes */
- else
- command = 15; /* Use fore and back as */
- /* constant attributes. */
-
- if ( b_vifast != 0
- || mode == 7
- || scequip() == IBM_CV
- || device == b_ega
- || device == b_vga
- || device == b_mcga)
- command |= 0x8000; /* Need not await retrace */
-
- vidirec0(&pbuf,&pscreen,height,width,columns * 2,
- utnybbyt(back,fore),command,gap);
- return height * width;
- }