home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / croutes.zip / FRAME.C < prev    next >
Text File  |  1984-05-11  |  2KB  |  69 lines

  1. /*                             *** frame.c ***                       */
  2. /*                                                                   */
  3. /* IBM-PC microsoft "C" under PC-DOS                                 */
  4. /*                                                                   */
  5. /* Function to draw a box given the upper left corner and the lower  */
  6. /* right corner.  Uses the extended character set - graphics board   */
  7. /* not needed.  Uses direct BIOS calls.  Returns a 0 if successful   */
  8. /* or a -1 if invalid parameters.                                    */
  9. /*                                                                   */
  10. /* *** NOTE ***                                                      */
  11. /* The upper left corner of the screen is 0,0 and the bottom right   */
  12. /* corner is 24,79.                                                  */
  13. /*                                                                   */
  14. /* Written by L. Cuthbertson, May 1984.                              */
  15. /*                                                                   */
  16. /*********************************************************************/
  17. /*                                                                   */
  18. int frame(ulrow,ulcol,lrrow,lrcol)
  19. int ulrow,ulcol,lrrow,lrcol;
  20. {
  21.     static int horbar = 0xC4, verbar = 0xB3;
  22.     static int ulcorn = 0xDA, urcorn = 0xBF;
  23.     static int llcorn = 0xC0, lrcorn = 0xD9;
  24.     int count,irow;
  25.  
  26.     /* error checking */
  27.     if (ulrow < 0 || ulrow > 24) return(-1);
  28.     if (ulcol < 0 || ulcol > 79) return(-1);
  29.     if (lrrow < 0 || lrrow > 24) return(-1);
  30.     if (lrcol < 0 || lrcol > 79) return(-1);
  31.     if (lrrow < ulrow) return(-1);
  32.     if (lrcol < ulcol) return(-1);
  33.  
  34.     /* do top line first */
  35.     biosset(ulrow,ulcol);
  36.     bioswc(ulcorn,1);
  37.     count = lrcol-ulcol-1;
  38.     if (count > 0) {
  39.         biosset(ulrow,ulcol+1);
  40.         bioswc(horbar,count);
  41.     }
  42.     biosset(ulrow,lrcol);
  43.     bioswc(urcorn,1);
  44.  
  45.     /* do both sides at once */
  46.     irow = ulrow + 1;
  47.     while (irow < lrrow) {
  48.         biosset(irow,ulcol);
  49.         bioswc(verbar,1);
  50.         biosset(irow,lrcol);
  51.         bioswc(verbar,1);
  52.         irow++;
  53.     }
  54.  
  55.     /* do bottom line */
  56.     biosset(lrrow,ulcol);
  57.     bioswc(llcorn,1);
  58.     count = lrcol-ulcol-1;
  59.     if (count > 0) {
  60.         biosset(lrrow,ulcol+1);
  61.         bioswc(horbar,count);
  62.     }
  63.     biosset(lrrow,lrcol);
  64.     bioswc(lrcorn,1);
  65.  
  66.     /* done */
  67.     return(0);
  68. }
  69.