home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 5.ddi / C / VIATRECT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  2.4 KB  |  79 lines

  1. /**
  2. *
  3. * Name        viatrect -- Change attributes on a rectangle via BIOS
  4. *
  5. * Synopsis    num_writ = viatrect(u_row,u_col,l_row,l_col,fore,back);
  6. *
  7. *        int  num_writ    Number of character cells actually changed,
  8. *                or 0 if screen is not in a text mode.
  9. *        int  u_row    Top row to write (0 = top of screen)
  10. *        int  u_col    Leftmost column to write (0 = left edge)
  11. *        int  l_row    Bottom row to write
  12. *        int  l_col    Rightmost column to write
  13. *        int  fore,back    Foreground and background attributes
  14. *
  15. * Description    This function fills a rectangular area on the current
  16. *        display page with a given attribute without affecting
  17. *        the characters already displayed there.  The cursor is
  18. *        not moved.
  19. *
  20. *        This function works only for standard text modes (0, 1,
  21. *        2, 3, and 7).  Use SCATRECT for other modes.
  22. *
  23. *        The upper left corner of the region is (u_row,u_col),
  24. *        where (0,0) represents the upper left corner of the
  25. *        entire screen.    The lower right corner of the region is
  26. *        (l_row,l_col), where (24,79) is the lower right corner
  27. *        of an 80-by-25 screen.
  28. *
  29. *        The returned value reports the number of "character
  30. *        cells" written, where "character cells" means the number
  31. *        of physical spaces on the screen.
  32. *
  33. *        Use SCATRECT if BIOS compatibility is desired.
  34. *
  35. * Returns    num_writ    Number of character cells changed,
  36. *                or 0 if screen is in a graphics mode.
  37. *
  38. * Version    3.0  (C)Copyright Blaise Computing Inc. 1986
  39. *
  40. **/
  41.  
  42. #include <bquery.h>
  43. #include <bscreen.h>
  44. #include <bvideo.h>
  45.  
  46. int viatrect(u_row,u_col,l_row,l_col,fore,back)
  47. int u_row,u_col,l_row,l_col;
  48. int fore,back;
  49. {
  50.     int device,mode,last_row,columns,act_page;
  51.     int height,width;
  52.     int command;
  53.     ADS scn_ads;
  54.  
  55.     device = scmode(&mode,&columns,&act_page);
  56.     if (mode > 3 && mode != 7)
  57.     return 0;
  58.     last_row = scrows() - 1;
  59.  
  60.     utbound(u_row,0,last_row)           /* Force reasonable values */
  61.     utbound(l_row,u_row,last_row)
  62.     utbound(u_col,0,columns - 1)
  63.     utbound(l_col,u_col,columns - 1)
  64.     height = l_row - u_row + 1;
  65.     width  = l_col - u_col + 1;
  66.  
  67.     viads(u_row,u_col,&scn_ads);
  68.  
  69.     command = 4;
  70.     if (   mode      == 7
  71.     || scequip() == IBM_CV
  72.     || device    == b_ega)
  73.     command |= 0x8000;          /* Need not await retrace       */
  74.  
  75.     vidirect(&scn_ads,&scn_ads,height,width,columns * 2,
  76.           utnybbyt(back,fore),command);
  77.     return height * width;
  78. }
  79.