home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name scpscrol -- Vertically scroll lines of text on the current
- * display page via the BIOS
- *
- * Synopsis iret = scpscrol(num_lines,attrib,u_row,u_col,l_row,l_col,
- * dir);
- *
- * int iret Number of lines actually scrolled.
- * int num_lines Number of lines to scroll. A value of
- * 0 specifies that all lines within the
- * rectangle should be scrolled (thus
- * clearing the window)
- * int attrib If the screen is in text mode, 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.
- * If the screen is in graphics mode and
- * the current page is not active, this
- * is the color to use for the scrolled text.
- * If the screen is in graphics mode and
- * the current page is active, this is
- * ignored.
- * int u_row,u_col Upper left corner of area to scroll.
- * int l_row,l_col Lower right corner of area to scroll.
- * int dir Scrolling direction (SCR_UP or SCR_DOWN).
- *
- * Description This function moves lines of characters (with their
- * attributes) up or down within a rectangular area of the
- * current display page. The vacant lines are filled with
- * blanks and a specified attribute.
- *
- * Use VISCROLL for greater speed in text modes on inactive
- * pages.
- *
- * Returns iret Number of lines actually scrolled.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bscreen.h>
-
- int scpscrol(num_lines,attrib,u_row,u_col,l_row,l_col,dir)
- int num_lines,attrib,u_row,u_col,l_row,l_col,dir;
- {
- int mode,columns,apage; /* Values returned by scmode */
- int graphics,last_row;
- char buffer[PC_COLS * 2],*pbuffer;
- int from_row,to_row,step,height,width,i,j;
- int fore,back;
- int save_row,save_col,cursor_was_on,top_scan,bot_scan;
-
- scmode(&mode,&columns,&apage);
- graphics = (mode > 3 && mode != 7);
- last_row = scrows() - 1;
-
- utbound(u_row,0,last_row) /* Force reasonable values */
- utbound(u_row,u_row,last_row)
- height = l_row - u_row + 1;
- if (num_lines <= 0 || num_lines > height)
- num_lines = height; /* Do not scroll more lines */
- /* than there are in the window.*/
- if (apage == b_curpage)
- { /* SCSCROLL is faster */
- scscroll(num_lines,attrib,u_row,u_col,l_row,l_col,dir);
- return num_lines;
- }
-
- utbound(u_col,0,columns - 1)
- utbound(l_col,u_col,columns - 1)
- width = l_col - u_col + 1;
- if (graphics) /* Force attribute for graphics */
- {
- utbound(attrib,0,3)
- }
-
- if (dir == SCR_DOWN)
- { /* Downward */
- to_row = l_row;
- from_row = l_row - num_lines;
- step = -1;
- }
- else
- { /* Upward */
- to_row = u_row;
- from_row = u_row + num_lines;
- step = 1;
- }
-
- /* Move the lines of text */
-
- /* 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 (i = height - num_lines; i; i--)
- {
- scrdbuf(from_row,u_col,width,buffer,CHAR_ATTR);
- if (graphics)
- for (j = 0,pbuffer = buffer + 1; j < width; j++)
- {
- *pbuffer = (char) attrib; /* Set attributes of */
- pbuffer += 2; /* scrolled text */
- }
- scwrbuf(to_row,u_col,width,buffer,0,0,CHAR_ATTR);
- from_row += step;
- to_row += step;
- }
-
- /* Fill the blank lines in */
-
- fore = utlonyb(attrib);
- back = uthinyb(attrib);
- for (i = num_lines; i; i--)
- {
- sccurset(to_row,u_col);
- scattrib(fore,back,(char) ' ',width);
- to_row += step;
- }
-
- 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 num_lines;
- }