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

#### Defined functions

abval defined in line 7; used 6 times

- in line 88-90(2), 98-100(2)
- in /usr/src/usr.lib/libplot/t300/line.c line 39-43(2)

dist2 defined in line 57; used 2 times

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

inplot defined in line 27; used 3 times

- in line 91, 101
- in /usr/src/usr.lib/libplot/t300/line.c line 35

movep defined in line 74; used 2 times

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

outplot defined in line 33; used 4 times

- in line 53, 93, 103
- in /usr/src/usr.lib/libplot/t300/line.c line 47

reset defined in line 51; used 4 times

- in /usr/src/local/zmodem/genie.c line 71
- in /usr/src/usr.lib/libplot/t300/close.c line 11
- in /usr/src/usr.lib/libplot/t300/open.c line 34-39(2)

spew defined in line 41; used 13 times

- in line 30-36(3), 81, 89-92(2), 99-102(2)
- in /usr/src/usr.lib/libplot/t300/erase.c line 9
- in /usr/src/usr.lib/libplot/t300/label.c line 12
- in /usr/src/usr.lib/libplot/t300/line.c line 40-45(3)

swap defined in line 66; never used
tobotleft defined in line 47; never used
xconv defined in line 12; used 4 times

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

xsc defined in line 107; used 4 times

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

yconv defined in line 20; used 4 times

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

ysc defined in line 112; used 4 times

- in /usr/src/usr.lib/libplot/t300/line.c line 7-11(3)
- in /usr/src/usr.lib/libplot/t300/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: 1600 |