111481Sralph /*
2*19798Sdist * Copyright (c) 1980 Regents of the University of California.
3*19798Sdist * All rights reserved. The Berkeley software License Agreement
4*19798Sdist * specifies the terms and conditions for redistribution.
5*19798Sdist */
6*19798Sdist
7*19798Sdist #ifndef lint
8*19798Sdist static char sccsid[] = "@(#)motion.c 5.1 (Berkeley) 04/30/85";
9*19798Sdist #endif not lint
10*19798Sdist
11*19798Sdist /*
1211481Sralph * Move the pen to x, y. We assume we are already in ESCP mode.
1311481Sralph */
1411481Sralph
1511481Sralph #include "2648.h"
1611481Sralph
motion(x,y)1711481Sralph motion(x, y)
1811481Sralph {
1911481Sralph char lox, loy, hix, hiy;
2011481Sralph int delx, dely;
2111481Sralph
2211481Sralph delx = x-_penx; dely = y-_peny;
2311481Sralph if (-16 <= delx && delx <= 15 && -16 <= dely && dely <= 15) {
2411481Sralph /*
2511481Sralph * Optimization: if within 15 in both directions, can use
2611481Sralph * HP short incremental mode, only 3 bytes.
2711481Sralph */
2811481Sralph outchar('j');
2911481Sralph outchar(32 + (delx & 31));
3011481Sralph outchar(32 + (dely & 31));
3111481Sralph } else {
3211481Sralph /*
3311481Sralph * Otherwise must use binary absolute mode, 5 bytes.
3411481Sralph * We never use ascii mode or binary incremental, since
3511481Sralph * those both take many more bytes.
3611481Sralph */
3711481Sralph outchar('i');
3811481Sralph outchar(32+ ((x>>5) & 31));
3911481Sralph outchar(32+ (x&31));
4011481Sralph outchar(32+ ((y>>5) & 31));
4111481Sralph outchar(32+ (y&31));
4211481Sralph }
4311481Sralph _penx = x;
4411481Sralph _peny = y;
4511481Sralph }
46