home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name scatrect -- Change attributes on a rectangle via BIOS
- *
- * Synopsis num_writ = scatrect(u_row,u_col,l_row,l_col,fore,back);
- *
- * int num_writ Number of character cells actually changed
- * 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
- * int fore,back Foreground and background attributes
- *
- * Description This function fills a rectangular area on the current
- * display page with a given attribute without affecting
- * the characters already displayed there. The cursor is
- * not moved.
- *
- * The upper left corner of the window is (u_row,u_col),
- * where (0,0) represents the upper left corner of the
- * entire screen. The lower right corner of the window 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.
- *
- * Use VIATRECT for greater speed in text modes.
- *
- * Returns num_writ Number of character cells changed
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bscreen.h>
-
- int scatrect(u_row,u_col,l_row,l_col,fore,back)
- int u_row,u_col,l_row,l_col;
- int fore,back;
- {
- int scr_mode,last_row,columns,act_page;
- register int row,col;
- int save_row,save_col;
- int old_fore,old_back;
- int cursor_was_on,top_scan,bot_scan;
-
- scmode(&scr_mode,&columns,&act_page);
- 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)
-
- /* Save cursor size & position. */
- if (cursor_was_on = !sccurst(&save_row,&save_col,&top_scan,&bot_scan))
- /* Turn the cursor off */
- scpgcur(1,top_scan,bot_scan,CUR_NO_ADJUST);
-
- for (row = u_row; row <= l_row; row++)
- for (col = u_col; col <= l_col; col++)
- {
- sccurset(row,col);
- /* Read & write the character */
- scattrib(fore,back,scread(&old_fore,&old_back),1);
- }
-
- sccurset(save_row,save_col); /* Restore cursor position */
- if (cursor_was_on) /* Restore cursor size. */
- scpgcur(0,top_scan,bot_scan,CUR_NO_ADJUST);
-
- return (l_row - u_row + 1) * (l_col - u_col + 1); /* Area filled */
- }