1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*0Sstevel@tonic-gate /* All Rights Reserved */ 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate #include <stdio.h> 34*0Sstevel@tonic-gate #include <signal.h> 35*0Sstevel@tonic-gate #include <values.h> 36*0Sstevel@tonic-gate #include <sys/types.h> 37*0Sstevel@tonic-gate #include <sys/stat.h> 38*0Sstevel@tonic-gate #include <fcntl.h> 39*0Sstevel@tonic-gate #include <sgtty.h> 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate #define NB 88 42*0Sstevel@tonic-gate #define BSIZ 512 43*0Sstevel@tonic-gate #define mapx(x) ((1536*((x)-botx)/del)+centx) 44*0Sstevel@tonic-gate #define mapy(y) ((1536*(del-(y)+boty)/del)-centy) 45*0Sstevel@tonic-gate #define SOLID -1 46*0Sstevel@tonic-gate #define DOTTED 014 47*0Sstevel@tonic-gate #define SHORTDASHED 034 48*0Sstevel@tonic-gate #define DOTDASHED 054 49*0Sstevel@tonic-gate #define LONGDASHED 074 50*0Sstevel@tonic-gate #define SETSTATE (('v'<<8)+1) 51*0Sstevel@tonic-gate #define NEG_MASK (MAXINT<<(2*BITS(char))) 52*0Sstevel@tonic-gate #define MAXCHAR ((char)~((char)(1<<BITS(char)-1))) 53*0Sstevel@tonic-gate #define BUILDINT(ubyte, lbyte) \ 54*0Sstevel@tonic-gate ubyte > MAXCHAR \ 55*0Sstevel@tonic-gate ? (ubyte << BITS(char))|lbyte|NEG_MASK \ 56*0Sstevel@tonic-gate : (ubyte << BITS(char))|lbyte 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate int linmod = SOLID; 59*0Sstevel@tonic-gate int again; 60*0Sstevel@tonic-gate int done1; 61*0Sstevel@tonic-gate extern char chrtab[][16]; 62*0Sstevel@tonic-gate short plotcom[] = { 0200, 0, 0, 0 }; 63*0Sstevel@tonic-gate short eotcom[] = { 0210, 0, 0, 0 }; 64*0Sstevel@tonic-gate char blocks [NB][BSIZ]; 65*0Sstevel@tonic-gate short obuf[264]; 66*0Sstevel@tonic-gate int lastx; 67*0Sstevel@tonic-gate int lasty; 68*0Sstevel@tonic-gate double topx = 1536; 69*0Sstevel@tonic-gate double topy = 1536; 70*0Sstevel@tonic-gate double botx = 0; 71*0Sstevel@tonic-gate double boty = 0; 72*0Sstevel@tonic-gate int centx; 73*0Sstevel@tonic-gate int centy; 74*0Sstevel@tonic-gate double delx = 1536; 75*0Sstevel@tonic-gate double dely = 1536; 76*0Sstevel@tonic-gate double del = 1536; 77*0Sstevel@tonic-gate int bflag; 78*0Sstevel@tonic-gate int fflag; 79*0Sstevel@tonic-gate char *banname; 80*0Sstevel@tonic-gate FILE *vpstr; 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate struct buf { 83*0Sstevel@tonic-gate int bno; 84*0Sstevel@tonic-gate char *block; 85*0Sstevel@tonic-gate }; 86*0Sstevel@tonic-gate struct buf bufs[NB]; 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate int in, out; 89*0Sstevel@tonic-gate char picname[] = "/var/tmp/rasterXXXXXX"; 90*0Sstevel@tonic-gate char *picture; 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate main(argc, argv) 93*0Sstevel@tonic-gate char **argv; 94*0Sstevel@tonic-gate { 95*0Sstevel@tonic-gate extern void onintr(); 96*0Sstevel@tonic-gate register i; 97*0Sstevel@tonic-gate extern char *optarg; 98*0Sstevel@tonic-gate extern int optind; 99*0Sstevel@tonic-gate register int c; 100*0Sstevel@tonic-gate char *fname; 101*0Sstevel@tonic-gate char *mktemp(); 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate while ((c = getopt(argc, argv, "e:b:")) != EOF) 104*0Sstevel@tonic-gate switch (c) { 105*0Sstevel@tonic-gate case 'b': 106*0Sstevel@tonic-gate bflag++; 107*0Sstevel@tonic-gate banname = optarg; 108*0Sstevel@tonic-gate break; 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate case 'e': 111*0Sstevel@tonic-gate fname = optarg; 112*0Sstevel@tonic-gate fflag++; 113*0Sstevel@tonic-gate break; 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate case '?': 116*0Sstevel@tonic-gate fprintf(stderr, 117*0Sstevel@tonic-gate "usage: vplot [ -f raster ] [ file ]\n"); 118*0Sstevel@tonic-gate exit(1); 119*0Sstevel@tonic-gate } 120*0Sstevel@tonic-gate if (fflag) { 121*0Sstevel@tonic-gate if ((in = open(fname, O_RDONLY)) < 0) { 122*0Sstevel@tonic-gate fprintf(stderr, "vplot: cannot open %s\n", fname); 123*0Sstevel@tonic-gate exit(1); 124*0Sstevel@tonic-gate } 125*0Sstevel@tonic-gate putpict(); 126*0Sstevel@tonic-gate exit(0); 127*0Sstevel@tonic-gate } 128*0Sstevel@tonic-gate if (optind < argc) 129*0Sstevel@tonic-gate if (freopen(argv[optind], "r", stdin) == NULL) { 130*0Sstevel@tonic-gate fprintf(stderr, 131*0Sstevel@tonic-gate "vplot: cannot open %s\n", argv[optind]); 132*0Sstevel@tonic-gate exit(1); 133*0Sstevel@tonic-gate } 134*0Sstevel@tonic-gate signal(SIGTERM, onintr); 135*0Sstevel@tonic-gate if (signal(SIGINT, SIG_IGN) != SIG_IGN) 136*0Sstevel@tonic-gate signal(SIGINT, onintr); 137*0Sstevel@tonic-gate if (signal(SIGHUP, SIG_IGN) != SIG_IGN) 138*0Sstevel@tonic-gate signal(SIGHUP, onintr); 139*0Sstevel@tonic-gate another: 140*0Sstevel@tonic-gate for (i = 0; i < NB; i++) { 141*0Sstevel@tonic-gate bufs[i].bno = -1; 142*0Sstevel@tonic-gate bufs[i].block = blocks[i]; 143*0Sstevel@tonic-gate } 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate if ((picture = mktemp(picname)) == NULL) { 146*0Sstevel@tonic-gate fprintf(stderr, "vplot: cannot create unique tmp. file name\n"); 147*0Sstevel@tonic-gate exit(1); 148*0Sstevel@tonic-gate } 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate if ((out = open(picture, (O_WRONLY|O_CREAT|O_TRUNC|O_EXCL), 151*0Sstevel@tonic-gate (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH))) == -1) { 152*0Sstevel@tonic-gate fprintf(stderr, "vplot: cannot open %s\n", picture); 153*0Sstevel@tonic-gate exit(1); 154*0Sstevel@tonic-gate } 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate zseek(out, 32*32); 157*0Sstevel@tonic-gate write(out, blocks[0], BSIZ); 158*0Sstevel@tonic-gate /* 159*0Sstevel@tonic-gate * delete following code when filsys deals properly with 160*0Sstevel@tonic-gate * holes in files 161*0Sstevel@tonic-gate */ 162*0Sstevel@tonic-gate for (i = 0; i < 512; i++) 163*0Sstevel@tonic-gate blocks[0][i] = 0; 164*0Sstevel@tonic-gate zseek(out, 0); 165*0Sstevel@tonic-gate for (i = 0; i < 32*32; i++) 166*0Sstevel@tonic-gate write(out, blocks[0], 512); 167*0Sstevel@tonic-gate getpict(); 168*0Sstevel@tonic-gate for (i = 0; i < NB; i++) 169*0Sstevel@tonic-gate if (bufs[i].bno != -1) { 170*0Sstevel@tonic-gate zseek(out, bufs[i].bno); 171*0Sstevel@tonic-gate write(out, bufs[i].block, BSIZ); 172*0Sstevel@tonic-gate } 173*0Sstevel@tonic-gate putpict(); 174*0Sstevel@tonic-gate if (again) { 175*0Sstevel@tonic-gate close(out); 176*0Sstevel@tonic-gate goto another; 177*0Sstevel@tonic-gate } 178*0Sstevel@tonic-gate unlink(picture); 179*0Sstevel@tonic-gate exit(0); 180*0Sstevel@tonic-gate } 181*0Sstevel@tonic-gate 182*0Sstevel@tonic-gate getpict() 183*0Sstevel@tonic-gate { 184*0Sstevel@tonic-gate register x1, y1; 185*0Sstevel@tonic-gate 186*0Sstevel@tonic-gate again = 0; 187*0Sstevel@tonic-gate for (;;) 188*0Sstevel@tonic-gate switch (x1 = getc(stdin)) { 189*0Sstevel@tonic-gate case 's': 190*0Sstevel@tonic-gate botx = getw(stdin); 191*0Sstevel@tonic-gate boty = getw(stdin); 192*0Sstevel@tonic-gate topx = getw(stdin); 193*0Sstevel@tonic-gate topy = getw(stdin); 194*0Sstevel@tonic-gate delx = topx-botx; 195*0Sstevel@tonic-gate dely = topy-boty; 196*0Sstevel@tonic-gate if (dely/delx > 1536./2048.) 197*0Sstevel@tonic-gate del = dely; 198*0Sstevel@tonic-gate else 199*0Sstevel@tonic-gate del = delx * (1566./2048.); 200*0Sstevel@tonic-gate centx = 0; 201*0Sstevel@tonic-gate centx = (2048 - mapx(topx)) / 2; 202*0Sstevel@tonic-gate centy = 0; 203*0Sstevel@tonic-gate centy = mapy(topy) / 2; 204*0Sstevel@tonic-gate continue; 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate case 'l': 207*0Sstevel@tonic-gate done1 |= 01; 208*0Sstevel@tonic-gate x1 = mapx(getw(stdin)); 209*0Sstevel@tonic-gate y1 = mapy(getw(stdin)); 210*0Sstevel@tonic-gate lastx = mapx(getw(stdin)); 211*0Sstevel@tonic-gate lasty = mapy(getw(stdin)); 212*0Sstevel@tonic-gate line(x1, y1, lastx, lasty); 213*0Sstevel@tonic-gate continue; 214*0Sstevel@tonic-gate 215*0Sstevel@tonic-gate case 'm': 216*0Sstevel@tonic-gate lastx = mapx(getw(stdin)); 217*0Sstevel@tonic-gate lasty = mapy(getw(stdin)); 218*0Sstevel@tonic-gate continue; 219*0Sstevel@tonic-gate 220*0Sstevel@tonic-gate case 't': 221*0Sstevel@tonic-gate done1 |= 01; 222*0Sstevel@tonic-gate while ((x1 = getc(stdin)) != '\n') 223*0Sstevel@tonic-gate plotch(x1); 224*0Sstevel@tonic-gate continue; 225*0Sstevel@tonic-gate 226*0Sstevel@tonic-gate case 'e': 227*0Sstevel@tonic-gate if (done1) { 228*0Sstevel@tonic-gate again++; 229*0Sstevel@tonic-gate return; 230*0Sstevel@tonic-gate } 231*0Sstevel@tonic-gate continue; 232*0Sstevel@tonic-gate 233*0Sstevel@tonic-gate case 'p': 234*0Sstevel@tonic-gate done1 |= 01; 235*0Sstevel@tonic-gate lastx = mapx(getw(stdin)); 236*0Sstevel@tonic-gate lasty = mapy(getw(stdin)); 237*0Sstevel@tonic-gate point(lastx, lasty); 238*0Sstevel@tonic-gate point(lastx+1, lasty); 239*0Sstevel@tonic-gate point(lastx, lasty+1); 240*0Sstevel@tonic-gate point(lastx+1, lasty+1); 241*0Sstevel@tonic-gate continue; 242*0Sstevel@tonic-gate 243*0Sstevel@tonic-gate case 'n': 244*0Sstevel@tonic-gate done1 |= 01; 245*0Sstevel@tonic-gate x1 = mapx(getw(stdin)); 246*0Sstevel@tonic-gate y1 = mapy(getw(stdin)); 247*0Sstevel@tonic-gate line(lastx, lasty, x1, y1); 248*0Sstevel@tonic-gate lastx = x1; 249*0Sstevel@tonic-gate lasty = y1; 250*0Sstevel@tonic-gate continue; 251*0Sstevel@tonic-gate 252*0Sstevel@tonic-gate case 'f': 253*0Sstevel@tonic-gate getw(stdin); 254*0Sstevel@tonic-gate getc(stdin); 255*0Sstevel@tonic-gate switch (getc(stdin)) { 256*0Sstevel@tonic-gate case 't': 257*0Sstevel@tonic-gate linmod = DOTTED; 258*0Sstevel@tonic-gate break; 259*0Sstevel@tonic-gate default: 260*0Sstevel@tonic-gate case 'i': 261*0Sstevel@tonic-gate linmod = SOLID; 262*0Sstevel@tonic-gate break; 263*0Sstevel@tonic-gate case 'g': 264*0Sstevel@tonic-gate linmod = LONGDASHED; 265*0Sstevel@tonic-gate break; 266*0Sstevel@tonic-gate case 'r': 267*0Sstevel@tonic-gate linmod = SHORTDASHED; 268*0Sstevel@tonic-gate break; 269*0Sstevel@tonic-gate case 'd': 270*0Sstevel@tonic-gate linmod = DOTDASHED; 271*0Sstevel@tonic-gate break; 272*0Sstevel@tonic-gate } 273*0Sstevel@tonic-gate while ((x1 = getc(stdin)) != '\n') 274*0Sstevel@tonic-gate if (x1 == -1) 275*0Sstevel@tonic-gate return; 276*0Sstevel@tonic-gate continue; 277*0Sstevel@tonic-gate 278*0Sstevel@tonic-gate case 'd': 279*0Sstevel@tonic-gate getw(stdin); 280*0Sstevel@tonic-gate getw(stdin); 281*0Sstevel@tonic-gate getw(stdin); 282*0Sstevel@tonic-gate x1 = getw(stdin); 283*0Sstevel@tonic-gate while (--x1 >= 0) 284*0Sstevel@tonic-gate getw(stdin); 285*0Sstevel@tonic-gate continue; 286*0Sstevel@tonic-gate 287*0Sstevel@tonic-gate case -1: 288*0Sstevel@tonic-gate return; 289*0Sstevel@tonic-gate 290*0Sstevel@tonic-gate default: 291*0Sstevel@tonic-gate printf("Botch\n"); 292*0Sstevel@tonic-gate return; 293*0Sstevel@tonic-gate } 294*0Sstevel@tonic-gate } 295*0Sstevel@tonic-gate 296*0Sstevel@tonic-gate plotch(c) 297*0Sstevel@tonic-gate register c; 298*0Sstevel@tonic-gate { 299*0Sstevel@tonic-gate register j; 300*0Sstevel@tonic-gate register char *cp; 301*0Sstevel@tonic-gate int i; 302*0Sstevel@tonic-gate 303*0Sstevel@tonic-gate if (c < ' ' || c > 0177) 304*0Sstevel@tonic-gate return; 305*0Sstevel@tonic-gate cp = chrtab[c-' ']; 306*0Sstevel@tonic-gate for (i = -16; i < 16; i += 2) { 307*0Sstevel@tonic-gate c = *cp++; 308*0Sstevel@tonic-gate for (j = 7; j >= 0; --j) 309*0Sstevel@tonic-gate if ((c>>j)&1) { 310*0Sstevel@tonic-gate point(lastx+6-j*2, lasty+i); 311*0Sstevel@tonic-gate point(lastx+7-j*2, lasty+i); 312*0Sstevel@tonic-gate point(lastx+6-j*2, lasty+i+1); 313*0Sstevel@tonic-gate point(lastx+7-j*2, lasty+i+1); 314*0Sstevel@tonic-gate } 315*0Sstevel@tonic-gate } 316*0Sstevel@tonic-gate lastx += 16; 317*0Sstevel@tonic-gate } 318*0Sstevel@tonic-gate 319*0Sstevel@tonic-gate int f; /* versatec file number */ 320*0Sstevel@tonic-gate putpict() 321*0Sstevel@tonic-gate { 322*0Sstevel@tonic-gate register x; 323*0Sstevel@tonic-gate register short *ip, *op; 324*0Sstevel@tonic-gate int y; 325*0Sstevel@tonic-gate 326*0Sstevel@tonic-gate if (f == 0) { 327*0Sstevel@tonic-gate f = open("/dev/vp", O_WRONLY); 328*0Sstevel@tonic-gate if (f < 0) { 329*0Sstevel@tonic-gate fprintf(stderr, "Cannot open vp\n"); 330*0Sstevel@tonic-gate unlink(picture); 331*0Sstevel@tonic-gate exit(1); 332*0Sstevel@tonic-gate } 333*0Sstevel@tonic-gate vpstr = fdopen(f, "w"); 334*0Sstevel@tonic-gate if (bflag) { 335*0Sstevel@tonic-gate banner(vpstr, banname); 336*0Sstevel@tonic-gate fflush(vpstr); 337*0Sstevel@tonic-gate } 338*0Sstevel@tonic-gate ioctl(f, TIOCSETP, plotcom); 339*0Sstevel@tonic-gate } 340*0Sstevel@tonic-gate op = obuf; 341*0Sstevel@tonic-gate lseek(in, 0L, 0); 342*0Sstevel@tonic-gate for (y = 0; y < 2048; y++) { 343*0Sstevel@tonic-gate if ((y&077) == 0) 344*0Sstevel@tonic-gate read(in, blocks[0], 32*BSIZ); 345*0Sstevel@tonic-gate for (x = 0; x < 32; x++) { 346*0Sstevel@tonic-gate ip = (short *)&blocks[x][(y&077)<<3]; 347*0Sstevel@tonic-gate *op++ = *ip++; 348*0Sstevel@tonic-gate *op++ = *ip++; 349*0Sstevel@tonic-gate *op++ = *ip++; 350*0Sstevel@tonic-gate *op++ = *ip++; 351*0Sstevel@tonic-gate } 352*0Sstevel@tonic-gate *op++ = 0; 353*0Sstevel@tonic-gate *op++ = 0; 354*0Sstevel@tonic-gate *op++ = 0; 355*0Sstevel@tonic-gate *op++ = 0; 356*0Sstevel@tonic-gate if (y&1) { 357*0Sstevel@tonic-gate write(f, (char *)obuf, sizeof (obuf)); 358*0Sstevel@tonic-gate op = obuf; 359*0Sstevel@tonic-gate } 360*0Sstevel@tonic-gate } 361*0Sstevel@tonic-gate } 362*0Sstevel@tonic-gate 363*0Sstevel@tonic-gate line(x0, y0, x1, y1) 364*0Sstevel@tonic-gate register x0, y0; 365*0Sstevel@tonic-gate { 366*0Sstevel@tonic-gate int dx, dy; 367*0Sstevel@tonic-gate int xinc, yinc; 368*0Sstevel@tonic-gate register res1; 369*0Sstevel@tonic-gate int res2; 370*0Sstevel@tonic-gate int slope; 371*0Sstevel@tonic-gate 372*0Sstevel@tonic-gate xinc = 1; 373*0Sstevel@tonic-gate yinc = 1; 374*0Sstevel@tonic-gate if ((dx = x1-x0) < 0) { 375*0Sstevel@tonic-gate xinc = -1; 376*0Sstevel@tonic-gate dx = -dx; 377*0Sstevel@tonic-gate } 378*0Sstevel@tonic-gate if ((dy = y1-y0) < 0) { 379*0Sstevel@tonic-gate yinc = -1; 380*0Sstevel@tonic-gate dy = -dy; 381*0Sstevel@tonic-gate } 382*0Sstevel@tonic-gate slope = xinc*yinc; 383*0Sstevel@tonic-gate res1 = 0; 384*0Sstevel@tonic-gate res2 = 0; 385*0Sstevel@tonic-gate if (dx >= dy) 386*0Sstevel@tonic-gate while (x0 != x1) { 387*0Sstevel@tonic-gate if ((x0 + slope*y0) & linmod) 388*0Sstevel@tonic-gate if (((x0>>6) + ((y0&~077)>>1)) == bufs[0].bno) 389*0Sstevel@tonic-gate bufs[0].block[((y0&077)<<3)+((x0>>3)&07)] |= 1 << (7-(x0&07)); 390*0Sstevel@tonic-gate else 391*0Sstevel@tonic-gate point(x0, y0); 392*0Sstevel@tonic-gate if (res1 > res2) { 393*0Sstevel@tonic-gate res2 += dx - res1; 394*0Sstevel@tonic-gate res1 = 0; 395*0Sstevel@tonic-gate y0 += yinc; 396*0Sstevel@tonic-gate } 397*0Sstevel@tonic-gate res1 += dy; 398*0Sstevel@tonic-gate x0 += xinc; 399*0Sstevel@tonic-gate } else while (y0 != y1) { 400*0Sstevel@tonic-gate if ((x0 + slope * y0) & linmod) 401*0Sstevel@tonic-gate if (((x0 >> 6) + ((y0 & ~077) >> 1)) == bufs[0].bno) 402*0Sstevel@tonic-gate bufs[0].block[((y0 & 077) << 3)+((x0 >> 3) & 07)] 403*0Sstevel@tonic-gate |= 1 << (7 - (x0& 07)); 404*0Sstevel@tonic-gate else 405*0Sstevel@tonic-gate point(x0, y0); 406*0Sstevel@tonic-gate if (res1 > res2) { 407*0Sstevel@tonic-gate res2 += dy - res1; 408*0Sstevel@tonic-gate res1 = 0; 409*0Sstevel@tonic-gate x0 += xinc; 410*0Sstevel@tonic-gate } 411*0Sstevel@tonic-gate res1 += dx; 412*0Sstevel@tonic-gate y0 += yinc; 413*0Sstevel@tonic-gate } 414*0Sstevel@tonic-gate if ((x1+slope*y1)&linmod) 415*0Sstevel@tonic-gate if (((x1>>6) + ((y1&~077)>>1)) == bufs[0].bno) 416*0Sstevel@tonic-gate bufs[0].block[((y1&077)<<3)+((x1>>3)&07)] |= 1 << (7-(x1&07)); 417*0Sstevel@tonic-gate else 418*0Sstevel@tonic-gate point(x1, y1); 419*0Sstevel@tonic-gate } 420*0Sstevel@tonic-gate 421*0Sstevel@tonic-gate point(x, y) 422*0Sstevel@tonic-gate register x, y; 423*0Sstevel@tonic-gate { 424*0Sstevel@tonic-gate register bno; 425*0Sstevel@tonic-gate 426*0Sstevel@tonic-gate bno = ((x&03700)>>6) + ((y&03700)>>1); 427*0Sstevel@tonic-gate if (bno != bufs[0].bno) { 428*0Sstevel@tonic-gate if (bno < 0 || bno >= 1024) 429*0Sstevel@tonic-gate return; 430*0Sstevel@tonic-gate getblk(bno); 431*0Sstevel@tonic-gate } 432*0Sstevel@tonic-gate bufs[0].block[((y&077)<<3)+((x>>3)&07)] |= 1 << (7-(x&07)); 433*0Sstevel@tonic-gate } 434*0Sstevel@tonic-gate 435*0Sstevel@tonic-gate getblk(b) 436*0Sstevel@tonic-gate register b; 437*0Sstevel@tonic-gate { 438*0Sstevel@tonic-gate register struct buf *bp1, *bp2; 439*0Sstevel@tonic-gate register char *tp; 440*0Sstevel@tonic-gate 441*0Sstevel@tonic-gate loop: 442*0Sstevel@tonic-gate for (bp1 = bufs; bp1 < &bufs[NB]; bp1++) { 443*0Sstevel@tonic-gate if (bp1->bno == b || bp1->bno == -1) { 444*0Sstevel@tonic-gate tp = bp1->block; 445*0Sstevel@tonic-gate for (bp2 = bp1; bp2 > bufs; --bp2) { 446*0Sstevel@tonic-gate bp2->bno = (bp2-1)->bno; 447*0Sstevel@tonic-gate bp2->block = (bp2-1)->block; 448*0Sstevel@tonic-gate } 449*0Sstevel@tonic-gate bufs[0].bno = b; 450*0Sstevel@tonic-gate bufs[0].block = tp; 451*0Sstevel@tonic-gate return; 452*0Sstevel@tonic-gate } 453*0Sstevel@tonic-gate } 454*0Sstevel@tonic-gate zseek(out, bufs[NB-1].bno); 455*0Sstevel@tonic-gate write(out, bufs[NB-1].block, BSIZ); 456*0Sstevel@tonic-gate zseek(in, b); 457*0Sstevel@tonic-gate read(in, bufs[NB-1].block, BSIZ); 458*0Sstevel@tonic-gate bufs[NB-1].bno = b; 459*0Sstevel@tonic-gate goto loop; 460*0Sstevel@tonic-gate } 461*0Sstevel@tonic-gate 462*0Sstevel@tonic-gate void 463*0Sstevel@tonic-gate onintr() 464*0Sstevel@tonic-gate { 465*0Sstevel@tonic-gate unlink(picture); 466*0Sstevel@tonic-gate exit(1); 467*0Sstevel@tonic-gate } 468*0Sstevel@tonic-gate 469*0Sstevel@tonic-gate zseek(a, b) 470*0Sstevel@tonic-gate { 471*0Sstevel@tonic-gate return (lseek(a, (long)b*512, 0)); 472*0Sstevel@tonic-gate } 473