1 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
2 /* All Rights Reserved */
3
4
5 /*
6 * Copyright (c) 1980 Regents of the University of California.
7 * All rights reserved. The Berkeley software License Agreement
8 * specifies the terms and conditions for redistribution.
9 */
10
11 /*
12 * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc.
13 * All Rights Reserved.
14 */
15
16 /* from OpenSolaris "move.c 1.4 05/06/02 SMI" SVr4.0 1.1 */
17
18 /*
19 * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
20 *
21 * Sccsid @(#)move.c 1.4 (gritter) 10/29/05
22 */
23
24 /*
25 * Changes Copyright (c) 2014 Carsten Kunze (carsten.kunze at arcor.de)
26 */
27
28 #include "e.h"
29 #include "y.tab.h"
30
31 extern YYSTYPE yyval;
32
33 void
move(int dir,int amt,int p)34 move(int dir, int amt, int p) {
35 #ifndef NEQN
36 float a;
37 #else /* NEQN */
38 int a;
39 #endif /* NEQN */
40
41 yyval.token = p;
42 #ifndef NEQN
43 a = VERT(EM(amt/100.0, EFFPS(ps)));
44 #else /* NEQN */
45 a = VERT( (amt+49)/50 ); /* nearest number of half-lines */
46 #endif /* NEQN */
47 printf(".ds %d ", yyval.token);
48 if( dir == FWD || dir == BACK ) /* fwd, back */
49 #ifndef NEQN
50 printf("\\h'%s%gp'\\*(%d\n", (dir==BACK) ? "-" : "", a, p);
51 #else /* NEQN */
52 printf("\\h'%s%du'\\*(%d\n", (dir==BACK) ? "-" : "", a, p);
53 #endif /* NEQN */
54 else if (dir == UP)
55 #ifndef NEQN
56 printf("\\v'-%gp'\\*(%d\\v'%gp'\n", a, p, a);
57 #else /* NEQN */
58 printf("\\v'-%du'\\*(%d\\v'%du'\n", a, p, a);
59 #endif /* NEQN */
60 else if (dir == DOWN)
61 #ifndef NEQN
62 printf("\\v'%gp'\\*(%d\\v'-%gp'\n", a, p, a);
63 if(dbg)printf(".\tmove %d dir %d amt %g; h=%g b=%g\n",
64 p, dir, a, eht[yyval.token], ebase[yyval.token]);
65 #else /* NEQN */
66 printf("\\v'%du'\\*(%d\\v'-%du'\n", a, p, a);
67 if(dbg)printf(".\tmove %d dir %d amt %d; h=%d b=%d\n",
68 p, dir, a, eht[yyval.token], ebase[yyval.token]);
69 #endif /* NEQN */
70 }
71