1: #ifndef lint
   2: static char sccsid[] = "@(#)subr.c	4.1 (Berkeley) 6/27/83";
   3: #endif
   4: 
   5: #include <stdio.h>
   6: #include "con.h"
   7: abval(q)
   8: {
   9:     return (q>=0 ? q : -q);
  10: }
  11: 
  12: xconv (xp)
  13: {
  14:     /* x position input is -2047 to +2047, output must be 0 to PAGSIZ*HORZRES */
  15:     xp += 2048;
  16:     /* the computation is newx = xp*(PAGSIZ*HORZRES)/4096 */
  17:     return (xoffset + xp /xscale);
  18: }
  19: 
  20: yconv (yp)
  21: {
  22:     /* see description of xconv */
  23:     yp += 2048;
  24:     return (yp / yscale);
  25: }
  26: 
  27: inplot()
  28: {
  29:     stty(OUTF, &PTTY);
  30:     spew(ESC);
  31:     spew (INPLOT);
  32: }
  33: 
  34: outplot()
  35: {
  36:     spew(ESC);
  37:     spew(ACK);
  38:     spew(ESC);
  39:     spew(ACK);
  40:     fflush(stdout);
  41:     stty (OUTF, &ITTY);
  42: }
  43: 
  44: spew(ch)
  45: {
  46:     putc(ch, stdout);
  47: }
  48: 
  49: tobotleft ()
  50: {
  51:     move(-2048,-2048);
  52: }
  53: reset()
  54: {
  55:     outplot();
  56:     exit();
  57: }
  58: 
  59: float
  60: dist2 (x1, y1, x2, y2)
  61: {
  62:     float t,v;
  63:     t = x2-x1;
  64:     v = y1-y2;
  65:     return (t*t+v*v);
  66: }
  67: 
  68: swap (pa, pb)
  69: int *pa, *pb;
  70: {
  71:     int t;
  72:     t = *pa;
  73:     *pa = *pb;
  74:     *pb = t;
  75: }
  76: 
  77: #define DOUBLE 010
  78: #define ADDR 0100
  79: #define COM 060
  80: #define MAXX 070
  81: #define MAXY 07
  82: extern xnow,ynow;
  83: #define SPACES 7
  84: movep(ix,iy){
  85:     int dx,dy,remx,remy,pts,i;
  86:     int xd,yd;
  87:     int addr,command;
  88:     char c;
  89:     if(xnow == ix && ynow == iy)return;
  90:     inplot();
  91:     dx = ix-xnow;
  92:     dy = iy-ynow;
  93:     command = COM|PENUP|((dx<0)<<1)|(dy<0);
  94:     dx = abval(dx);
  95:     dy = abval(dy);
  96:     xd = dx/(SPACES*2);
  97:     yd = dy/(SPACES*2);
  98:     pts = xd<yd?xd:yd;
  99:     if((i=pts)>0){
 100:         c=command|DOUBLE;
 101:         addr=ADDR;
 102:         if(xd>0)addr|=MAXX;
 103:         if(yd>0)addr|=MAXY;
 104:         spew(c);
 105:         while(i--){
 106:             spew(addr);
 107:         }
 108:     }
 109:     if(xd!=yd){
 110:         if(xd>pts){
 111:             i=xd-pts;
 112:             addr=ADDR|MAXX;
 113:         }
 114:         else{
 115:             i=yd-pts;
 116:             addr=ADDR|MAXY;
 117:         }
 118:         c=command|DOUBLE;
 119:         spew(c);
 120:         while(i--){
 121:             spew(addr);
 122:         }
 123:     }
 124:     remx=dx-xd*SPACES*2;
 125:     remy=dy-yd*SPACES*2;
 126:     addr=ADDR;
 127:     i = 0;
 128:     if(remx>7){
 129:         i=1;
 130:         addr|=MAXX;
 131:         remx -= 7;
 132:     }
 133:     if(remy>7){
 134:         i=1;
 135:         addr|=MAXY;
 136:         remy -= 7;
 137:     }
 138:     while(i--){
 139:         spew(command);
 140:         spew(addr);
 141:     }
 142:     if(remx>0||remy>0){
 143:         spew(command);
 144:         spew(ADDR|remx<<3|remy);
 145:     }
 146:     xnow=ix;
 147:     ynow=iy;
 148:     outplot();
 149:     return;
 150: }
 151: xsc(xi){
 152:     int xa;
 153:     xa = (xi - obotx) * scalex + botx;
 154:     return(xa);
 155: }
 156: ysc(yi){
 157:     int ya;
 158:     ya = (yi - oboty) *scaley +boty;
 159:     return(ya);
 160: }

Defined functions

abval defined in line 7; used 4 times
dist2 defined in line 59; used 2 times
inplot defined in line 27; used 2 times
outplot defined in line 34; used 3 times
swap defined in line 68; never used
tobotleft defined in line 49; never used
xsc defined in line 151; used 4 times
ysc defined in line 156; used 4 times

Defined variables

sccsid defined in line 2; never used

Defined macros

ADDR defined in line 78; used 5 times
COM defined in line 79; used 1 times
  • in line 93
DOUBLE defined in line 77; used 2 times
MAXX defined in line 80; used 3 times
MAXY defined in line 81; used 3 times
SPACES defined in line 83; used 4 times
Last modified: 1987-02-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1974
Valid CSS Valid XHTML 1.0 Strict