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

  1. /**
  2. *
  3. * Name        scatrect -- Change attributes on a rectangle via BIOS
  4. *
  5. * Synopsis    num_writ = scatrect(u_row,u_col,l_row,l_col,fore,back);
  6. *
  7. *        int  num_writ    Number of character cells actually changed
  8. *        int  u_row    Top row to write (0 = top of screen)
  9. *        int  u_col    Leftmost column to write (0 = left edge)
  10. *        int  l_row    Bottom row to write
  11. *        int  l_col    Rightmost column to write
  12. *        int  fore,back    Foreground and background attributes
  13. *
  14. * Description    This function fills a rectangular area on the current
  15. *        display page with a given attribute without affecting
  16. *        the characters already displayed there.  The cursor is
  17. *        not moved.
  18. *
  19. *        The upper left corner of the window is (u_row,u_col),
  20. *        where (0,0) represents the upper left corner of the
  21. *        entire screen.    The lower right corner of the window is
  22. *        (l_row,l_col), where (24,79) is the lower right corner
  23. *        of an 80-by-25 screen.
  24. *
  25. *        The returned value reports the number of "character
  26. *        cells" written, where "character cells" means the number
  27. *        of physical spaces on the screen.
  28. *
  29. *        Use VIATRECT for greater speed in text modes.
  30. *
  31. * Returns    num_writ    Number of character cells changed
  32. *
  33. * Version    3.0  (C)Copyright Blaise Computing Inc. 1986
  34. *
  35. **/
  36.  
  37. #include <bscreen.h>
  38.  
  39. int scatrect(u_row,u_col,l_row,l_col,fore,back)
  40. int u_row,u_col,l_row,l_col;
  41. int fore,back;
  42. {
  43.     int      scr_mode,last_row,columns,act_page;
  44.     register int row,col;
  45.     int      save_row,save_col;
  46.     int      old_fore,old_back;
  47.     int      cursor_was_on,top_scan,bot_scan;
  48.  
  49.     scmode(&scr_mode,&columns,&act_page);
  50.     last_row = scrows() - 1;
  51.  
  52.     utbound(u_row,0,last_row)           /* Force reasonable values */
  53.     utbound(l_row,u_row,last_row)
  54.     utbound(u_col,0,columns - 1)
  55.     utbound(l_col,u_col,columns - 1)
  56.  
  57.                       /* Save cursor size & position. */
  58.     if (cursor_was_on = !sccurst(&save_row,&save_col,&top_scan,&bot_scan))
  59.                       /* Turn the cursor off          */
  60.     scpgcur(1,top_scan,bot_scan,CUR_NO_ADJUST);
  61.  
  62.     for (row = u_row; row <= l_row; row++)
  63.     for (col = u_col; col <= l_col; col++)
  64.     {
  65.         sccurset(row,col);
  66.                       /* Read & write the character   */
  67.         scattrib(fore,back,scread(&old_fore,&old_back),1);
  68.     }
  69.  
  70.     sccurset(save_row,save_col);      /* Restore cursor position      */
  71.     if (cursor_was_on)              /* Restore cursor size.          */
  72.     scpgcur(0,top_scan,bot_scan,CUR_NO_ADJUST);
  73.  
  74.     return (l_row - u_row + 1) * (l_col - u_col + 1);  /* Area filled */
  75. }
  76.