/*
 *
 *                  plotps.c
 *
 */
 
#include "defn.h"

#define MAXDRAWPOINTS	100

plotps(type)
char   *type;
{
    if (type == MOVE || type == RMOVE)
    {
	while (test_token())
	{
	    if (type == MOVE)
	    {
		end_draw();
		lastXmove = absX = getval() * XSCALE;
		lastYmove = absY = getval() * YSCALE;
	    } else
	    if (type == RMOVE)
	    {
		end_draw();
		lastXmove = absX += getval() * XSCALE;
		lastYmove = absY += getval() * YSCALE;
	    }
            if (SETDOT || SYMBOLX)  plotdot(MOVE);
	}
    }
    else			/* Must be a DRAW or RDRAW */
    {
	while (test_token())
	{
	    if (dcount++ >= MAXDRAWPOINTS)
	    {
		end_draw();
	        lastXmove = absX;           /* <<<---- new line --<< */
		lastYmove = absY;           /* <<<---- new line --<< */  
		fprintf(outfile, "newpath\n");
		fprintf(outfile, "  %g %g %s\n", absX, absY, MOVE);
		DRAW_FLAG = 1;
                if (DEBUG)
		    fprintf(stderr, "Warning exceeded %d draw points\n", MAXDRAWPOINTS);
	    }
	    xval = getval() * XSCALE;
	    yval = getval() * YSCALE;
	    if (!DRAW_FLAG)
	    {
	        lastXmove = absX;           /* <<<---- new line --<< */
		lastYmove = absY;           /* <<<---- new line --<< */  
		fprintf(outfile, "newpath\n");
		fprintf(outfile, "  %g %g %s\n", absX, absY, MOVE);
		DRAW_FLAG = 1;
	    }
	    if (type == RDRAW)
	    {
		absX += xval;
		absY += yval;
		fprintf(outfile, "  %g %g %s\n", xval, yval, RDRAW);
	    } else
	    if (type == DRAW)
	    {
		absX = xval;
		absY = yval;
		fprintf(outfile, "  %g %g %s\n", absX, absY, DRAW);
	    } else
	    {
		fprintf(stderr, "Error: expecting draw command not %s\n", type);
		exit(1);
	    }

            if (SETDOT || SYMBOLX)  plotdot(MOVE);
	}
    }

    CR_point_X = absX;
    CR_point_Y = absY;
}
