home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name vihoriz -- Horizontally scroll columns of text on the
- * current display page via direct access to
- * video memory
- *
- * Synopsis scrolled = vihoriz(num_cols,attr,
- * u_row,u_col,l_row,l_col,dir);
- *
- * int scrolled Number of columns actually scrolled
- * (0 if graphics mode).
- * int num_cols Number of columns to scroll. A value
- * of 0 specifies that all columns
- * within the region should be scrolled
- * (thus clearing the region).
- * int attr This is the attribute to be used on the
- * vacant columns. It has the background
- * attribute in the high order four bits
- * of the low order byte, and the
- * foreground in the low order nybble.
- * int u_row,u_col Upper left corner of region.
- * int l_row,l_col Lower right corner of region.
- * int dir Scrolling direction (SCR_LEFT or
- * SCR_RIGHT).
- *
- * Description This function moves columns of characters (with their
- * attributes) within a defined rectangular region to the
- * left or right. The vacant columns are filled with
- * blanks and a specified attribute.
- *
- * This function works only for standard text modes (0, 1,
- * 2, 3, and 7).
- *
- * Returns scrolled Number of columns actually scrolled
- * (0 if graphics mode).
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1986,1987,1989
- *
- **/
-
- #include <bscreens.h>
- #include <bvideo.h>
-
- int vihoriz(num_cols,attr,u_row,u_col,l_row,l_col,dir)
- int num_cols,attr,u_row,u_col,l_row,l_col,dir;
- {
- int device,mode,last_row,columns,act_page;
- int height,width;
- int command;
- char far *pfrom;
- char far *pto;
- const char blank = ' ';
- const char far * const pblank = ␣
- int fast_mask;
-
- 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;
- if (num_cols <= 0 || num_cols > width)
- num_cols = width; /* Do not scroll more columns */
- /* than there are in the region.*/
-
- if ( b_vifast != 0
- || mode == 7
- || scequip() == IBM_CV
- || device == b_ega
- || device == b_vga
- || device == b_mcga)
- fast_mask = (int) 0x8000; /* Need not await retrace */
- else
- fast_mask = 0x0000;
-
- if (num_cols < width)
- { /* We're not blanking the whole */
- /* region. */
- if (dir == SCR_LEFT)
- { /* Leftward */
- command = 7;
- pfrom = viptr(u_row,u_col + num_cols);
- pto = viptr(u_row,u_col );
- }
- else
- { /* Rightward */
- command = 9;
- pfrom = viptr(u_row,u_col );
- pto = viptr(u_row,u_col + num_cols);
- }
-
- vidirect(&pfrom,&pto,height,width - num_cols,
- columns * 2,0,command | fast_mask);
- }
- else
- dir = SCR_LEFT; /* Shortcut to force */
- /* computation of pto. */
-
- /* Now blank out the new columns in the region. */
-
- if (dir == SCR_LEFT)
- { /* Leftward */
- /* Address of first column to */
- pto = viptr(u_row,u_col + width - num_cols); /* blank */
- }
- else
- { /* Rightward */
- pto = pfrom; /* pfrom already points to */
- /* first column to blank */
- }
- vidirect(&pblank,&pto,height,num_cols,
- columns * 2,attr,
- 3 | fast_mask);
-
- return num_cols;
- }