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). Use SCHORIZ for other modes or when BIOS
- * compatibility is desired.
- *
- * Returns scrolled Number of columns actually scrolled
- * (0 if graphics mode).
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- * Version 3.02 March 20, 1987
- * Corrected handling of SCR_RIGHT case to force computation
- * of to_ads.
- *
- **/
-
- #include <bquery.h>
- #include <bscreen.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;
- ADS from_ads,to_ads;
- char blank;
- 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 ( mode == 7
- || scequip() == IBM_CV
- || device == b_ega)
- 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;
- viads(u_row,u_col + num_cols,&from_ads);
- viads(u_row,u_col, &to_ads);
- }
- else
- { /* Rightward */
- command = 9;
- viads(u_row,u_col, &from_ads);
- viads(u_row,u_col + num_cols,&to_ads);
- }
-
- vidirect(&from_ads,&to_ads,height,width - num_cols,
- columns * 2,0,command | fast_mask);
- }
- else
- dir = SCR_LEFT; /* Shortcut to force */
- /* computation of to_ads. */
-
- /* Now blank out the new columns in the region. */
-
- if (dir == SCR_LEFT)
- { /* Leftward */
- /* Address of first column to */
- viads(u_row,u_col + width - num_cols,&to_ads); /* blank */
- }
- else
- { /* Rightward */
- to_ads.r = from_ads.r; /* from_ads already points to */
- to_ads.s = from_ads.s; /* first column to blank */
- }
- blank = ' ';
- utabsptr(&blank,&from_ads);
- vidirect(&from_ads,&to_ads,height,num_cols,
- columns * 2,attr,
- 3 | fast_mask);
-
- return num_cols;
- }