home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / logo / part01 / atari.i < prev    next >
Encoding:
Text File  |  1987-06-23  |  2.2 KB  |  101 lines

  1.  
  2. /* Include file for turtle.c for Atari 800 as graphics terminal */
  3.  
  4. int ataturn(),apenc(),asetc(),astate();
  5. NUMBER ncheck();
  6.  
  7. struct display bwatari ={0.0,0.0,0.0,-160.0,160.0,-96.0,96.0,0.875,0,
  8.     "\033#G","\033c","\033.t","\033.c",
  9.     nullfn,nullfn,nullfn,nullfn,nullfn,nullfn,ataturn,
  10.     apenc,asetc,astate};
  11. struct display colatari ={0.0,0.0,0.0,-80.0,80.0,-48.0,48.0,0.875,0,
  12.     "\033#G","\033c","\033.t","\033.c",
  13.     nullfn,nullfn,nullfn,nullfn,nullfn,nullfn,ataturn,
  14.     apenc,asetc,astate};
  15.  
  16. ataturn() {
  17.     printf("\033.%dh",(int)((mydpy->turth+11.0)/22.5));
  18. }
  19.  
  20. apenc(ipen)
  21. register int ipen;
  22. {
  23.     if ((ipen<0) || (ipen>6)) {
  24.         puts("Bad pen color, must be 0 to 6.");
  25.         errhand();
  26.     }
  27.     mydpy = (ipen ? &colatari : &bwatari);
  28.     printf("\033.%dP",ipen);
  29.     if (!(mydpy->cleared)) {
  30.         printf("\033.c");    /* clear screen */
  31.         mydpy->cleared++;
  32.     }
  33.  
  34.     /* this is to fix bug in Atari program */
  35.     printf("\033.%dh",(int)((mydpy->turth+11.0)/22.5));
  36. }
  37.  
  38. asetc(ipen,colorlist)
  39. register int ipen;
  40. struct object *colorlist;
  41. {
  42.     register struct object *next;
  43.     register int icolor,intens;
  44.     static int normint[] = {1,5,5,1};
  45.     NUMBER number;
  46.  
  47.     if ((ipen<0) || (ipen>3)) {
  48.         puts("Pen number must be 0 to 3.");
  49.         errhand();
  50.     }
  51.  
  52.     if (listp(colorlist)) {
  53.         number = ncheck(localize(colorlist->obcar));
  54.         icolor = number;
  55.         next = colorlist->obcdr;
  56.         number = ncheck(localize(next->obcar));
  57.         intens = number;
  58.         mfree(colorlist);
  59.     } else {
  60.         number = ncheck(colorlist);
  61.         icolor = number;
  62.         intens = normint[ipen];
  63.     }
  64.     if ((icolor<0) || (icolor>15) || (intens<0) || (intens>7)) {
  65.         puts("Invalid color numbers.");
  66.         errhand();
  67.     }
  68.     printf("\033.%d;%dC",ipen,(icolor*16)+(intens*2));
  69. }
  70.  
  71. astate(which) {
  72.     switch(which) {
  73.         case 'c':
  74.             fflush(stdout);
  75.             sleep(1);
  76.         case '*':
  77.             return;
  78.         case 'w':
  79.             fflush(stdout);
  80.             sleep(1);
  81.             ataturn();
  82.             printf("\033.U\033.%d;%dG",
  83.                 (int)(yscrunch*mydpy->turty),(int)(mydpy->turtx));
  84.             if (pendown)
  85.                 printf("\033.%c","DER"[penerase]);
  86.             return;
  87.         case 'G':
  88.             printf("\033.%d;%dG",
  89.                 (int)(yscrunch*mydpy->turty),(int)(mydpy->turtx));
  90.             return;
  91.         case 'R':
  92.             printf("Atari can't penreverse; setting pendown.\n");
  93.             penerase = 0;
  94.             which = 'D';
  95.             /* falls into */
  96.         default:
  97.             printf("\033.%c",which);
  98.     }
  99. }
  100.  
  101.