home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / C128CPM / SGTOOL11.ARC / LIBC128.ARC / VDCWIN.C < prev   
Encoding:
C/C++ Source or Header  |  1993-07-25  |  2.1 KB  |  90 lines

  1. /*
  2. SG C Tools 1.1
  3.  
  4. (C) 1993 Steve Goldsmith
  5. All Rights Reserved
  6.  
  7. Compiled with HI-TECH C 3.09 (CP/M-80).
  8. */
  9.  
  10. #include <string.h>
  11. #include <hitech.h>
  12. #include <vdc.h>
  13.  
  14. uchar vdcWinChars[] = {32,32,244,231,204,239,250};
  15. uchar vdcShadow = vdcAltChrSet+vdcDarkGray;
  16.  
  17. extern uchar  vdcScrHorz;
  18. extern ushort vdcDispMem;
  19. extern ushort vdcAttrMem;
  20.  
  21. /* clear window given x1, y1, x2, y2 rectangle in current page */
  22.  
  23. void clrwinvdc(uchar X1, uchar Y1, uchar X2, uchar Y2, uchar Ch)
  24. {
  25.   uchar XLen;
  26.   ushort DispOfs;
  27.  
  28.   DispOfs = Y1*vdcScrHorz+vdcDispMem+X1;
  29.   XLen = X2-X1+1;
  30.   for(; Y1 <= Y2; Y1++)
  31.   {
  32.     fillmemvdc(DispOfs,XLen,Ch);
  33.     DispOfs += vdcScrHorz;
  34.   }
  35. }
  36.  
  37. /* clear attr window given x1, y1, x2, y2 rectangle in current page */
  38.  
  39. void clrwinattrvdc(uchar X1, uchar Y1, uchar X2, uchar Y2, uchar Ch)
  40. {
  41.   uchar XLen;
  42.   ushort AttrOfs;
  43.  
  44.   AttrOfs = Y1*vdcScrHorz+vdcAttrMem+X1;
  45.   XLen = X2-X1+1;
  46.   for(; Y1 <= Y2; Y1++)
  47.   {
  48.     fillmemvdc(AttrOfs,XLen,Ch);
  49.     AttrOfs += vdcScrHorz;
  50.   }
  51. }
  52.  
  53. /* draw window given x1, y1, x2, y2 rectangle in current page */
  54.  
  55. void winvdc(uchar X1, uchar Y1, uchar X2, uchar Y2, uchar Attr, char *Title)
  56. {
  57.   char  ChSave;
  58.   uchar Y, InsideLen, TitleLen;
  59.  
  60.   InsideLen = X2-X1-1;
  61.   clrwinvdc(X1,Y1,X2,Y2,vdcWinChars[0]);
  62.   clrwinattrvdc(X1,Y1,X2,Y2,Attr);
  63.   filldspvdc(X1,Y1,InsideLen+2,vdcWinChars[1]);
  64.   if (Title != "")
  65.   {
  66.     TitleLen = strlen(Title);
  67.     if (TitleLen > InsideLen)
  68.     {
  69.       ChSave = Title[InsideLen];
  70.       Title[InsideLen] = 0;
  71.       printstrvdc(X1+1,Y1,Attr,Title);
  72.       Title[InsideLen] = ChSave;
  73.     }
  74.     else
  75.       printstrvdc(((InsideLen-TitleLen) >> 1)+X1+1,Y1,Attr,Title);
  76.   }
  77.   fillattrvdc(X1,Y1,InsideLen+2,Attr | vdcRvsVid);
  78.   filldspvdc(X1,Y2,1,vdcWinChars[4]);
  79.   filldspvdc(X1+1,Y2,InsideLen,vdcWinChars[5]);
  80.   filldspvdc(X2,Y2,1,vdcWinChars[6]);
  81.   fillattrvdc(X1+1,Y2+1,InsideLen+2,vdcShadow);
  82.   fillattrvdc(X2+1,Y2,1,vdcShadow);
  83.   for(Y1++, Y2--, Y = Y1; Y <= Y2; Y++)
  84.   {
  85.     filldspvdc(X1,Y,1,vdcWinChars[2]);
  86.     filldspvdc(X2,Y,1,vdcWinChars[3]);
  87.     fillattrvdc(X2+1,Y,1,vdcShadow);
  88.   }
  89. }
  90.