1
0

Source code upload

This commit is contained in:
calmsacibis995
2022-09-29 17:59:04 +03:00
parent 72fa9da3d7
commit 8fc8fa8089
33399 changed files with 11964078 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
#!smake
#ident "$Revision: 1.4 $"
include $(ROOT)/usr/include/make/commondefs
SUBDIRS= plot vt0
default exports install $(COMMONTARGS): $(_FORCE)
$(SUBDIRS_MAKERULE)
$(_FORCE):
+21
View File
@@ -0,0 +1,21 @@
#!smake
#
# Makefile for libplot.
#
#ident "$Revision: 1.4 $"
OBJECT_STYLE=32
BASELIB=libplot.a
include $(ROOT)/usr/include/make/librootdefs
TARGETS=$(LIBS)
CFILES = arc.c box.c circle.c close.c cont.c dot.c erase.c label.c line.c \
linmod.c move.c open.c point.c putsi.c space.c
default: $(TARGETS)
exports install: default
$(INSTALL) -F /usr/lib -m 444 $(LIBS)
include $(LIBROOTRULES)
+23
View File
@@ -0,0 +1,23 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void putsi(int);
void
arc(int xi, int yi, int x0, int y0, int x1, int y1){
putc('a',stdout);
putsi(xi);
putsi(yi);
putsi(x0);
putsi(y0);
putsi(x1);
putsi(y1);
}
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.2 $"
extern void cont(int, int);
extern void move(int, int);
void
box(int x0, int y0, int x1, int y1)
{
move(x0, y0);
cont(x0, y1);
cont(x1, y1);
cont(x1, y0);
cont(x0, y0);
move(x1, y1);
}
+20
View File
@@ -0,0 +1,20 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void putsi(int);
void
circle(int x, int y, int r){
putc('c',stdout);
putsi(x);
putsi(y);
putsi(r);
}
+21
View File
@@ -0,0 +1,21 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
void
closevt(void)
{
fflush(stdout);
}
void
closepl(void){
fflush(stdout);
}
+19
View File
@@ -0,0 +1,19 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void putsi(int);
void
cont(int xi, int yi){
putc('n',stdout);
putsi(xi);
putsi(yi);
}
+24
View File
@@ -0,0 +1,24 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void putsi(int);
void
dot(int xi, int yi, int dx, int n, int pat[])
{
int i;
putc('d',stdout);
putsi(xi);
putsi(yi);
putsi(dx);
putsi(n);
for(i=0; i<n; i++)putsi(pat[i]);
}
+16
View File
@@ -0,0 +1,16 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
void
erase(void)
{
putc('e',stdout);
}
+19
View File
@@ -0,0 +1,19 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
void
label(char *s)
{
int i;
putc('t',stdout);
for(i=0;s[i];)putc(s[i++],stdout);
putc('\n',stdout);
}
+4
View File
@@ -0,0 +1,4 @@
#
# Global library definitions
#
LIBRARY_COPTS= -fullwarn
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void putsi(int);
void
line(int x0, int y0, int x1, int y1)
{
putc('l',stdout);
putsi(x0);
putsi(y0);
putsi(x1);
putsi(y1);
}
+19
View File
@@ -0,0 +1,19 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
void
linemod(char *s)
{
int i;
putc('f',stdout);
for(i=0;s[i];)putc(s[i++],stdout);
putc('\n',stdout);
}
+20
View File
@@ -0,0 +1,20 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void putsi(int);
void
move(int xi, int yi)
{
putc('m',stdout);
putsi(xi);
putsi(yi);
}
+18
View File
@@ -0,0 +1,18 @@
/* 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 "$Revision: 1.2 $"
void
openvt(void)
{
}
void
openpl(void)
{
}
+20
View File
@@ -0,0 +1,20 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void putsi(int);
void
point(int xi, int yi)
{
putc('p',stdout);
putsi(xi);
putsi(yi);
}
+17
View File
@@ -0,0 +1,17 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
void
putsi(int a)
{
putc((char)a,stdout);
putc((char)(a>>8),stdout);
}
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void putsi(int);
void
space(int x0, int y0, int x1, int y1)
{
putc('s',stdout);
putsi(x0);
putsi(y0);
putsi(x1);
putsi(y1);
}
+21
View File
@@ -0,0 +1,21 @@
#!smake
#
# Makefile for lib300.
#
#ident "$Revision: 1.2 $"
BASELIB=lib300.a
include $(ROOT)/usr/include/make/librootdefs
TARGETS=$(LIBS)
CFILES = arc.c box.c circle.c close.c dot.c erase.c label.c line.c \
linmod.c move.c open.c point.c space.c subr.c
default: $(TARGETS)
exports install: default
$(INSTALL) -F /usr/lib -m 444 $(LIBS)
include $(LIBROOTRULES)
+146
View File
@@ -0,0 +1,146 @@
/* 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 "$Revision: 1.2 $"
#include <math.h>
extern void move(int, int);
extern void cont(int, int);
int abs(int);
int quad(int, int, int, int);
int del = 20;
void
step(int d)
{
del = d;
}
void
arc(int x, int y, int x0, int y0, int x1, int y1){
double pc;
int flg,m,xc,yc,xs,ys,qs,qf,qt,qtctr=0;
int m0,m1;
float dx,dy,r;
char use;
dx = x-x0;
dy = y-y0;
r = dx*dx+dy*dy;
pc = r;
pc = sqrt(pc);
flg = pc/4;
if(flg == 0)step(1);
else if(flg < del)step(flg);
xc = xs = x0;
yc = ys = y0;
move(xs,ys);
if(x0 == x1 && y0 == y1)flg=0;
else flg=1;
qs = quad(x,y,x0,y0);
qf = quad(x,y,x1,y1);
if(abs(x-x1) < abs(y-y1)){
use = 'x';
if(qs == 2 || qs ==3)m = -1;
else m=1;
}
else {
use = 'y';
if(qs > 2)m= -1;
else m= 1;
}
if(qs == qf) {
m0=(y0-y)/(x0-x);
m1=(y1-y)/(x1-x);
if(m0 >= m1)qt = 4;
else qt = 0;
}
else if((qt=qf-qs) < 0)qt += 4;
while(1){
switch(use){
case 'x':
if(qs == 2 || qs == 3)yc -= del;
else yc += del;
dy = yc-y;
pc = r-dy*dy;
xc = m*sqrt(pc)+x;
if((x < xs && x >= xc) || ( x > xs && x <= xc) ||
(y < ys && y >= yc) || ( y > ys && y <= yc) )
{
if(++qtctr > qt)return;
if(++qs > 4)qs=1;
if(qs == 2 || qs == 3)m= -1;
else m=1;
flg=1;
}
cont(xc,yc);
xs = xc;
ys = yc;
if(qs == qf && flg == 1)
switch(qf){
case 3:
case 4:
if(xs >= x1)return;
continue;
case 1:
case 2:
if(xs <= x1)return;
}
continue;
case 'y':
if(qs > 2)xc += del;
else xc -= del;
dx = xc-x;
pc = r-dx*dx;
yc = m*sqrt(pc)+y;
if((x < xs && x >= xc) || ( x > xs && x <= xc ) ||
(y < ys && y >= yc) || (y > ys && y <= yc) )
{
if(++qtctr > qt)return;
if(++qs > 4)qs=1;
if(qs > 2)m = -1;
else m = 1;
flg=1;
}
cont(xc,yc);
xs = xc;
ys = yc;
if(qs == qf && flg == 1)
switch(qs){
case 1:
case 4:
if(ys >= y1)return;
continue;
case 2:
case 3:
if(ys <= y1)return;
}
}
}
}
int
quad(int x, int y, int xp, int yp)
{
if(x < xp)
if(y <= yp)return(1);
else return(4);
else if(x > xp)
if(y < yp)return(2);
else return(3);
else if(y < yp)return(2);
else return(4);
}
int
abs(int a)
{
if(a < 0)return(-a);
return(a);
}
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.2 $"
extern void move(int, int);
extern void cont(int, int);
void
box(int x0, int y0, int x1, int y1)
{
move(x0, y0);
cont(x0, y1);
cont(x1, y1);
cont(x1, y0);
cont(x0, y0);
move(x1, y1);
}
+16
View File
@@ -0,0 +1,16 @@
/* 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 "$Revision: 1.2 $"
extern void arc(int, int, int, int, int, int);
void
circle(int x, int y, int r)
{
arc(x,y,x+r,y,x+r,y);
}
+27
View File
@@ -0,0 +1,27 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void reset(void);
void closepl(void);
void
closevt(void)
{
closepl();
}
void
closepl(void)
{
fflush(stdout);
reset();
}
+35
View File
@@ -0,0 +1,35 @@
/* 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 "$Revision: 1.1 $"
# include <termio.h>
/* gsi plotting output routines */
# define DOWN 012
# define UP 013
# define LEFT 010
# define RIGHT 040
# define BEL 007
# define ESC 033
# define ACK 006
# define CR 015
# define FF 014
# define VERTRESP 48
# define HORZRESP 60.
# define VERTRES 8.
# define HORZRES 6.
/* down is line feed, up is reverse line feed,
left is backspace, right is space. 48 points per inch
vertically, 60 horizontally */
extern int xnow, ynow;
extern struct termio ITTY, PTTY;
extern int OUTF;
extern float HEIGHT, WIDTH, OFFSET;
extern int xscale, xoffset, yscale;
extern float botx, boty, obotx, oboty, scalex,scaley;
+13
View File
@@ -0,0 +1,13 @@
/* 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 "$Revision: 1.2 $"
void
dot(void)
{
}
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.2 $"
#include "con.h"
extern void spew(int);
void
erase(void)
{
int i;
for(i=0; i<11*(VERTRESP/VERTRES); i++)
spew(DOWN);
return;
}
+23
View File
@@ -0,0 +1,23 @@
/* 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 "$Revision: 1.2 $"
#include "con.h"
extern void spew(int);
void
label(char *s)
{
int i,c;
while((c = *s++) != '\0'){
xnow += HORZRES;
spew(c);
}
return;
}
+4
View File
@@ -0,0 +1,4 @@
#
# Global library definitions
#
LIBRARY_COPTS= -fullwarn
+79
View File
@@ -0,0 +1,79 @@
/* 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 "$Revision: 1.2 $"
#include "con.h"
#include "math.h"
/* external declarations */
extern int xconv(int);
extern int yconv(int);
extern int xsc(int);
extern int ysc(int);
extern void movep(int, int);
extern void inplot(void);
extern int abval(int);
extern void spew(int);
extern void outplot(void);
extern float dist2(int, int, int, int);
/* foward declarations */
void iline(int, int, int, int);
void
line(int x0, int y0, int x1, int y1)
{
iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1)));
return;
}
void
cont(int x0, int y0)
{
iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0)));
return;
}
void
iline(int cx0, int cy0, int cx1, int cy1)
{
int maxp,tt,j,np;
char chx,chy;
float xd,yd;
movep(cx0,cy0);
maxp = sqrt(dist2(cx0,cy0,cx1,cy1))/2.;
xd = cx1-cx0;
yd = cy1-cy0;
if(xd >= 0)chx = RIGHT;
else chx = LEFT;
if(yd >= 0)chy = UP;
else chy = DOWN;
if(maxp==0){
xd=0;
yd=0;
}
else{
xd /=maxp;
yd /=maxp;
}
inplot();
for (tt=0; tt<=maxp; tt++){
j= cx0+xd*tt-xnow;
xnow += j;
j = abval(j);
while(j-- > 0)spew(chx);
j = cy0+yd*tt-ynow;
ynow += j;
j = abval(j);
while(j-- > 0)spew(chy);
spew ('.');
}
outplot();
return;
}
+13
View File
@@ -0,0 +1,13 @@
/* 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 "$Revision: 1.2 $"
void
linemod(void)
{
}
+23
View File
@@ -0,0 +1,23 @@
/* 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 "$Revision: 1.2 $"
/* external declarations */
extern int xconv(int);
extern int yconv(int);
extern int xsc(int);
extern int ysc(int);
extern void movep(int, int);
void
move(int xi, int yi)
{
movep(xconv(xsc(xi)),yconv(ysc(yi)));
return;
}
+63
View File
@@ -0,0 +1,63 @@
/* 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 "$Revision: 1.2 $"
#include <signal.h>
#include <termio.h>
#include <stdio.h>
/* gsi plotting output routines */
# define DOWN 012
# define UP 013
# define LEFT 010
# define RIGHT 040
# define BEL 007
# define ACK 006
# define CR 015
# define FF 014
# define VERTRESP 48
# define HORZRESP 60.
# define VERTRES 8.
# define HORZRES 6.
/* down is line feed, up is reverse line feed,
left is backspace, right is space. 48 points per inch
vertically, 60 horizontally */
int xnow, ynow;
struct termio ITTY, PTTY;
int OUTF;
float HEIGHT = 6.0, WIDTH = 6.0, OFFSET = 0.0;
int xscale, xoffset, yscale;
float botx = 0., boty = 0., obotx = 0., oboty = 0.;
float scalex = 1., scaley = 1.;
void
openpl (void)
{
void reset();
xnow = ynow = 0;
OUTF = 1;
printf("\r");
ioctl(OUTF, TCGETA, &ITTY);
signal (SIGINT, reset);
PTTY = ITTY;
PTTY.c_oflag &= ~(ONLCR|OCRNL|ONOCR|ONLRET);
PTTY.c_cflag |= CSTOPB;
ioctl(OUTF, TCSETAW, &PTTY);
/* initialize constants */
xscale = 4096./(HORZRESP * WIDTH);
yscale = 4096 /(VERTRESP * HEIGHT);
xoffset = OFFSET * HORZRESP;
return;
}
void
openvt(void)
{
openpl();
}
+20
View File
@@ -0,0 +1,20 @@
/* 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 "$Revision: 1.2 $"
/* external declarations */
extern void move(int, int);
extern void label(char *);
void
point(int xi, int yi)
{
move(xi,yi);
label(".");
return;
}
+23
View File
@@ -0,0 +1,23 @@
/* 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 "$Revision: 1.2 $"
# include "con.h"
extern float deltx;
extern float delty;
void
space(int x0, int y0, int x1, int y1)
{
botx = -2047.;
boty = -2047.;
obotx = x0;
oboty = y0;
scalex = deltx/(x1-x0);
scaley = delty/(y1-y0);
}
+144
View File
@@ -0,0 +1,144 @@
/* 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 "$Revision: 1.2 $"
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include "con.h"
extern void move(int, int);
void spew(int);
int
abval(int q)
{
return (q>=0 ? q : -q);
}
int
xconv(int xp)
{
/* x position input is -2047 to +2047, output must be 0 to PAGSIZ*HORZRES */
xp += 2048;
/* the computation is newx = xp*(PAGSIZ*HORZRES)/4096 */
return (xoffset + xp /xscale);
}
int
yconv(int yp)
{
/* see description of xconv */
yp += 2048;
return (yp / yscale);
}
void
inplot(void)
{
spew (ACK);
}
void
outplot(void)
{
spew(ESC);
spew(ACK);
fflush(stdout);
}
void
spew(int ch)
{
if(ch == UP)putc(ESC,stdout);
putc(ch, stdout);
}
void
tobotleft(void)
{
move(-2048,-2048);
}
void
reset(void)
{
signal(SIGINT,SIG_IGN);
spew(BEL);
fflush(stdout);
ioctl(OUTF, TCSETAW, &ITTY);
exit(0);
}
float
dist2(int x1, int y1, int x2, int y2)
{
float t,v;
t = x2-x1;
v = y1-y2;
return (t*t+v*v);
}
void
swap (int *pa, int *pb)
{
int t;
t = *pa;
*pa = *pb;
*pb = t;
}
void
movep(int xg, int yg)
{
int i,ch;
if((xg == xnow) && (yg == ynow))return;
/* if we need to go to left margin, just CR */
if (xg < xnow/2)
{
spew(CR);
xnow = 0;
}
i = (xg-xnow)/HORZRES;
if(xnow < xg)ch = RIGHT;
else ch = LEFT;
xnow += i*HORZRES;
i = abval(i);
while(i--)spew(ch);
i = abval(xg-xnow);
inplot();
while(i--) spew(ch);
outplot();
i=(yg-ynow)/VERTRES;
if(ynow < yg)ch = UP;
else ch = DOWN;
ynow += i*VERTRES;
i = abval(i);
while(i--)spew(ch);
i=abval(yg-ynow);
inplot();
while(i--)spew(ch);
outplot();
xnow = xg; ynow = yg;
}
int
xsc(int xi)
{
int xa;
xa = (xi - obotx) * scalex + botx;
return(xa);
}
int
ysc(int yi)
{
int ya;
ya = (yi - oboty) *scaley +boty;
return(ya);
}
+21
View File
@@ -0,0 +1,21 @@
#!smake
#
# Makefile for lib300s.
#
#ident "$Revision: 1.2 $"
BASELIB=lib300s.a
include $(ROOT)/usr/include/make/librootdefs
TARGETS=$(LIBS)
CFILES = arc.c box.c circle.c close.c dot.c erase.c label.c line.c \
linmod.c move.c open.c point.c space.c subr.c
default: $(TARGETS)
exports install: default
$(INSTALL) -F /usr/lib -m 444 $(LIBS)
include $(LIBROOTRULES)
+145
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 "$Revision: 1.2 $"
#include <math.h>
extern void move(int, int);
extern void cont(int, int);
int quad(int, int, int, int);
int abs(int);
int del = 20;
void
step(int d){
del = d;
}
void
arc(int x, int y, int x0, int y0, int x1, int y1)
{
double pc;
int flg,m,xc,yc,xs,ys,qs,qf,qt,qtctr=0;
int m0,m1;
float dx,dy,r;
char use;
dx = x-x0;
dy = y-y0;
r = dx*dx+dy*dy;
pc = r;
pc = sqrt(pc);
flg = pc/4;
if(flg == 0)step(1);
else if(flg < del)step(flg);
xc = xs = x0;
yc = ys = y0;
move(xs,ys);
if(x0 == x1 && y0 == y1)flg=0;
else flg=1;
qs = quad(x,y,x0,y0);
qf = quad(x,y,x1,y1);
if(abs(x-x1) < abs(y-y1)){
use = 'x';
if(qs == 2 || qs ==3)m = -1;
else m=1;
}
else {
use = 'y';
if(qs > 2)m= -1;
else m= 1;
}
if(qs == qf) {
m0=(y0-y)/(x0-x);
m1=(y1-y)/(x1-x);
if(m0 >= m1)qt = 4;
else qt = 0;
}
else if((qt=qf-qs) < 0)qt += 4;
while(1){
switch(use){
case 'x':
if(qs == 2 || qs == 3)yc -= del;
else yc += del;
dy = yc-y;
pc = r-dy*dy;
xc = m*sqrt(pc)+x;
if((x < xs && x >= xc) || ( x > xs && x <= xc) ||
(y < ys && y >= yc) || ( y > ys && y <= yc) )
{
if(++qtctr > qt)return;
if(++qs > 4)qs=1;
if(qs == 2 || qs == 3)m= -1;
else m=1;
flg=1;
}
cont(xc,yc);
xs = xc;
ys = yc;
if(qs == qf && flg == 1)
switch(qf){
case 3:
case 4:
if(xs >= x1)return;
continue;
case 1:
case 2:
if(xs <= x1)return;
}
continue;
case 'y':
if(qs > 2)xc += del;
else xc -= del;
dx = xc-x;
pc = r-dx*dx;
yc = m*sqrt(pc)+y;
if((x < xs && x >= xc) || ( x > xs && x <= xc ) ||
(y < ys && y >= yc) || (y > ys && y <= yc) )
{
if(++qtctr > qt)return;
if(++qs > 4)qs=1;
if(qs > 2)m = -1;
else m = 1;
flg=1;
}
cont(xc,yc);
xs = xc;
ys = yc;
if(qs == qf && flg == 1)
switch(qs){
case 1:
case 4:
if(ys >= y1)return;
continue;
case 2:
case 3:
if(ys <= y1)return;
}
}
}
}
int
quad(int x, int y, int xp, int yp)
{
if(x < xp)
if(y <= yp)return(1);
else return(4);
else if(x > xp)
if(y < yp)return(2);
else return(3);
else if(y < yp)return(2);
else return(4);
}
int
abs(int a)
{
if(a < 0)return(-a);
return(a);
}
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.2 $"
extern void move(int, int);
extern void cont(int, int);
void
box(int x0, int y0, int x1, int y1)
{
move(x0, y0);
cont(x0, y1);
cont(x1, y1);
cont(x1, y0);
cont(x0, y0);
move(x1, y1);
}
+16
View File
@@ -0,0 +1,16 @@
/* 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 "$Revision: 1.2 $"
extern void arc(int, int, int, int, int, int);
void
circle(int x, int y, int r)
{
arc(x,y,x+r,y,x+r,y);
}
+26
View File
@@ -0,0 +1,26 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void reset(void);
void closepl(void);
void
closevt(void)
{
closepl();
}
void
closepl(void)
{
fflush(stdout);
reset();
}
+43
View File
@@ -0,0 +1,43 @@
/* 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 "$Revision: 1.1 $"
#include <termio.h>
/* gsi plotting output routines */
# define DOUBLE 010
#define ADDR 0100
#define COM 060
#define PENUP 04
#define MAXX 070
#define MAXY 07
#define SPACES 7
# define DOWN 012
# define UP 013
# define LEFT 010
# define RIGHT 040
# define BEL 007
# define ESC 033
# define ACK 006
# define INPLOT 'P'
# define CR 015
# define FF 014
# define VERTRESP 48
# define HORZRESP 60.
# define VERTRES 8.
# define HORZRES 6.
/* down is line feed, up is reverse line feed,
left is backspace, right is space. 48 points per inch
vertically, 60 horizontally */
extern int xnow, ynow;
extern struct termio ITTY, PTTY;
extern int OUTF;
extern float HEIGHT, WIDTH, OFFSET;
extern int xscale, xoffset, yscale;
extern float botx, boty, obotx, oboty, scalex,scaley;
+13
View File
@@ -0,0 +1,13 @@
/* 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 "$Revision: 1.2 $"
void
dot(void)
{
}
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.2 $"
#include "con.h"
extern void spew(int);
void
erase(void)
{
int i;
for(i=0; i<11*(VERTRESP/VERTRES); i++)
spew(DOWN);
return;
}
+24
View File
@@ -0,0 +1,24 @@
/* 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 "$Revision: 1.2 $"
#include "con.h"
extern void spew(int);
void
label(char *s)
{
int i,c;
while((c = *s++) != '\0'){
xnow += HORZRES;
spew(c);
}
return;
}
+4
View File
@@ -0,0 +1,4 @@
#
# Global library definitions
#
LIBRARY_COPTS= -fullwarn
+74
View File
@@ -0,0 +1,74 @@
/* 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 "$Revision: 1.2 $"
#include "con.h"
#include "math.h"
/* external declarations */
extern int xconv(int);
extern int yconv(int);
extern int xsc(int);
extern int ysc(int);
extern void movep(int, int);
extern void inplot(void);
extern int abval(int);
extern void spew(int);
extern void outplot(void);
extern float dist2(int, int, int, int);
/* foward declarations */
void iline(int, int, int, int);
void
line(int x0, int y0, int x1, int y1)
{
iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1)));
return;
}
void
cont(int x0, int y0)
{
iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0)));
return;
}
void
iline(int cx0, int cy0, int cx1, int cy1)
{
int maxp,tt,j,np;
char chx,chy,command;
float xd,yd;
movep(cx0,cy0);
maxp = sqrt(dist2(cx0,cy0,cx1,cy1))/2.;
xd = cx1-cx0;
yd = cy1-cy0;
command = COM|((xd<0)<<1)|(yd<0);
if(maxp == 0){
xd=0;
yd=0;
}
else {
xd /=maxp;
yd /=maxp;
}
inplot();
spew(command);
for (tt=0; tt<=maxp; tt++){
chx= cx0+xd*tt-xnow;
xnow += chx;
chx = abval(chx);
chy = cy0+yd*tt-ynow;
ynow += chy;
chy = abval(chy);
spew(ADDR|chx<<3|chy);
}
outplot();
return;
}
+13
View File
@@ -0,0 +1,13 @@
/* 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 "$Revision: 1.2 $"
void
linemod(void)
{
}
+23
View File
@@ -0,0 +1,23 @@
/* 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 "$Revision: 1.2 $"
/* external declarations */
extern int xconv(int);
extern int yconv(int);
extern int xsc(int);
extern int ysc(int);
extern void movep(int, int);
void
move(int xi, int yi)
{
movep(xconv(xsc(xi)),yconv(ysc(yi)));
return;
}
+63
View File
@@ -0,0 +1,63 @@
/* 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 "$Revision: 1.2 $"
#include <signal.h>
#include <termio.h>
#include <stdio.h>
/* gsi plotting output routines */
# define DOWN 012
# define UP 013
# define LEFT 010
# define RIGHT 040
# define BEL 007
# define ACK 006
# define CR 015
# define FF 014
# define VERTRESP 48
# define HORZRESP 60.
# define HORZRES 6.
# define VERTRES 8.
/* down is line feed, up is reverse line feed,
left is backspace, right is space. 48 points per inch
vertically, 60 horizontally */
int xnow, ynow;
struct termio ITTY, PTTY;
int OUTF;
float HEIGHT = 6.0, WIDTH = 6.0, OFFSET = 0.0;
int xscale, xoffset, yscale;
float botx = 0., boty = 0., obotx = 0., oboty = 0.;
float scalex = 1., scaley = 1.;
void
openpl (void)
{
void reset();
xnow = ynow = 0;
OUTF = 1;
printf("\r");
ioctl(OUTF, TCGETA, &ITTY);
signal (SIGINT, reset);
PTTY = ITTY;
PTTY.c_oflag &= ~(ONLCR|OCRNL|ONOCR|ONLRET);
PTTY.c_cflag |= CSTOPB;
ioctl(OUTF, TCSETAW, &PTTY);
/* initialize constants */
xscale = 4096./(HORZRESP * WIDTH);
yscale = 4096 /(VERTRESP * HEIGHT);
xoffset = OFFSET * HORZRESP;
return;
}
void
openvt(void)
{
openpl();
}
+21
View File
@@ -0,0 +1,21 @@
/* 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 "$Revision: 1.2 $"
#include "con.h"
extern void move(int, int);
extern void label(char *);
void
point(int xi, int yi)
{
move(xi,yi);
label(".");
return;
}
+23
View File
@@ -0,0 +1,23 @@
/* 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 "$Revision: 1.2 $"
# include "con.h"
extern float deltx;
extern float delty;
void
space(int x0, int y0, int x1, int y1)
{
botx = -2047.;
boty = -2047.;
obotx = x0;
oboty = y0;
scalex = deltx/(x1-x0);
scaley = delty/(y1-y0);
}
+209
View File
@@ -0,0 +1,209 @@
/* 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 "$Revision: 1.2 $"
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include "con.h"
extern void move(int, int);
void spew(int);
void delay(void);
int
abval(int q)
{
return (q>=0 ? q : -q);
}
int
xconv(int xp)
{
/* x position input is -2047 to +2047, output must be 0 to PAGSIZ*HORZRES */
xp += 2048;
/* the computation is newx = xp*(PAGSIZ*HORZRES)/4096 */
return (xoffset + xp /xscale);
}
int
yconv(int yp)
{
/* see description of xconv */
yp += 2048;
return (yp / yscale);
}
void
inplot(void)
{
spew(ESC);
spew (INPLOT);
}
void
outplot(void)
{
spew(ESC);
spew(ACK);
spew(ESC);
spew(ACK);
fflush(stdout);
}
void
spew(int ch)
{
putc(ch, stdout);
}
void
tobotleft(void)
{
move(-2048,-2048);
}
void
reset(void)
{
signal(SIGINT,SIG_IGN);
outplot();
ioctl(OUTF, TCSETAW, &ITTY);
exit(0);
}
float
dist2(int x1, int y1, int x2, int y2)
{
float t,v;
t = x2-x1;
v = y1-y2;
return (t*t+v*v);
}
void
swap(int *pa, int *pb)
{
int t;
t = *pa;
*pa = *pb;
*pb = t;
}
#define DOUBLE 010
#define ADDR 0100
#define COM 060
#define MAXX 070
#define MAXY 07
extern xnow,ynow;
#define SPACES 7
void
movep(int ix,int iy)
{
int dx,dy,remx,remy,pts,i;
int xd,yd;
int addr,command;
char c;
if(xnow == ix && ynow == iy)return;
inplot();
dx = ix-xnow;
dy = iy-ynow;
command = COM|PENUP|((dx<0)<<1)|(dy<0);
dx = abval(dx);
dy = abval(dy);
xd = dx/(SPACES*2);
yd = dy/(SPACES*2);
pts = xd<yd?xd:yd;
if((i=pts)>0){
c=command|DOUBLE;
addr=ADDR;
if(xd>0)addr|=MAXX;
if(yd>0)addr|=MAXY;
spew(c);
delay();
while(i--){
spew(addr);
delay();
}
}
if(xd!=yd){
if(xd>pts){
i=xd-pts;
addr=ADDR|MAXX;
}
else{
i=yd-pts;
addr=ADDR|MAXY;
}
c=command|DOUBLE;
spew(c);
delay();
while(i--){
spew(addr);
delay();
}
}
remx=dx-xd*SPACES*2;
remy=dy-yd*SPACES*2;
addr=ADDR;
i = 0;
if(remx>7){
i=1;
addr|=MAXX;
remx -= 7;
}
if(remy>7){
i=1;
addr|=MAXY;
remy -= 7;
}
while(i--){
spew(command);
delay();
spew(addr);
delay();
}
if(remx>0||remy>0){
spew(command);
delay();
spew(ADDR|remx<<3|remy);
delay();
}
xnow=ix;
ynow=iy;
outplot();
return;
}
int
xsc(int xi)
{
int xa;
xa = (xi - obotx) * scalex + botx;
return(xa);
}
int
ysc(int yi)
{
int ya;
ya = (yi - oboty) *scaley +boty;
return(ya);
}
void
delay(void)
{
int i;
for (i=0;i<2;i++) {
ioctl(OUTF,TCSBRK,1);
}
return;
}
+21
View File
@@ -0,0 +1,21 @@
#!smake
#
# Makefile for lib4014.
#
#ident "$Revision: 1.2 $"
BASELIB=lib4014.a
include $(ROOT)/usr/include/make/librootdefs
TARGETS=$(LIBS)
CFILES = arc.c box.c circle.c close.c dot.c erase.c label.c line.c \
linemod.c move.c open.c point.c scale.c space.c subr.c
default: $(TARGETS)
exports install: default
$(INSTALL) -F /usr/lib -m 444 $(LIBS)
include $(LIBROOTRULES)
+146
View File
@@ -0,0 +1,146 @@
/* 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 "$Revision: 1.2 $"
#include <math.h>
extern void move(int, int);
extern void cont(int, int);
int quad(int, int, int, int);
int abs(int);
int del = 20;
void
step(int d)
{
del = d;
}
void
arc(int x, int y, int x0, int y0, int x1, int y1)
{
double pc;
int flg,m,xc,yc,xs,ys,qs,qf,qt,qtctr=0;
int m0,m1;
float dx,dy,r;
char use;
dx = x-x0;
dy = y-y0;
r = dx*dx+dy*dy;
pc = r;
pc = sqrt(pc);
flg = pc/4;
if(flg == 0)step(1);
else if(flg < del)step(flg);
xc = xs = x0;
yc = ys = y0;
move(xs,ys);
if(x0 == x1 && y0 == y1)flg=0;
else flg=1;
qs = quad(x,y,x0,y0);
qf = quad(x,y,x1,y1);
if(abs(x-x1) < abs(y-y1)){
use = 'x';
if(qs == 2 || qs ==3)m = -1;
else m=1;
}
else {
use = 'y';
if(qs > 2)m= -1;
else m= 1;
}
if(qs == qf) {
m0=(y0-y)/(x0-x);
m1=(y1-y)/(x1-x);
if(m0 >= m1)qt = 4;
else qt = 0;
}
else if((qt=qf-qs) < 0)qt += 4;
while(1){
switch(use){
case 'x':
if(qs == 2 || qs == 3)yc -= del;
else yc += del;
dy = yc-y;
pc = r-dy*dy;
xc = m*sqrt(pc)+x;
if((x < xs && x >= xc) || ( x > xs && x <= xc) ||
(y < ys && y >= yc) || ( y > ys && y <= yc) )
{
if(++qtctr > qt)return;
if(++qs > 4)qs=1;
if(qs == 2 || qs == 3)m= -1;
else m=1;
flg=1;
}
cont(xc,yc);
xs = xc;
ys = yc;
if(qs == qf && flg == 1)
switch(qf){
case 3:
case 4:
if(xs >= x1)return;
continue;
case 1:
case 2:
if(xs <= x1)return;
}
continue;
case 'y':
if(qs > 2)xc += del;
else xc -= del;
dx = xc-x;
pc = r-dx*dx;
yc = m*sqrt(pc)+y;
if((x < xs && x >= xc) || ( x > xs && x <= xc ) ||
(y < ys && y >= yc) || (y > ys && y <= yc) )
{
if(++qtctr > qt)return;
if(++qs > 4)qs=1;
if(qs > 2)m = -1;
else m = 1;
flg=1;
}
cont(xc,yc);
xs = xc;
ys = yc;
if(qs == qf && flg == 1)
switch(qs){
case 1:
case 4:
if(ys >= y1)return;
continue;
case 2:
case 3:
if(ys <= y1)return;
}
}
}
}
int
quad(int x, int y, int xp, int yp)
{
if(x < xp)
if(y <= yp)return(1);
else return(4);
else if(x > xp)
if(y < yp)return(2);
else return(3);
else if(y < yp)return(2);
else return(4);
}
int
abs(int a)
{
if(a < 0)return(-a);
return(a);
}
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.2 $"
extern void move(int, int);
extern void cont(int, int);
void
box(int x0, int y0, int x1, int y1)
{
move(x0, y0);
cont(x0, y1);
cont(x1, y1);
cont(x1, y0);
cont(x0, y0);
move(x1, y1);
}
+16
View File
@@ -0,0 +1,16 @@
/* 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 "$Revision: 1.2 $"
extern void arc(int, int, int, int, int, int);
void
circle(int x, int y, int r)
{
arc(x,y,x+r,y,x+r,y);
}
+26
View File
@@ -0,0 +1,26 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void reset(void);
extern void putch(int);
void
closevt(void)
{
putch(037);
fflush(stdout);
}
void
closepl(void){
putch(037);
fflush(stdout);
}
+14
View File
@@ -0,0 +1,14 @@
/* 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 "$Revision: 1.2 $"
void
dot(void)
{
}
+32
View File
@@ -0,0 +1,32 @@
/* 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 "$Revision: 1.2 $"
#include <unistd.h>
extern int putch(int);
extern int ohiy;
extern int ohix;
extern int oloy;
extern int oextra;
void
erase(void)
{
int i;
putch(033);
putch(014);
ohiy= -1;
ohix = -1;
oextra = -1;
oloy = -1;
sleep(2);
return;
}
+39
View File
@@ -0,0 +1,39 @@
/* 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 "$Revision: 1.2 $"
extern void putch(int);
#define N 0104
#define E 0101
#define NE 0105
#define S 0110
#define W 0102
#define SW 0112
/* arrange by incremental plotting that an initial
* character such as +, X, *, etc will fall
* right on the point, and undo it so that further
* labels will fall properly in place
*/
char lbl_mv[] = {
036,040,S,S,S,S,S,S,SW,SW,SW,SW,SW,SW,SW,SW,SW,SW,037,0
};
char lbl_umv[] = {
036,040,N,N,N,N,N,N,NE,NE,NE,NE,NE,NE,NE,NE,NE,NE,037,0
};
label(char *s)
{
register i,c;
for(i=0; c=lbl_mv[i]; i++)
putch(c);
for(i=0; c=s[i]; i++)
putch(c);
for(i=0; c=lbl_umv[i]; i++)
putch(c);
}
+4
View File
@@ -0,0 +1,4 @@
#
# Global library definitions
#
LIBRARY_COPTS= -fullwarn
+18
View File
@@ -0,0 +1,18 @@
/* 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 "$Revision: 1.2 $"
extern void move(int, int);
extern void cont(int, int);
void
line(int x0, int y0, int x1, int y1)
{
move(x0,y0);
cont(x1,y1);
}
+29
View File
@@ -0,0 +1,29 @@
/* 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 "$Revision: 1.2 $"
extern void putch(int);
linemod(char *s)
{
char c;
putch(033);
switch(s[0]){
case 'l':
c = 'd';
break;
case 'd':
if(s[3] != 'd')c='a';
else c='b';
break;
case 's':
if(s[5] != '\0')c='c';
else c='`';
}
putch(c);
}
+18
View File
@@ -0,0 +1,18 @@
/* 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 "$Revision: 1.2 $"
extern void cont(int, int);
extern void putch(int);
void
move(int xi, int yi)
{
putch(035);
cont(xi,yi);
}
+18
View File
@@ -0,0 +1,18 @@
/* 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 "$Revision: 1.2 $"
void
openvt (void)
{
}
void
openpl(void)
{
}
+18
View File
@@ -0,0 +1,18 @@
/* 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 "$Revision: 1.2 $"
extern void move(int, int);
extern void cont(int, int);
void
point(int xi, int yi)
{
move(xi,yi);
cont(xi,yi);
}
+31
View File
@@ -0,0 +1,31 @@
/* 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 "$Revision: 1.2 $"
extern float scalex;
extern float scaley;
extern int scaleflag;
void
scale(char i, float x, float y)
{
switch(i) {
default:
return;
case 'c':
x *= 2.54;
y *= 2.54;
case 'i':
x /= 200;
y /= 200;
case 'u':
scalex = 1/x;
scaley = 1/y;
}
scaleflag = 1;
}
+29
View File
@@ -0,0 +1,29 @@
/* 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 "$Revision: 1.2 $"
extern float botx;
extern float boty;
extern float obotx;
extern float oboty;
extern float scalex;
extern float scaley;
extern int scaleflag;
void
space(int x0, int y0, int x1, int y1)
{
botx = 0.;
boty = 0.;
obotx = x0;
oboty = y0;
if(scaleflag)
return;
scalex = 3120./(x1-x0);
scaley = 3120./(y1-y0);
}
+76
View File
@@ -0,0 +1,76 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern int abs(int);
void putch(int);
float obotx = 0.;
float oboty = 0.;
float botx = 0.;
float boty = 0.;
float scalex = 1.;
float scaley = 1.;
int scaleflag;
int oloy = -1;
int ohiy = -1;
int ohix = -1;
int oextra = -1;
void
cont(int x, int y)
{
int hix,hiy,lox,loy,extra;
int n;
x = (x-obotx)*scalex + botx;
y = (y-oboty)*scaley + boty;
hix=(x>>7) & 037;
hiy=(y>>7) & 037;
lox = (x>>2)&037;
loy=(y>>2)&037;
extra=x&03+(y<<2)&014;
n = (abs(hix-ohix) + abs(hiy-ohiy) + 6) / 12;
if(hiy != ohiy){
putch(hiy|040);
ohiy=hiy;
}
if(hix != ohix){
if(extra != oextra){
putch(extra|0140);
oextra=extra;
}
putch(loy|0140);
putch(hix|040);
ohix=hix;
oloy=loy;
}
else{
if(extra != oextra){
putch(extra|0140);
putch(loy|0140);
oextra=extra;
oloy=loy;
}
else if(loy != oloy){
putch(loy|0140);
oloy=loy;
}
}
putch(lox|0100);
while(n--)
putch(0);
}
void
putch(int c)
{
putc(c,stdout);
}
+21
View File
@@ -0,0 +1,21 @@
#!smake
#
# Makefile for lib450.
#
#ident "$Revision: 1.2 $"
BASELIB=lib450.a
include $(ROOT)/usr/include/make/librootdefs
TARGETS=$(LIBS)
CFILES = arc.c box.c circle.c close.c dot.c erase.c label.c line.c \
linmod.c move.c open.c point.c space.c subr.c
default: $(TARGETS)
exports install: default
$(INSTALL) -F /usr/lib -m 444 $(LIBS)
include $(LIBROOTRULES)
+147
View File
@@ -0,0 +1,147 @@
/* 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 "$Revision: 1.2 $"
#include <math.h>
extern void move(int, int);
extern void cont(int, int);
int quad(int, int, int, int);
int abs(int);
int del = 20;
void
step(int d)
{
del = d;
}
void
arc(int x, int y, int x0, int y0, int x1, int y1)
{
double pc;
int flg,m,xc,yc,xs,ys,qs,qf,qt,qtctr=0;
int m0,m1;
float dx,dy,r;
char use;
dx = x-x0;
dy = y-y0;
r = dx*dx+dy*dy;
pc = r;
pc = sqrt(pc);
flg = pc/4;
if(flg == 0)step(1);
else if(flg < del)step(flg);
xc = xs = x0;
yc = ys = y0;
move(xs,ys);
if(x0 == x1 && y0 == y1)flg=0;
else flg=1;
qs = quad(x,y,x0,y0);
qf = quad(x,y,x1,y1);
if(abs(x-x1) < abs(y-y1)){
use = 'x';
if(qs == 2 || qs ==3)m = -1;
else m=1;
}
else {
use = 'y';
if(qs > 2)m= -1;
else m= 1;
}
if(qs == qf) {
m0=(y0-y)/(x0-x);
m1=(y1-y)/(x1-x);
if(m0 >= m1)qt = 4;
else qt = 0;
}
else if((qt=qf-qs) < 0)qt += 4;
while(1){
switch(use){
case 'x':
if(qs == 2 || qs == 3)yc -= del;
else yc += del;
dy = yc-y;
pc = r-dy*dy;
xc = m*sqrt(pc)+x;
if((x < xs && x >= xc) || ( x > xs && x <= xc) ||
(y < ys && y >= yc) || ( y > ys && y <= yc) )
{
if(++qtctr > qt)return;
if(++qs > 4)qs=1;
if(qs == 2 || qs == 3)m= -1;
else m=1;
flg=1;
}
cont(xc,yc);
xs = xc;
ys = yc;
if(qs == qf && flg == 1)
switch(qf){
case 3:
case 4:
if(xs >= x1)return;
continue;
case 1:
case 2:
if(xs <= x1)return;
}
continue;
case 'y':
if(qs > 2)xc += del;
else xc -= del;
dx = xc-x;
pc = r-dx*dx;
yc = m*sqrt(pc)+y;
if((x < xs && x >= xc) || ( x > xs && x <= xc ) ||
(y < ys && y >= yc) || (y > ys && y <= yc) )
{
if(++qtctr > qt)return;
if(++qs > 4)qs=1;
if(qs > 2)m = -1;
else m = 1;
flg=1;
}
cont(xc,yc);
xs = xc;
ys = yc;
if(qs == qf && flg == 1)
switch(qs){
case 1:
case 4:
if(ys >= y1)return;
continue;
case 2:
case 3:
if(ys <= y1)return;
}
}
}
}
int
quad(int x, int y, int xp, int yp)
{
if(x < xp)
if(y <= yp)return(1);
else return(4);
else if(x > xp)
if(y < yp)return(2);
else return(3);
else if(y < yp)return(2);
else return(4);
}
int
abs(int a)
{
if(a < 0)return(-a);
return(a);
}
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.2 $"
extern void move(int, int);
extern void cont(int, int);
void
box(int x0, int y0, int x1, int y1)
{
move(x0, y0);
cont(x0, y1);
cont(x1, y1);
cont(x1, y0);
cont(x0, y0);
move(x1, y1);
}
+16
View File
@@ -0,0 +1,16 @@
/* 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 "$Revision: 1.2 $"
extern void arc(int, int, int, int, int, int);
void
circle(int x, int y, int r)
{
arc(x,y,x+r,y,x+r,y);
}
+26
View File
@@ -0,0 +1,26 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
extern void reset(void);
void closepl(void);
void
closevt(void)
{
closepl();
}
void
closepl(void)
{
fflush(stdout);
reset();
}
+37
View File
@@ -0,0 +1,37 @@
/* 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 "$Revision: 1.1 $"
#include <termio.h>
/* gsi plotting output routines */
# define DOWN 012
# define UP 013
# define LEFT 010
# define RIGHT 040
# define BEL 007
# define ESC 033
# define ACK 006
#define PLOTIN 063
#define PLOTOUT 064
# define CR 015
# define FF 014
# define VERTRESP 48
# define HORZRESP 60.
# define VERTRES 8.
# define HORZRES 6.
/* down is line feed, up is reverse line feed,
left is backspace, right is space. 48 points per inch
vertically, 60 horizontally */
extern int xnow, ynow;
extern struct termio ITTY, PTTY;
extern int OUTF;
extern float HEIGHT, WIDTH, OFFSET;
extern int xscale, xoffset, yscale;
extern float botx, boty, obotx, oboty, scalex,scaley;
+13
View File
@@ -0,0 +1,13 @@
/* 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 "$Revision: 1.2 $"
void
dot(void)
{
}
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.2 $"
#include "con.h"
extern void spew(int);
void
erase(void)
{
int i;
for(i=0; i<11*(VERTRESP/VERTRES); i++)
spew(DOWN);
return;
}
+24
View File
@@ -0,0 +1,24 @@
/* 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 "$Revision: 1.2 $"
#include "con.h"
extern void spew(int);
void
label(char *s)
{
int i,c;
while((c = *s++) != '\0'){
xnow += HORZRES;
spew(c);
}
return;
}
+4
View File
@@ -0,0 +1,4 @@
#
# Global library definitions
#
LIBRARY_COPTS= -fullwarn
+79
View File
@@ -0,0 +1,79 @@
/* 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 "$Revision: 1.2 $"
#include "con.h"
#include "math.h"
/* external declarations */
extern int xconv(int);
extern int yconv(int);
extern int xsc(int);
extern int ysc(int);
extern void movep(int, int);
extern void inplot(void);
extern int abval(int);
extern void spew(int);
extern void outplot(void);
extern float dist2(int, int, int, int);
/* foward declarations */
void iline(int, int, int, int);
void
line(int x0, int y0, int x1, int y1)
{
iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1)));
return;
}
void
cont(int x0, int y0)
{
iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0)));
return;
}
void
iline(int cx0, int cy0, int cx1, int cy1)
{
int maxp,tt,j,np;
char chx,chy;
float xd,yd;
movep(cx0,cy0);
maxp = sqrt(dist2(cx0,cy0,cx1,cy1))/2.;
xd = cx1-cx0;
yd = cy1-cy0;
if(xd >= 0)chx = RIGHT;
else chx = LEFT;
if(yd >= 0)chy = UP;
else chy = DOWN;
if(maxp == 0){
xd=0;
yd=0;
}
else{
xd /=maxp;
yd /=maxp;
}
inplot();
for (tt=0; tt<=maxp; tt++){
j= cx0+xd*tt-xnow;
xnow += j;
j = abval(j);
while(j-- > 0)spew(chx);
j = cy0+yd*tt-ynow;
ynow += j;
j = abval(j);
while(j-- > 0)spew(chy);
spew ('.');
}
outplot();
return;
}
+13
View File
@@ -0,0 +1,13 @@
/* 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 "$Revision: 1.2 $"
void
linemod(void)
{
}
+23
View File
@@ -0,0 +1,23 @@
/* 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 "$Revision: 1.2 $"
/* external declarations */
extern int xconv(int);
extern int yconv(int);
extern int xsc(int);
extern int ysc(int);
extern void movep(int, int);
void
move(int xi, int yi)
{
movep(xconv(xsc(xi)),yconv(ysc(yi)));
return;
}
+77
View File
@@ -0,0 +1,77 @@
/* 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 "$Revision: 1.2 $"
#include <termio.h>
#include <signal.h>
#include <stdio.h>
/* gsi plotting output routines */
# define DOWN 012
# define UP 013
# define LEFT 010
# define RIGHT 040
# define BEL 007
# define ACK 006
#define PLOTIN 063
#define PLOTOUT 064
# define CR 015
# define FF 014
# define VERTRESP 48
# define HORZRESP 60.
# define HORZRES 6.
# define VERTRES 8.
/* vert and horiz spacing */
#define ESC 033
#define RS 036
#define US 037
#define HT 011
/* down is line feed, up is reverse line feed,
left is backspace, right is space. 48 points per inch
vertically, 60 horizontally */
int xnow, ynow;
struct termio ITTY,PTTY;
int OUTF;
float HEIGHT = 6.0, WIDTH = 6.0, OFFSET = 0.0;
int xscale, xoffset, yscale;
float botx = 0., boty = 0., obotx = 0., oboty = 0.;
float scalex = 1., scaley = 1.;
void
openpl(void)
{
void reset();
xnow = ynow = 0;
OUTF = 1;
printf("\r");
ioctl(OUTF, TCGETA, &ITTY);
signal (SIGINT, reset);
PTTY = ITTY;
PTTY.c_oflag &= ~(ONLCR|OCRNL|ONOCR|ONLRET);
PTTY.c_cflag |= CSTOPB;
ioctl(OUTF, TCSETAW,&PTTY);
/* set vert and horiz spacing to 6 and 10 */
putchar(ESC); /* set vert spacing to 6 lpi */
putchar(RS);
putchar(HT);
putchar(ESC); /* set horiz spacing to 10 cpi */
putchar(US);
putchar(CR);
/* initialize constants */
xscale = 4096./(HORZRESP * WIDTH);
yscale = 4096 /(VERTRESP * HEIGHT);
xoffset = OFFSET * HORZRESP;
return;
}
void
openvt(void)
{
openpl();
}
+19
View File
@@ -0,0 +1,19 @@
/* 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 "$Revision: 1.2 $"
extern void move(int, int);
extern void label(char *);
void
point(int xi, int yi)
{
move(xi,yi);
label(".");
return;
}
+21
View File
@@ -0,0 +1,21 @@
/* 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 "$Revision: 1.2 $"
# include "con.h"
void
space(int x0, int y0, int x1, int y1)
{
botx = -2047.;
boty = -2047.;
obotx = x0;
oboty = y0;
scalex = 4096./(x1-x0);
scaley = 4096./(y1-y0);
}
+147
View File
@@ -0,0 +1,147 @@
/* 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 "$Revision: 1.2 $"
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include "con.h"
extern void move(int, int);
void spew(int);
int
abval(int q)
{
return (q>=0 ? q : -q);
}
int
xconv(int xp)
{
/* x position input is -2047 to +2047, output must be 0 to PAGSIZ*HORZRES */
xp += 2048;
/* the computation is newx = xp*(PAGSIZ*HORZRES)/4096 */
return (xoffset + xp /xscale);
}
int
yconv(int yp)
{
/* see description of xconv */
yp += 2048;
return (yp / yscale);
}
void
inplot(void)
{
spew(ESC);
spew(PLOTIN);
}
void
outplot(void)
{
spew(ESC);
spew(PLOTOUT);
fflush(stdout);
}
void
spew(int ch)
{
if(ch == UP){
putc(ESC,stdout);
ch = DOWN;
}
putc(ch, stdout);
}
void
tobotleft(void)
{
move(-2048,-2048);
}
void
reset(void)
{
signal(SIGINT,SIG_IGN);
outplot();
ioctl(OUTF, TCSETAW, &ITTY);
exit(0);
}
float
dist2(int x1, int y1, int x2, int y2)
{
float t,v;
t = x2-x1;
v = y1-y2;
return (t*t+v*v);
}
void
swap(int *pa, int *pb)
{
int t;
t = *pa;
*pa = *pb;
*pb = t;
}
void
movep(int xg, int yg)
{
int i,ch;
if((xg == xnow) && (yg == ynow))return;
/* if we need to go to left margin, just CR */
if (xg < xnow/2)
{
spew(CR);
xnow = 0;
}
i = (xg-xnow)/HORZRES;
if(xnow < xg)ch = RIGHT;
else ch = LEFT;
xnow += i*HORZRES;
i = abval(i);
while(i--)spew(ch);
i = abval(xg-xnow);
inplot();
while(i--) spew(ch);
outplot();
i=(yg-ynow)/VERTRES;
if(ynow < yg)ch = UP;
else ch = DOWN;
ynow += i*VERTRES;
i = abval(i);
while(i--)spew(ch);
i=abval(yg-ynow);
inplot();
while(i--)spew(ch);
outplot();
xnow = xg; ynow = yg;
}
int
xsc(int xi)
{
int xa;
xa = (xi - obotx) * scalex + botx;
return(xa);
}
int
ysc(int yi)
{
int ya;
ya = (yi - oboty) *scaley +boty;
return(ya);
}
+22
View File
@@ -0,0 +1,22 @@
#!smake
#
# Makefile for libvt0.
#
#ident "$Revision: 1.3 $"
OBJECT_STYLE=32
BASELIB=libvt0.a
include $(ROOT)/usr/include/make/librootdefs
TARGETS=$(LIBS)
CFILES = arc.c box.c circle.c close.c dot.c erase.c frame.c label.c line.c \
linmod.c move.c open.c point.c space.c subr.c
default: $(TARGETS)
exports install: default
$(INSTALL) -F /usr/lib -m 444 $(LIBS)
include $(LIBROOTRULES)
+21
View File
@@ -0,0 +1,21 @@
/* 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 "$Revision: 1.2 $"
#include <unistd.h>
extern int vti;
void
arc(int xi, int yi, int x0, int y0, int x1, int y1)
{
char c;
c = 6;
write(vti,&c,1);
write(vti,&xi,12);
}
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.2 $"
extern void move(int, int);
extern void cont(int, int);
void
box(int x0, int y0, int x1, int y1)
{
move(x0, y0);
cont(x0, y1);
cont(x1, y1);
cont(x1, y0);
cont(x0, y0);
move(x1, y1);
}
+22
View File
@@ -0,0 +1,22 @@
/* 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 "$Revision: 1.3 $"
#include <unistd.h>
extern int vti;
/* ARGSUSED */
void
circle(int x, int y, int r)
{
char c;
c = 5;
write(vti,&c,1);
write(vti,&x,6);
}
+24
View File
@@ -0,0 +1,24 @@
/* 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 "$Revision: 1.2 $"
#include <unistd.h>
extern int vti;
void
closevt(void)
{
close(vti);
}
void
closepl(void)
{
close(vti);
}
+26
View File
@@ -0,0 +1,26 @@
/* 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 "$Revision: 1.2 $"
#include <unistd.h>
extern int xsc(int);
extern int ysc(int);
extern int vti;
dot(int xi, int yi, int dx, int n, int pat[])
{
struct {char pad,c; int xi,yi,dx;} p;
p.c = 7;
p.xi = xsc(xi);
p.yi = ysc(yi);
p.dx = xsc(dx);
write(vti,&p.c,7);
write(vti,pat,n?n&0377:256);
}
+20
View File
@@ -0,0 +1,20 @@
/* 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 "$Revision: 1.2 $"
#include <unistd.h>
extern vti;
void
erase(void)
{
int i;
i=0401;
write(vti,&i,2);
}
+19
View File
@@ -0,0 +1,19 @@
/* 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 "$Revision: 1.2 $"
#include <unistd.h>
extern int vti;
void
frame(int n)
{
n=n&0377 | 02000;
write(vti,&n,2);
}
+23
View File
@@ -0,0 +1,23 @@
/* 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 "$Revision: 1.2 $"
#include <unistd.h>
extern int vti;
label(char *s)
{
int i, o;
o = 01401;
write(vti, &o, 2);
for(i=0; s[i++]; )
;
write(vti, s, i);
}
+4
View File
@@ -0,0 +1,4 @@
#
# Global library definitions
#
LIBRARY_COPTS= -fullwarn
+35
View File
@@ -0,0 +1,35 @@
/* 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 "$Revision: 1.2 $"
#include <unistd.h>
extern int xsc(int);
extern int ysc(int);
extern int vti;
extern int xnow,ynow;
void
line(int x0, int y0, int x1, int y1)
{
struct{char x,c; int x0,y0,x1,y1;} p;
p.c = 3;
p.x0 = xsc(x0);
p.y0 = ysc(y0);
p.x1 = xnow = xsc(x1);
p.y1 = ynow = ysc(y1);
write(vti,&p.c,9);
}
void
cont(int x0, int y0)
{
line(xnow,ynow,xsc(x0),ysc(y0));
return;
}
+13
View File
@@ -0,0 +1,13 @@
/* 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 "$Revision: 1.2 $"
void
linemod(char *s)
{
}
+26
View File
@@ -0,0 +1,26 @@
/* 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 "$Revision: 1.2 $"
#include <unistd.h>
extern int xsc(int);
extern int ysc(int);
extern int vti;
extern int xnow,ynow;
void
move(int xi, int yi)
{
struct {char pad,c; int x,y;} p;
p.c = 9;
p.x = xnow = xsc(xi);
p.y = ynow = ysc(yi);
write(vti,&p.c,5);
}
+34
View File
@@ -0,0 +1,34 @@
/* 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 "$Revision: 1.2 $"
#include <fcntl.h>
int xnow;
int ynow;
float boty = 0.;
float botx = 0.;
float oboty = 0.;
float obotx = 0.;
float scalex = 1.;
float scaley = 1.;
int vti = -1;
void
openvt(void)
{
vti = open("/dev/vt0",1);
return;
}
void
openpl(void)
{
vti = open("/dev/vt0",1);
return;
}

Some files were not shown because too many files have changed in this diff Show More