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

  1. /**
  2. *
  3. * Name        viatrect -- Change attributes on a rectangle
  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).
  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. * Returns    num_writ    Number of character cells changed,
  34. *                or 0 if screen is in a graphics mode.
  35. *
  36. * Version    6.00 (C)Copyright Blaise Computing Inc.  1986,1987,1989
  37. *
  38. **/
  39.  
  40. #include <bscreens.h>
  41. #include <bvideo.h>
  42.  
  43. int viatrect(u_row,u_col,l_row,l_col,fore,back)
  44. int u_row,u_col,l_row,l_col;
  45. int fore,back;
  46. {
  47.     int device,mode,act_page,last_row,columns;
  48.     int height,width;
  49.     int command;
  50.     char far *pscreen;
  51.  
  52.     device = scmode(&mode,&columns,&act_page);
  53.     if (mode > 3 && mode != 7)
  54.     return 0;
  55.     last_row = scrows() - 1;
  56.  
  57.     utbound(u_row,0,last_row)           /* Force reasonable values */
  58.     utbound(l_row,u_row,last_row)
  59.     utbound(u_col,0,columns - 1)
  60.     utbound(l_col,u_col,columns - 1)
  61.     height = l_row - u_row + 1;
  62.     width  = l_col - u_col + 1;
  63.  
  64.     pscreen = viptr(u_row,u_col);
  65.  
  66.     command = 4;
  67.     if (   b_vifast  != 0
  68.     || mode      == 7
  69.     || scequip() == IBM_CV
  70.     || device    == b_ega
  71.     || device    == b_vga
  72.     || device    == b_mcga)
  73.     command |= 0x8000;          /* Need not await retrace       */
  74.  
  75.     vidirect(&pscreen,&pscreen,height,width,columns * 2,
  76.           utnybbyt(back,fore),command);
  77.     return height * width;
  78. }
  79.