This commit is contained in:
seta75D
2021-10-11 19:38:01 -03:00
commit 7c4988eac0
12567 changed files with 3198619 additions and 0 deletions

40
cmd/tplot/Makefile Executable file
View File

@@ -0,0 +1,40 @@
#
#ident "@(#)Makefile 1.2 92/06/24 SMI"
#
# Copyright (c) 1992 by Sun Microsystems, Inc.
#
# cmd/tplot/Makefile
TPROG= t4014 t300 t300s t450
PROG= $(TPROG) vplot
SHFILES= tplot
# include common definitions
include ../Makefile.cmd
CLOBBERFILES += $(SHFILES)
# conditional assignments
t% := LDLIBS += -l$(@F:t%=%) -lm
.KEEP_STATE:
all: $(PROG) $(SHFILES)
$(TPROG): driver.o
$(LINK.c) -o $@ driver.o $(LDLIBS)
$(POST_PROCESS)
$(ROOTSHFILES): $(SHFILES)
vplot: vplot.o banner.o
$(LINK.c) -o $@ vplot.o banner.o $(LDLIBS)
$(POST_PROCESS)
install: $(ROOTLIBPROG) $(ROOTSHFILES)
clean:
$(RM) driver.o vplot.o banner.o
# include common targets
include ../Makefile.targ

145
cmd/tplot/banner.c Executable file
View File

