#include "plplot.h"
#include <stdio.h>
#include <string.h>
#include <limits.h>

struct termattr {
   unsigned char com[4];
   unsigned char rom[4];
   unsigned char ram[4];
   unsigned char con[5];
   unsigned char eor;
} termattr;

#define  DGX    639
#define  DGY    239

void dgsetup(xdpi,ydpi,xwid,ywid)
PLINT xwid, ywid;
PLFLT xdpi, ydpi;
{
}

void dginit()
{
   /* Request terminal configuration report */
   printf("\n\036\107\051\n");
   scanf("%s",(char *)&termattr);
   while(getchar() != '\n')
      ;
   if(!strncmp((char *)&termattr.ram[0],"0000",4)) {
      printf("Please wait while graphics interpreter is downloaded.\n");
      /* Need to download graphics interpreter. */
      system("cat  /usr/local/src/g300/g300gci110.tx");
   }

   /* Clear screen, Set pen color to green, Absolute positioning */
   printf("\036\107\063\060\n\036\107\155\061\n\036\107\151\060\n");
   printf("\036\107\042\061\n");

   /* set plplot stuff */
   smod(1);   /* interaction mode */
   scol(1);   /* color */
   swid(1);
   setpxl(3.316*16,1.655*16);
   setphy(0,DGX*16,0,DGY*16);
}

void dgselect(ori,file)
PLINT ori;
char *file;
{
}

void dgtext()
{
}

void dggraph()
{
}

void dgclear()
{
   /* Before clearing wait for CR */
   putchar('\007');
   fflush(stdout);
   while(getchar() != '\n')
      ;
   printf("ERASE\n");
}

void dgpage()
{
}

void dgcolor(colour)
PLINT colour;
{
}

void dgline(x1,y1,x2,y2)
PLINT x1,y1,x2,y2;
{
   printf("LINE %d %d %d %d\n",x1>>4,y1>>3,x2>>4,y2>>3);
}

void dgtidy()
{
   dgclear();
   printf("\036\107\042\060\n");
   fflush(stdout);
}

void dgwidth(width)
PLINT width;
{
}

