home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name virdsect -- Read contents of rectangular region directly
- * from the current display page
- *
- * Synopsis num_read = virdsect(u_row,u_col,l_row,l_col,buffer,gap,
- * option);
- *
- * int num_read Number of spaces actually read,
- * or 0 if error.
- * int u_row Top row to read (0 = top of screen)
- * int u_col Leftmost column to read (0 = left edge)
- * int l_row Bottom row to read
- * int l_col Rightmost column to read
- * char *buffer Space in which to put the data
- * unsigned gap Gap (expressed in character cells)
- * between successive rows in the buffer.
- * int option One bit in the option value tells
- * VIRDSECT how the buffer is constructed.
- * The two possible values for this bit are:
- *
- * Value Meaning
- * ----------- ------------------------------------
- * CHARS_ONLY Buffer contains characters only.
- * CHAR_ATTR Buffer contains (char,attr) pairs.
- *
- * Description This function reads the contents of a rectangular region
- * directly from the current display page with or without
- * the corresponding video attributes. The cursor is not
- * moved. The data is read row by row.
- *
- * In contrast to VIRDRECT, 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 read a rectangular subsection of the
- * buffer from the screen. The "gap" argument indicates
- * the number of character cells in the buffer to skip
- * between rows read from 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.
- *
- * Be aware that this function does NOT add a trailing NUL
- * ('\0') at the end of the buffer, and that any 8-bit
- * character may be present in the buffer, depending on
- * what is in video memory.
- *
- * Returns num_read Number of character cells read,
- * or 0 if error.
- * *buffer Characters read from the display page
- * (perhaps with their attributes)
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1986,1987,1989
- *
- **/
-
- #include <bscreens.h>
- #include <bvideo.h>
-
- int virdsect(u_row,u_col,l_row,l_col,buffer,gap,option)
- int u_row,u_col,l_row,l_col;
- char *buffer;
- unsigned gap;
- int option;
- {
- int device,mode,act_page,last_row,columns;
- int height,width;
- int command;
- char far *pbuf;
- const 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);
-
- command = ((option & CHAR_ATTR) ? 17 : 16);
- 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(&pscreen,&pbuf,height,width,columns * 2,
- 0,command,gap);
- return height * width;
- }