home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name viscroll -- Vertically scroll lines of text on the current
- * display page by direct memory access.
- *
- * Synopsis iret = viscroll(num_lines,attr,u_row,u_col,l_row,l_col,
- * dir);
- *
- * int iret Number of lines actually scrolled
- * (0 if graphics mode).
- * int num_lines Number of lines to scroll. A value of 0
- * specifies that all lines within the
- * region should be scrolled (thus clearing
- * the region)
- * int attr This is the attribute to be used on the
- * vacant lines. 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_UP or SCR_DOWN).
- *
- * Description This function moves lines of characters (with their
- * attributes) up or down within a defined rectangular
- * region. The vacant lines are filled with blanks and a
- * specified attribute.
- *
- * This function works only for standard text modes (0, 1,
- * 2, 3, and 7). Use SCPSCROL for other modes or when BIOS
- * compatibility is desirable.
- *
- * Returns iret Number of lines 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_DOWN case to force computation
- * of to_ads.
- *
- **/
-
- #include <bquery.h>
- #include <bscreen.h>
- #include <bvideo.h>
-
- int viscroll(num_lines,attr,u_row,u_col,l_row,l_col,dir)
- int num_lines,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_lines <= 0 || num_lines > height)
- num_lines = height; /* Do not scroll more lines */
- /* 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_lines < height)
- { /* We're not blanking the whole */
- /* region. */
- if (dir == SCR_DOWN)
- { /* Downward */
- command = 9;
- viads(u_row, u_col,&from_ads);
- viads(u_row + num_lines,u_col,&to_ads);
- }
- else
- { /* Upward */
- command = 7;
- viads(u_row + num_lines,u_col,&from_ads);
- viads(u_row, u_col,&to_ads);
- }
-
- vidirect(&from_ads,&to_ads,height - num_lines,width,
- columns * 2,0,command | fast_mask);
- }
- else
- dir = SCR_UP; /* Shortcut to force */
- /* computation of to_ads. */
-
- /* Now blank out the new lines in the region. */
-
- if (dir == SCR_DOWN)
- {
- to_ads.r = from_ads.r; /* from_ads already points to */
- to_ads.s = from_ads.s; /* first line to blank */
- }
- else
- {
- /* Address of first line to */
- viads(u_row + height - num_lines,u_col,&to_ads); /* blank */
- }
- blank = ' ';
- utabsptr(&blank,&from_ads);
- vidirect(&from_ads,&to_ads,num_lines,width,
- columns * 2,attr,
- 3 | fast_mask);
-
- return num_lines;
- }