home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 287_01 / frame.c < prev    next >
Text File  |  1989-05-25  |  1KB  |  56 lines

  1. #include <stdio.h>
  2. #include <gds.h>
  3. #include <prtfont.h>
  4.  
  5. #define ERROR (-1)
  6. #define OK 0
  7.  
  8. CreateFrame(horizontal,vertical)
  9. int horizontal,vertical;
  10. {
  11.     void far *farcalloc();
  12.     int ff,width;
  13.     register struct fdesc *fptr;
  14.  
  15.     if ((ff=freeframe()) == 0) {
  16.         graderror(6,7);
  17.     }
  18.     fptr = & FTABLE[ff];
  19.     width=(horizontal + 15) >> 4;
  20.     if ((fptr->faddr=
  21.        nor_ptr((int far *) farcalloc(((long) width)*vertical,2L)))
  22.                           == (int far *) NULL) {
  23.         graderror(6,8,horizontal,vertical);
  24.     }
  25.     fptr->forgx=fptr->forgy=fptr->fwinx1=fptr->fwiny1=0;
  26.     fptr->status=USED;
  27.     fptr->ln_byte=width << 1;
  28.     fptr->fwinx2=fptr->horz=(width << 4) - 1;
  29.     fptr->fwiny2=fptr->vert=vertical - 1;
  30.     return(ff);
  31. }
  32.  
  33. freeframe()
  34. {
  35.     register int loop;
  36.  
  37.     for(loop=1; loop < NFRAME ; loop++)
  38.         if (FTABLE[loop].status == NOT_USED)
  39.             return(loop);
  40.     return(0);
  41. }
  42.  
  43. int RemvFrame(ff)
  44. int ff;
  45. {
  46.     register struct fdesc *fptr;
  47.  
  48.     if ((fptr=&FTABLE[ff])->status == NOT_USED) return(ERROR);
  49.     if (fptr->status == PERMANENT) return(OK);
  50.     if (ff == CUR_FRAME) CUR_FRAME=0;
  51.     fptr->status=NOT_USED;
  52.     farfree(fptr->faddr);
  53.     return(OK);
  54. }
  55.  
  56.