home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 5.ddi / C / VIHORIZ.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-04-13  |  3.7 KB  |  125 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).  Use SCHORIZ for other modes or when BIOS
  33. *        compatibility is desired.
  34. *
  35. * Returns    scrolled      Number of columns actually scrolled
  36. *                  (0 if graphics mode).
  37. *
  38. * Version    3.0  (C)Copyright Blaise Computing Inc. 1986
  39. *
  40. * Version    3.02 March 20, 1987
  41. *        Corrected handling of SCR_RIGHT case to force computation
  42. *            of to_ads.
  43. *
  44. **/
  45.  
  46. #include <bquery.h>
  47. #include <bscreen.h>
  48. #include <bvideo.h>
  49.  
  50. int vihoriz(num_cols,attr,u_row,u_col,l_row,l_col,dir)
  51. int num_cols,attr,u_row,u_col,l_row,l_col,dir;
  52. {
  53.     int  device,mode,last_row,columns,act_page;
  54.     int  height,width;
  55.     int  command;
  56.     ADS  from_ads,to_ads;
  57.     char blank;
  58.     int  fast_mask;
  59.  
  60.     device = scmode(&mode,&columns,&act_page);
  61.     if (mode > 3 && mode != 7)
  62.     return 0;
  63.     last_row = scrows() - 1;
  64.  
  65.     utbound(u_row,0,last_row)           /* Force reasonable values */
  66.     utbound(l_row,u_row,last_row)
  67.     utbound(u_col,0,columns - 1)
  68.     utbound(l_col,u_col,columns - 1)
  69.     height = l_row - u_row + 1;
  70.     width  = l_col - u_col + 1;
  71.     if (num_cols <= 0 || num_cols > width)
  72.     num_cols = width;          /* Do not scroll more columns   */
  73.                       /* than there are in the region.*/
  74.  
  75.     if (   mode      == 7
  76.     || scequip() == IBM_CV
  77.     || device    == b_ega)
  78.     fast_mask = (int) 0x8000;     /* Need not await retrace       */
  79.     else
  80.     fast_mask = 0x0000;
  81.  
  82.     if (num_cols < width)
  83.     {                      /* We're not blanking the whole */
  84.                       /* region.              */
  85.     if (dir == SCR_LEFT)
  86.     {                  /* Leftward              */
  87.         command = 7;
  88.         viads(u_row,u_col + num_cols,&from_ads);
  89.         viads(u_row,u_col,         &to_ads);
  90.     }
  91.     else
  92.     {                  /* Rightward              */
  93.         command = 9;
  94.         viads(u_row,u_col,         &from_ads);
  95.         viads(u_row,u_col + num_cols,&to_ads);
  96.     }
  97.  
  98.     vidirect(&from_ads,&to_ads,height,width - num_cols,
  99.               columns * 2,0,command | fast_mask);
  100.     }
  101.     else
  102.     dir = SCR_LEFT;           /* Shortcut to force          */
  103.                       /* computation of to_ads.       */
  104.  
  105.     /* Now blank out the new columns in the region.              */
  106.  
  107.     if (dir == SCR_LEFT)
  108.     {                      /* Leftward              */
  109.                       /* Address of first column to   */
  110.     viads(u_row,u_col + width - num_cols,&to_ads);     /* blank     */
  111.     }
  112.     else
  113.     {                      /* Rightward              */
  114.     to_ads.r = from_ads.r;          /* from_ads already points to   */
  115.     to_ads.s = from_ads.s;          /* first column to blank          */
  116.     }
  117.     blank = ' ';
  118.     utabsptr(&blank,&from_ads);
  119.     vidirect(&from_ads,&to_ads,height,num_cols,
  120.               columns * 2,attr,
  121.               3 | fast_mask);
  122.  
  123.     return num_cols;
  124. }
  125.