@@ -0,0 +1,145 @@
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)banner.c 1.3 93/12/01 SMI"
#include <stdio.h>
#include <sys/types.h>
#define FF '\014'
unsigned char chrtab[][16] = {
0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, sp, */
0010,0010,0010,0010,0010,0010,0010,0010,0000,0000,0010,0000,0000,0000,0000,0000, /*, !, */
0024,0024,0024,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ", */
0000,0000,0000,0044,0044,0176,0044,0044,0176,0044,0044,0000,0000,0000,0000,0000, /*, #, */
0000,0010,0010,0010,0076,0101,0100,0076,0001,0101,0076,0010,0010,0000,0000,0000, /*, $, */
0000,0000,0000,0141,0142,0004,0010,0010,0020,0043,0103,0000,0000,0000,0000,0000, /*, %, */
0000,0000,0070,0104,0110,0060,0060,0111,0106,0106,0071,0000,0000,0000,0000,0000, /*, &, */
0004,0010,0020,0040,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ', */
0000,0004,0010,0020,0040,0040,0040,0040,0040,0040,0020,0010,0004,0000,0000,0000, /*, (, */
0000,0040,0020,0010,0004,0004,0004,0004,0004,0004,0010,0020,0040,0000,0000,0000, /*, ), */
0000,0000,0000,0010,0111,0052,0034,0177,0034,0052,0111,0010,0000,0000,0000,0000, /*, *, */
0000,0000,0000,0000,0010,0010,0010,0177,0010,0010,0010,0000,0000,0000,0000,0000, /*, +, */
0000,0000,0000,0000,0000,0000,0000,0000,0000,0030,0030,0010,0020,0000,0000,0000, /*, ,, */
0000,0000,0000,0000,0000,0000,0000,0176,0000,0000,0000,0000,0000,0000,0000,0000, /*, -, */
0000,0000,0000,0000,0000,0000,0000,0000,0000,0030,0030,0000,0000,0000,0000,0000, /*, ., */
0000,0000,0001,0002,0004,0010,0010,0010,0020,0040,0100,0000,0000,0000,0000,0000, /*, /, */
0000,0030,0044,0102,0102,0102,0102,0102,0102,0044,0030,0000,0000,0000,0000,0000, /*, 0, */
0000,0010,0030,0010,0010,0010,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, 1, */
0000,0070,0104,0004,0004,0010,0020,0040,0100,0100,0174,0000,0000,0000,0000,0000, /*, 2, */
0000,0176,0004,0004,0010,0014,0002,0002,0002,0104,0070,0000,0000,0000,0000,0000, /*, 3, */
0000,0004,0014,0024,0044,0104,0176,0004,0004,0004,0004,0000,0000,0000,0000,0000, /*, 4, */
0000,0174,0100,0100,0130,0144,0002,0002,0102,0044,0030,0000,0000,0000,0000,0000, /*, 5, */
0000,0074,0102,0100,0130,0144,0102,0102,0102,0044,0030,0000,0000,0000,0000,0000, /*, 6, */
0000,0176,0004,0004,0010,0010,0020,0020,0040,0040,0040,0000,0000,0000,0000,0000, /*, 7, */
0000,0034,0042,0101,0042,0076,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, 8, */
0000,0034,0042,0101,0101,0101,0043,0036,0004,0010,0020,0040,0000,0000,0000,0000, /*, 9, */
0000,0000,0000,0000,0000,0000,0030,0030,0000,0030,0030,0000,0000,0000,0000,0000, /*, :, */
0000,0000,0000,0000,0000,0000,0030,0030,0000,0030,0030,0020,0040,0000,0000,0000, /*, ;, */
0002,0004,0010,0020,0040,0100,0040,0020,0010,0004,0002,0000,0000,0000,0000,0000, /*, <, */
0000,0000,0000,0000,0177,0000,0177,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, =, */
0100,0040,0020,0010,0004,0002,0004,0010,0020,0040,0100,0000,0000,0000,0000,0000, /*, >, */
0000,0030,0044,0102,0001,0002,0004,0010,0010,0000,0010,0000,0000,0000,0000,0000, /*, ?, */
0000,0074,0102,0101,0115,0123,0121,0121,0121,0111,0046,0000,0000,0000,0000,0000, /*, @, */
0000,0010,0024,0042,0101,0101,0177,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, A, */
0000,0176,0101,0101,0101,0176,0101,0101,0101,0101,0176,0000,0000,0000,0000,0000, /*, B, */
0000,0076,0101,0100,0100,0100,0100,0100,0100,0101,0076,0000,0000,0000,0000,0000, /*, C, */
0000,0176,0101,0101,0101,0101,0101,0101,0101,0101,0176,0000,0000,0000,0000,0000, /*, D, */
0000,0176,0100,0100,0100,0170,0100,0100,0100,0100,0177,0000,0000,0000,0000,0000, /*, E, */
0000,0177,0100,0100,0100,0174,0100,0100,0100,0100,0100,0000,0000,0000,0000,0000, /*, F, */
0000,0076,0101,0100,0100,0117,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, G, */
0000,0101,0101,0101,0101,0176,0101,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, H, */
0000,0034,0010,0010,0010,0010,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, I, */
0000,0016,0004,0004,0004,0004,0004,0004,0104,0104,0070,0000,0000,0000,0000,0000, /*, J, */
0000,0101,0102,0104,0110,0120,0160,0110,0104,0102,0101,0000,0000,0000,0000,0000, /*, K, */
0000,0100,0100,0100,0100,0100,0100,0100,0100,0100,0177,0000,0000,0000,0000,0000, /*, L, */
0000,0101,0143,0125,0111,0101,0101,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, M, */
0000,0101,0141,0121,0111,0105,0103,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, N, */
0000,0076,0101,0101,0101,0101,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, O, */
0000,0176,0101,0101,0101,0176,0100,0100,0100,0100,0100,0000,0000,0000,0000,0000, /*, P, */
0000,0076,0101,0101,0101,0101,0101,0101,0131,0105,0076,0002,0001,0000,0000,0000, /*, Q, */
0000,0176,0101,0101,0101,0176,0104,0102,0101,0101,0101,0000,0000,0000,0000,0000, /*, R, */
0000,0076,0101,0100,0100,0076,0001,0001,0001,0101,0076,0000,0000,0000,0000,0000, /*, S, */
0000,0177,0010,0010,0010,0010,0010,0010,0010,0010,0010,0000,0000,0000,0000,0000, /*, T, */
0000,0101,0101,0101,0101,0101,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, U, */
0000,0101,0101,0101,0101,0101,0101,0101,0042,0024,0010,0000,0000,0000,0000,0000, /*, V, */
0000,0101,0101,0101,0101,0111,0111,0125,0143,0101,0101,0000,0000,0000,0000,0000, /*, W, */
0000,0101,0101,0042,0024,0010,0024,0042,0101,0101,0101,0000,0000,0000,0000,0000, /*, X, */
0000,0101,0042,0024,0010,0010,0010,0010,0010,0010,0010,0000,0000,0000,0000,0000, /*, Y, */
0000,0177,0001,0002,0004,0010,0020,0040,0100,0100,0177,0000,0000,0000,0000,0000, /*, Z, */
0000,0034,0020,0020,0020,0020,0020,0020,0020,0020,0020,0034,0000,0000,0000,0000, /*, [, */
0000,0000,0100,0040,0020,0010,0010,0010,0004,0002,0001,0000,0000,0000,0000,0000, /*, , \, */
0000,0070,0010,0010,0010,0010,0010,0010,0010,0010,0010,0070,0000,0000,0000,0000, /*, ], */
0010,0024,0042,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ^, */
0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0377,0000,0000, /*, _, */
0040,0020,0010,0004,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, `, */
0000,0000,0000,0000,0000,0074,0002,0076,0102,0102,0076,0000,0000,0000,0000,0000, /*, a, */
0000,0100,0100,0100,0100,0174,0102,0102,0102,0102,0174,0000,0000,0000,0000,0000, /*, b, */
0000,0000,0000,0000,0000,0074,0102,0100,0100,0102,0074,0000,0000,0000,0000,0000, /*, c, */
0002,0002,0002,0002,0002,0076,0102,0102,0102,0102,0076,0000,0000,0000,0000,0000, /*, d, */
0000,0000,0000,0000,0000,0074,0102,0174,0100,0102,0074,0000,0000,0000,0000,0000, /*, e, */
0000,0016,0020,0020,0020,0176,0020,0020,0020,0020,0020,0000,0000,0000,0000,0000, /*, f, */
0000,0000,0000,0000,0000,0076,0102,0102,0102,0102,0076,0002,0002,0102,0076,0000, /*, g, */
0000,0100,0100,0100,0100,0174,0102,0102,0102,0102,0102,0000,0000,0000,0000,0000, /*, h, */
0000,0000,0000,0010,0000,0030,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, i, */
0000,0000,0000,0010,0000,0030,0010,0010,0010,0010,0010,0010,0010,0050,0020,0000, /*, j, */
0000,0100,0100,0100,0100,0106,0110,0120,0160,0110,0106,0000,0000,0000,0000,0000, /*, k, */
0000,0030,0010,0010,0010,0010,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, l, */
0000,0000,0000,0000,0000,0166,0111,0111,0111,0111,0111,0000,0000,0000,0000,0000, /*, m, */
0000,0000,0000,0000,0100,0174,0102,0102,0102,0102,0102,0000,0000,0000,0000,0000, /*, n, */
0000,0000,0000,0000,0000,0074,0102,0102,0102,0102,0074,0000,0000,0000,0000,0000, /*, o, */
0000,0000,0000,0000,0000,0174,0102,0102,0102,0102,0174,0100,0100,0100,0100,0000, /*, p, */
0000,0000,0000,0000,0000,0076,0102,0102,0102,0102,0076,0002,0002,0002,0002,0000, /*, q, */
0000,0000,0000,0000,0000,0134,0142,0100,0100,0100,0100,0000,0000,0000,0000,0000, /*, r, */
0000,0000,0000,0000,0000,0076,0100,0074,0002,0102,0074,0000,0000,0000,0000,0000, /*, s, */
0000,0020,0020,0020,0020,0176,0020,0020,0020,0020,0014,0000,0000,0000,0000,0000, /*, t, */
0000,0000,0000,0000,0000,0102,0102,0102,0102,0102,0075,0000,0000,0000,0000,0000, /*, u, */
0000,0000,0000,0000,0000,0101,0101,0101,0042,0024,0010,0000,0000,0000,0000,0000, /*, v, */
0000,0000,0000,0000,0000,0111,0111,0111,0111,0111,0066,0000,0000,0000,0000,0000, /*, w, */
0000,0000,0000,0000,0000,0102,0044,0030,0030,0044,0102,0000,0000,0000,0000,0000, /*, x, */
0000,0000,0000,0000,0000,0102,0102,0102,0042,0024,0010,0020,0040,0100,0000,0000, /*, y, */
0000,0000,0000,0000,0000,0176,0004,0010,0020,0040,0176,0000,0000,0000,0000,0000, /*, z, */
0000,0014,0020,0020,0020,0020,0040,0020,0020,0020,0020,0014,0000,0000,0000,0000, /*, {, */
0000,0010,0010,0010,0010,0000,0000,0010,0010,0010,0010,0000,0000,0000,0000,0000, /*, |, */
0000,0030,0010,0010,0010,0010,0004,0010,0010,0010,0010,0030,0000,0000,0000,0000, /*, }, */
0020,0052,0004,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ~, */
0000,0176,0176,0176,0176,0176,0176,0176,0176,0176,0176,0000,0000,0000,0000,0000, /*, del, */
};
banner(out,s)
FILE *out;
char *s;
{
extern char *ctime();
extern time_t time();
long timeb;
register char *sp;
int i, j, t, lsw;
for(lsw=0; s[lsw] && lsw<5; lsw++);
fprintf(out, "\n\n\n\n\n\n\n\n");
for (i=0; i<16; i++) {
if(lsw < 5)
fprintf(out, " ");
for (sp=s; *sp; sp++) {
if (*sp<=' '|| *sp >'}')
continue;
fprintf(out, " ");
t = chrtab[*sp - ' '][i];
for (j=7; j>=0; j--)
if ((t>>j) & 01)
putc('X', out);
else
putc(' ', out);
}
putc('\n', out);
}
fprintf(out, "\n\n\n\n\n\n\n\n");
time(&timeb);
fprintf(out, " ");
fprintf(out, ctime(&timeb));
putc(FF, out);
}

158
cmd/tplot/driver.c Executable file
View File

@@ -0,0 +1,158 @@
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)driver.c 1.2 92/07/22 SMI"
#include <stdio.h>
#include <math.h>
#include <errno.h>
float deltx = 4095.0;
float delty = 4095.0;
main(argc,argv) char **argv; {
int std=1;
FILE *fin;
while(argc-- > 1) {
if(*argv[1] == '-')
switch(argv[1][1]) {
case 'l':
deltx = atoi(&argv[1][2]) - 1;
break;
case 'w':
delty = atoi(&argv[1][2]) - 1;
break;
}
else {
std = 0;
if ((fin = fopen(argv[1], "r")) == NULL) {
fprintf(stderr, "can't open %s\n", argv[1]);
exit(1);
}
fplt(fin);
}
argv++;
}
if (std)
fplt( stdin );
exit(0);
}
fplt(fin) FILE *fin; {
int c;
char s[256];
int xi,yi,x0,y0,x1,y1,r,dx,n,i;
int pat[256];
openpl();
while((c=getc(fin)) != EOF){
switch(c){
case 'm':
xi = getsi(fin);
yi = getsi(fin);
move(xi,yi);
break;
case 'l':
x0 = getsi(fin);
y0 = getsi(fin);
x1 = getsi(fin);
y1 = getsi(fin);
line(x0,y0,x1,y1);
break;
case 't':
getsd(s,fin);
label(s);
break;
case 'e':
erase();
break;
case 'p':
xi = getsi(fin);
yi = getsi(fin);
point(xi,yi);
break;
case 'n':
xi = getsi(fin);
yi = getsi(fin);
cont(xi,yi);
break;
case 's':
x0 = getsi(fin);
y0 = getsi(fin);
x1 = getsi(fin);
y1 = getsi(fin);
space(x0,y0,x1,y1);
break;
case 'a':
xi = getsi(fin);
yi = getsi(fin);
x0 = getsi(fin);
y0 = getsi(fin);
x1 = getsi(fin);
y1 = getsi(fin);
arc(xi,yi,x0,y0,x1,y1);
break;
case 'c':
xi = getsi(fin);
yi = getsi(fin);
r = getsi(fin);
circle(xi,yi,r);
break;
case 'f':
getsd(s,fin);
linemod(s);
break;
case 'd':
xi = getsi(fin);
yi = getsi(fin);
dx = getsi(fin);
n = getsi(fin);
for(i=0; i<n; i++)pat[i] = getsi(fin);
dot(xi,yi,dx,n,pat);
break;
}
}
closepl();
}
getsi(fin) FILE *fin; { /* get an integer stored in 2 ascii bytes. */
short a, b;
if((b = getc(fin)) == EOF)
return(EOF);
if((a = getc(fin)) == EOF)
return(EOF);
a = a<<8;
return(a|b);
}
getsd(s,fin) char *s; FILE *fin; {
for( ; *s = getc(fin); s++)
if(*s == '\n')
break;
*s = '\0';
return;
}
matherr(x)
struct exception *x;
{
if(x->type==DOMAIN)
{errno=EDOM;
if(!strcmp("log",x->name))x->retval = (-HUGE);
else x->retval = 0;
return(1);
}
else if ((x->type)==SING)
{errno=EDOM;
x->retval = (-HUGE);
return(1);
}
else return(0);
}

23
cmd/tplot/tplot.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/sh
# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
# All Rights Reserved
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
# The copyright notice above does not evidence any
# actual or intended publication of such source code.
#ident "@(#)tplot.sh 1.3 93/01/11 SMI"
case $1 in
-T*) t=$1
shift ;;
*) t=-T$TERM
esac
case $t in
-T450) exec /usr/lib/t450 $*;;
-T300) exec /usr/lib/t300 $*;;
-T300S|-T300s) exec /usr/lib/t300s $*;;
-Tver) exec /usr/lib/vplot $*;;
-Ttek|-T4014) exec /usr/lib/t4014 $* ;;
*) echo terminal type not known 1>&2; exit 1
esac

450
cmd/tplot/vplot.c Executable file
View File

@@ -0,0 +1,450 @@
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)vplot.c 1.4 93/12/09 SMI"
#include <stdio.h>
#include <signal.h>
#include <values.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sgtty.h>
#define NB 88
#define BSIZ 512
#define mapx(x) ((1536*((x)-botx)/del)+centx)
#define mapy(y) ((1536*(del-(y)+boty)/del)-centy)
#define SOLID -1
#define DOTTED 014
#define SHORTDASHED 034
#define DOTDASHED 054
#define LONGDASHED 074
#define SETSTATE (('v'<<8)+1)
#define NEG_MASK (MAXINT<<(2*BITS(char)))
#define MAXCHAR ((char)~((char)(1<<BITS(char)-1)))
#define BUILDINT(ubyte,lbyte) \
ubyte>MAXCHAR?(ubyte<<BITS(char))|lbyte|NEG_MASK:(ubyte<<BITS(char))|lbyte
#ifdef vax
#define getw(x) gethw(x)
#endif
int linmod = SOLID;
int again;
int done1;
extern char chrtab[][16];
short plotcom[] = { 0200, 0, 0, 0 };
short eotcom[] = { 0210, 0, 0, 0 };
char blocks [NB][BSIZ];
short obuf[264];
int lastx;
int lasty;
double topx = 1536;
double topy = 1536;
double botx = 0;
double boty = 0;
int centx;
int centy;
double delx = 1536;
double dely = 1536;
double del = 1536;
int bflag;
int fflag;
char *banname;
FILE *vpstr;
struct buf {
int bno;
char *block;
};
struct buf bufs[NB];
int in, out;
char *picname = "/var/tmp/rasterXXXXXX";
char *picture;
main(argc, argv)
char **argv;
{
extern void onintr();
register i;
extern char *optarg;
extern int optind;
register int c;
char *fname;
char *mktemp();
while((c = getopt(argc, argv, "e:b:")) != EOF) switch(c) {
case 'b':
bflag++;
banname = optarg;
break;
case 'e':
fname = optarg;
fflag++;
break;
case '?':
fprintf(stderr,"usage: vplot [ -f raster ] [ file ]\n");
exit(1);
}
if (fflag) {
if ((in = open(fname, O_RDONLY)) < 0) {
fprintf(stderr, "vplot: cannot open %s\n",fname);
exit(1);
}
putpict();
exit(0);
}
if (optind < argc)
if (freopen(argv[optind], "r", stdin) == NULL) {
fprintf(stderr,"vplot: cannot open %s\n",argv[optind]);
exit(1);
}
signal(SIGTERM, onintr);
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
signal(SIGINT, onintr);
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
signal(SIGHUP, onintr);
another:
for (i=0; i<NB; i++) {
bufs[i].bno = -1;
bufs[i].block = blocks[i];
}
picture = mktemp(picname);
out = creat(picture, (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH));
in = open(picture, O_RDONLY);
zseek(out, 32*32);
write(out, blocks[0], BSIZ);
/*delete following code when filsys deals properly with
holes in files
for(i=0;i<512;i++)
blocks[0][i] = 0;
zseek(out, 0);
for(i=0;i<32*32;i++)
write(out,blocks[0],512);
/**/
getpict();
for (i=0; i<NB; i++)
if (bufs[i].bno != -1) {
zseek(out, bufs[i].bno);
write(out, bufs[i].block, BSIZ);
}
putpict();
if (again) {
close(in);
close(out);
goto another;
}
unlink(picture);
exit(0);
}
getpict()
{
register x1, y1;
again = 0;
for (;;) switch (x1 = getc(stdin)) {
case 's':
botx = getw(stdin);
boty = getw(stdin);
topx = getw(stdin);
topy = getw(stdin);
delx = topx-botx;
dely = topy-boty;
if (dely/delx > 1536./2048.)
del = dely;
else
del = delx * (1566./2048.);
centx = 0;
centx = (2048 - mapx(topx)) / 2;
centy = 0;
centy = mapy(topy) / 2;
continue;
case 'l':
done1 |= 01;
x1 = mapx(getw(stdin));
y1 = mapy(getw(stdin));
lastx = mapx(getw(stdin));
lasty = mapy(getw(stdin));
line(x1, y1, lastx, lasty);
continue;
case 'm':
lastx = mapx(getw(stdin));
lasty = mapy(getw(stdin));
continue;
case 't':
done1 |= 01;
while ((x1 = getc(stdin)) != '\n')
plotch(x1);
continue;
case 'e':
if (done1) {
again++;
return;
}
continue;
case 'p':
done1 |= 01;
lastx = mapx(getw(stdin));
lasty = mapy(getw(stdin));
point(lastx, lasty);
point(lastx+1, lasty);
point(lastx, lasty+1);
point(lastx+1, lasty+1);
continue;
case 'n':
done1 |= 01;
x1 = mapx(getw(stdin));
y1 = mapy(getw(stdin));
line(lastx, lasty, x1, y1);
lastx = x1;
lasty = y1;
continue;
case 'f':
getw(stdin);
getc(stdin);
switch(getc(stdin)) {
case 't':
linmod = DOTTED;
break;
default:
case 'i':
linmod = SOLID;
break;
case 'g':
linmod = LONGDASHED;
break;
case 'r':
linmod = SHORTDASHED;
break;
case 'd':
linmod = DOTDASHED;
break;
}
while((x1=getc(stdin))!='\n')
if(x1==-1) return;
continue;
case 'd':
getw(stdin);
getw(stdin);
getw(stdin);
x1 = getw(stdin);
while (--x1 >= 0)
getw(stdin);
continue;
case -1:
return;
default:
printf("Botch\n");
return;
}
}
plotch(c)
register c;
{
register j;
register char *cp;
int i;
if (c<' ' || c >0177)
return;
cp = chrtab[c-' '];
for (i = -16; i<16; i += 2) {
c = *cp++;
for (j=7; j>=0; --j)
if ((c>>j)&1) {
point(lastx+6-j*2, lasty+i);
point(lastx+7-j*2, lasty+i);
point(lastx+6-j*2, lasty+i+1);
point(lastx+7-j*2, lasty+i+1);
}
}
lastx += 16;
}
int f; /* versatec file number */
putpict()
{
register x;
register short *ip, *op;
int y;
if (f==0){
f = open("/dev/vp", O_WRONLY);
if (f < 0) {
fprintf(stderr,"Cannot open vp\n");
unlink(picture);
exit(1);
}
vpstr = fdopen(f, "w");
if (bflag) {
banner(vpstr, banname);
fflush(vpstr);
}
/*stty(f, plotcom);*/
ioctl(f,TIOCSETP,plotcom);
}
op = obuf;
lseek(in, 0L, 0);
for (y=0; y<2048; y++) {
if ((y&077) == 0)
read(in, blocks[0], 32*BSIZ);
for (x=0; x<32; x++) {
ip = (short *)&blocks[x][(y&077)<<3];
*op++ = *ip++;
*op++ = *ip++;
*op++ = *ip++;
*op++ = *ip++;
}
*op++ = 0;
*op++ = 0;
*op++ = 0;
*op++ = 0;
if (y&1) {
write(f, (char *)obuf, sizeof(obuf));
op = obuf;
}
}
}
line(x0, y0, x1, y1)
register x0, y0;
{
int dx, dy;
int xinc, yinc;
register res1;
int res2;
int slope;
xinc = 1;
yinc = 1;
if ((dx = x1-x0) < 0) {
xinc = -1;
dx = -dx;
}
if ((dy = y1-y0) < 0) {
yinc = -1;
dy = -dy;
}
slope = xinc*yinc;
res1 = 0;
res2 = 0;
if (dx >= dy) while (x0 != x1) {
if((x0+slope*y0)&linmod)
if (((x0>>6) + ((y0&~077)>>1)) == bufs[0].bno)
bufs[0].block[((y0&077)<<3)+((x0>>3)&07)] |= 1 << (7-(x0&07));
else
point(x0, y0);
if (res1 > res2) {
res2 += dx - res1;
res1 = 0;
y0 += yinc;
}
res1 += dy;
x0 += xinc;
} else while (y0 != y1) {
if((x0+slope*y0)&linmod)
if (((x0>>6) + ((y0&~077)>>1)) == bufs[0].bno)
bufs[0].block[((y0&077)<<3)+((x0>>3)&07)] |= 1 << (7-(x0&07));
else
point(x0, y0);
if (res1 > res2) {
res2 += dy - res1;
res1 = 0;
x0 += xinc;
}
res1 += dx;
y0 += yinc;
}
if((x1+slope*y1)&linmod)
if (((x1>>6) + ((y1&~077)>>1)) == bufs[0].bno)
bufs[0].block[((y1&077)<<3)+((x1>>3)&07)] |= 1 << (7-(x1&07));
else
point(x1, y1);
}
point(x, y)
register x, y;
{
register bno;
bno = ((x&03700)>>6) + ((y&03700)>>1);
if (bno != bufs[0].bno) {
if (bno < 0 || bno >= 1024)
return;
getblk(bno);
}
bufs[0].block[((y&077)<<3)+((x>>3)&07)] |= 1 << (7-(x&07));
}
getblk(b)
register b;
{
register struct buf *bp1, *bp2;
register char *tp;
loop:
for (bp1 = bufs; bp1 < &bufs[NB]; bp1++) {
if (bp1->bno == b || bp1->bno == -1) {
tp = bp1->block;
for (bp2 = bp1; bp2>bufs; --bp2) {
bp2->bno = (bp2-1)->bno;
bp2->block = (bp2-1)->block;
}
bufs[0].bno = b;
bufs[0].block = tp;
return;
}
}
zseek(out, bufs[NB-1].bno);
write(out, bufs[NB-1].block, BSIZ);
zseek(in, b);
read(in, bufs[NB-1].block, BSIZ);
bufs[NB-1].bno = b;
goto loop;
}
void
onintr()
{
unlink(picture);
exit(1);
}
zseek(a, b)
{
return(lseek(a, (long)b*512, 0));
}
#include <stdio.h>
gethw(iop)
register FILE *iop;
{
register i,j;
i = getc(iop);
if (iop->_flag&_IOEOF)
return(-1);
j = getc(iop);
return(BUILDINT( j , i));
}