# 2.11BSD#431 - /usr/src/usr.lib/libplot/t450/subr.c

##### Functions

    abval             X
    dist2             X
    inplot            X
    movep             X
    outplot           X
    reset             X
    spew              X
    swap              X
    tobotleft         X
    xconv             X
    xsc               X
    yconv             X
    ysc               X

       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:     spew (ESC);
      30:     spew(PLOTIN);
      31: }
      32:
      33: outplot()
      34: {
      35:     spew(ESC);
      36:     spew(PLOTOUT);
      37:     fflush(stdout);
      38: }
      39:
      40: spew(ch)
      41: {
      42:     if(ch == UP){
      43:         putc(ESC,stdout);
      44:         ch = DOWN;
      45:     }
      46:     putc(ch, stdout);
      47: }
      48:
      49: tobotleft ()
      50: {
      51:     move(-2048,-2048);
      52: }
      53: reset()
      54: {
      55:     signal(2,1);
      56:     outplot();
      57:     stty(OUTF,&ITTY);
      58:     exit();
      59: }
      60:
      61: float
      62: dist2 (x1, y1, x2, y2)
      63: {
      64:     float t,v;
      65:     t = x2-x1;
      66:     v = y1-y2;
      67:     return (t*t+v*v);
      68: }
      69:
      70: swap (pa, pb)
      71: int *pa, *pb;
      72: {
      73:     int t;
      74:     t = *pa;
      75:     *pa = *pb;
      76:     *pb = t;
      77: }
      78: movep (xg,yg)
      79: {
      80:     int i,ch;
      81:     if((xg == xnow) && (yg == ynow))return;
      82:     /* if we need to go to left margin, just CR */
      83:     if (xg < xnow/2)
      84:     {
      85:         spew(CR);
      86:         xnow = 0;
      87:     }
      88:     i = (xg-xnow)/HORZRES;
      89:     if(xnow < xg)ch = RIGHT;
      90:     else ch = LEFT;
      91:     xnow += i*HORZRES;
      92:     i = abval(i);
      93:     while(i--)spew(ch);
      94:     i = abval(xg-xnow);
      95:     inplot();
      96:     while(i--) spew(ch);
      97:     outplot();
      98:     i=(yg-ynow)/VERTRES;
      99:     if(ynow < yg)ch = UP;
     100:     else ch = DOWN;
     101:     ynow += i*VERTRES;
     102:     i = abval(i);
     103:     while(i--)spew(ch);
     104:     i=abval(yg-ynow);
     105:     inplot();
     106:     while(i--)spew(ch);
     107:     outplot();
     108:     xnow = xg; ynow = yg;
     109: }
     110:
     111: xsc(xi){
     112:     int xa;
     113:     xa = (xi - obotx) * scalex + botx;
     114:     return(xa);
     115: }
     116: ysc(yi){
     117:     int ya;
     118:     ya = (yi - oboty) *scaley +boty;
     119:     return(ya);
     120: }

#### Defined functions

abval defined in line 7; used 6 times

- in line 92-94(2), 102-104(2)
- in /usr/src/usr.lib/libplot/t450/line.c line 39-43(2)

dist2 defined in line 61; used 2 times

- in /usr/src/usr.lib/libplot/t450/line.c line 18-20(2)

inplot defined in line 27; used 3 times

- in line 95, 105
- in /usr/src/usr.lib/libplot/t450/line.c line 35

movep defined in line 78; used 2 times

- in /usr/src/usr.lib/libplot/t450/line.c line 19
- in /usr/src/usr.lib/libplot/t450/move.c line 6

outplot defined in line 33; used 4 times

- in line 56, 97, 107
- in /usr/src/usr.lib/libplot/t450/line.c line 47

reset defined in line 53; used 3 times

- in /usr/src/usr.lib/libplot/t450/close.c line 11
- in /usr/src/usr.lib/libplot/t450/open.c line 36-41(2)

spew defined in line 40; used 14 times

- in line 29-36(4), 85, 93-96(2), 103-106(2)
- in /usr/src/usr.lib/libplot/t450/erase.c line 9
- in /usr/src/usr.lib/libplot/t450/label.c line 12
- in /usr/src/usr.lib/libplot/t450/line.c line 40-45(3)

swap defined in line 70; never used
tobotleft defined in line 49; never used
xconv defined in line 12; used 4 times

- in /usr/src/usr.lib/libplot/t450/line.c line 7-11(3)
- in /usr/src/usr.lib/libplot/t450/move.c line 6

xsc defined in line 111; used 4 times

- in /usr/src/usr.lib/libplot/t450/line.c line 7-11(3)
- in /usr/src/usr.lib/libplot/t450/move.c line 6

yconv defined in line 20; used 4 times

- in /usr/src/usr.lib/libplot/t450/line.c line 7-11(3)
- in /usr/src/usr.lib/libplot/t450/move.c line 6

ysc defined in line 116; used 4 times

- in /usr/src/usr.lib/libplot/t450/line.c line 7-11(3)
- in /usr/src/usr.lib/libplot/t450/move.c line 6

#### Defined variables

sccsid defined in line 2; never used

Last modified: 1987-02-18 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 959 |