home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / crssrc16 / twinkle2.c < prev    next >
C/C++ Source or Header  |  1993-07-29  |  1KB  |  75 lines

  1. /*
  2.  * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
  3.  * University of California.  Permission is granted to freely
  4.  * distribute curses and its documentation provided that this
  5.  * notice is left intact.
  6.  */
  7.  
  8. #ifndef lint
  9. static char sccsid[] = "@(#)twinkle2.c    6.1 (Berkeley) 4/24/86";
  10. #endif not lint
  11.  
  12. extern int    _putchar();
  13.  
  14. main()
  15. {
  16.     reg char    *sp;
  17.  
  18.     srand(getpid());        /* initialize random sequence */
  19.  
  20.     if (isatty(0)) {
  21.            gettmode();
  22.            if ((sp = getenv("TERM")) != NULL)
  23.                setterm(sp);
  24.         signal(SIGINT, die);
  25.     }
  26.     else {
  27.         printf("Need a terminal on %d\n", _tty_ch);
  28.         exit(1);
  29.     }
  30.     _puts(TI);
  31.     _puts(VS);
  32.  
  33.     noecho();
  34.     nonl();
  35.     tputs(CL, NLINES, _putchar);
  36.     for (;;) {
  37.         makeboard();        /* make the board setup */
  38.         puton('*');        /* put on '*'s */
  39.         puton(' ');        /* cover up with ' 's */
  40.     }
  41. }
  42.  
  43. puton(ch)
  44. char    ch;
  45. {
  46.     reg LOCS    *lp;
  47.     reg int        r;
  48.     reg LOCS    *end;
  49.     LOCS        temp;
  50.     static int    lasty, lastx;
  51.  
  52.     end = &Layout[Numstars];
  53.     for (lp = Layout; lp < end; lp++) {
  54.         r = rand() % Numstars;
  55.         temp = *lp;
  56.         *lp = Layout[r];
  57.         Layout[r] = temp;
  58.     }
  59.  
  60.     for (lp = Layout; lp < end; lp++)
  61.             /* prevent scrolling */
  62.         if (!AM || (lp->y < NLINES - 1 || lp->x < NCOLS - 1)) {
  63.             mvcur(lasty, lastx, lp->y, lp->x);
  64.             putchar(ch);
  65.             lasty = lp->y;
  66.             if ((lastx = lp->x + 1) >= NCOLS)
  67.                 if (AM) {
  68.                     lastx = 0;
  69.                     lasty++;
  70.                 }
  71.                 else
  72.                     lastx = NCOLS - 1;
  73.         }
  74. }
  75.