home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / S / SGTOOL12.ARC / EXAMPLES.ARC / WINDOWS.C < prev   
C/C++ Source or Header  |  1993-08-09  |  2KB  |  74 lines

  1. /*
  2. SG C Tools 1.2
  3.  
  4. (C) 1993 Steve Goldsmith
  5. All Rights Reserved
  6.  
  7. Example of using high speed scrolling pop-up windows.
  8.  
  9. Compiled with HI-TECH C 3.09 (CP/M-80).
  10.  
  11. To compile with HI-TECH C and SG C Tools source on same disk use:
  12. C WINDOWS.C -LC128
  13. */
  14.  
  15. #include <stdlib.h>
  16. #include <hitech.h>
  17. #include <conio.h>
  18. #include <vdc.h>
  19.  
  20. #define appClrScrCh 32
  21.  
  22. void drawwindows(void);
  23. void scrollwindow(uchar X1, uchar Y1, uchar X2, uchar Y2);
  24.  
  25. char appScrlStr1[] = {
  26. "Use scrollupvdc() to scroll windows!"
  27. };
  28.  
  29. main()
  30. {
  31.   srand(9);
  32.   savevdc();                             /* save vdc regs */
  33.   mapvdc();
  34.   clrscrvdc(appClrScrCh);                /* clear screen */
  35.   clrattrvdc(vdcAltChrSet+vdcLightBlue); /* clear attributes */
  36.   setcursorvdc(0,0,vdcCurNone);          /* turn cursor off */
  37.   outvdc(vdcFgBgColor,vdcBlack);         /* set new screen color */
  38.   clrattrvdc(vdcAltChrSet+vdcLightBlue);
  39.   clrscrvdc(137);
  40.   drawwindows();                    /* draw random windows */
  41.   scrollwindow(20,6,59,16);         /* scroll 3 different size windows */
  42.   scrollwindow(10,4,69,18);
  43.   scrollwindow(1,1,77,22);
  44.   while (getch() != 0x0D);          /* wait for return press */
  45.   restorevdc();                     /* restore registers saved by savevdc() */
  46.   putchar(0x1A);                    /* adm-3a clear-home cursor */
  47. }
  48.  
  49. void drawwindows(void)
  50. {
  51.   uchar X1, Y1, X2, Y2, I;
  52.  
  53.   for (I = 1; I <= 50; I++)      /* draw 50 random windows */
  54.   {
  55.     X1 = (uchar) (rand() >> 10);
  56.     Y1 = (uchar) (rand() >> 12);
  57.     X2 = X1+(uchar) (rand() >> 10)+3;
  58.     Y2 = Y1+(uchar) (rand() >> 12)+3;
  59.     winvdc(X1,Y1,X2,Y2,vdcAltChrSet+(uchar) (rand() >> 11),"C Windows!");
  60.   }
  61. }
  62.  
  63. void scrollwindow(uchar X1, uchar Y1, uchar X2, uchar Y2)
  64. {
  65.   uchar I;
  66.  
  67.   winvdc(X1,Y1,X2,Y2,vdcAltChrSet+vdcDarkGreen,"Scroller");
  68.   for (I = 1; I <= 100; I++) /* scroll window with random color string */
  69.   {
  70.     scrollupvdc(X1+1,Y1+2,X2-1,Y2-1);
  71.     printstrvdc(X1+1,Y2-2,vdcAltChrSet+(uchar) (rand() >> 11),appScrlStr1);
  72.   }
  73. }
  74.