home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / VIHORIZ.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  3.6 KB  |  122 lines

  1. /**
  2. *
  3. * Name        vihoriz -- Horizontally scroll columns of text on the
  4. *               current display page via direct access to
  5. *               video memory
  6. *
  7. * Synopsis    scrolled = vihoriz(num_cols,attr,
  8. *                    u_row,u_col,l_row,l_col,dir);
  9. *
  10. *        int scrolled      Number of columns actually scrolled
  11. *                  (0 if graphics mode).
  12. *        int num_cols      Number of columns to scroll.    A value
  13. *                  of 0 specifies that all columns
  14. *                  within the region should be scrolled
  15. *                  (thus clearing the region).
  16. *        int attr      This is the attribute to be used on the
  17. *                  vacant columns.  It has the background
  18. *                  attribute in the high order four bits
  19. *                  of the low order byte, and the
  20. *                  foreground in the low order nybble.
  21. *        int u_row,u_col   Upper left corner of region.
  22. *        int l_row,l_col   Lower right corner of region.
  23. *        int dir       Scrolling direction (SCR_LEFT or
  24. *                  SCR_RIGHT).
  25. *
  26. * Description    This function moves columns of characters (with their
  27. *        attributes) within a defined rectangular region to the
  28. *        left or right.    The vacant columns are filled with
  29. *        blanks and a specified attribute.
  30. *
  31. *        This function works only for standard text modes (0, 1,
  32. *        2, 3, and 7).
  33. *
  34. * Returns    scrolled      Number of columns actually scrolled
  35. *                  (0 if graphics mode).
  36. *
  37. * Version    6.00 (C)Copyright Blaise Computing Inc.  1986,1987,1989
  38. *
  39. **/
  40.  
  41. #include <bscreens.h>
  42. #include <bvideo.h>
  43.  
  44. int vihoriz(num_cols,attr,u_row,u_col,l_row,l_col,dir)
  45. int num_cols,attr,u_row,u_col,l_row,l_col,dir;
  46. {
  47.     int  device,mode,last_row,columns,act_page;
  48.     int  height,width;
  49.     int  command;
  50.     char far *pfrom;
  51.     char far *pto;
  52.     const char            blank = ' ';
  53.     const char far * const pblank = ␣
  54.     int  fast_mask;
  55.  
  56.     device = scmode(&mode,&columns,&act_page);
  57.     if (mode > 3 && mode != 7)
  58.     return 0;
  59.     last_row = scrows() - 1;
  60.  
  61.     utbound(u_row,0,last_row)           /* Force reasonable values */
  62.     utbound(l_row,u_row,last_row)
  63.     utbound(u_col,0,columns - 1)
  64.     utbound(l_col,u_col,columns - 1)
  65.     height = l_row - u_row + 1;
  66.     width  = l_col - u_col + 1;
  67.     if (num_cols <= 0 || num_cols > width)
  68.     num_cols = width;          /* Do not scroll more columns   */
  69.                       /* than there are in the region.*/
  70.  
  71.     if (   b_vifast  != 0
  72.     || mode      == 7
  73.     || scequip() == IBM_CV
  74.     || device    == b_ega
  75.     || device    == b_vga
  76.     || device    == b_mcga)
  77.     fast_mask = (int) 0x8000;     /* Need not await retrace       */
  78.     else
  79.     fast_mask = 0x0000;
  80.  
  81.     if (num_cols < width)
  82.     {                      /* We're not blanking the whole */
  83.                       /* region.              */
  84.     if (dir == SCR_LEFT)
  85.     {                  /* Leftward              */
  86.         command = 7;
  87.         pfrom = viptr(u_row,u_col + num_cols);
  88.         pto   = viptr(u_row,u_col        );
  89.     }
  90.     else
  91.     {                  /* Rightward              */
  92.         command = 9;
  93.         pfrom = viptr(u_row,u_col        );
  94.         pto   = viptr(u_row,u_col + num_cols);
  95.     }
  96.  
  97.     vidirect(&pfrom,&pto,height,width - num_cols,
  98.               columns * 2,0,command | fast_mask);
  99.     }
  100.     else
  101.     dir = SCR_LEFT;           /* Shortcut to force          */
  102.                       /* computation of pto.          */
  103.  
  104.     /* Now blank out the new columns in the region.              */
  105.  
  106.     if (dir == SCR_LEFT)
  107.     {                      /* Leftward              */
  108.                       /* Address of first column to   */
  109.     pto = viptr(u_row,u_col + width - num_cols);     /* blank     */
  110.     }
  111.     else
  112.     {                      /* Rightward              */
  113.     pto = pfrom;              /* pfrom already points to      */
  114.                       /* first column to blank          */
  115.     }
  116.     vidirect(&pblank,&pto,height,num_cols,
  117.               columns * 2,attr,
  118.               3 | fast_mask);
  119.  
  120.     return num_cols;
  121. }
  122.