.\" Copyright (c) 1983 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\" @(#)lib2648.3 5.1 (Berkeley) %G%
.TH LIB2648 3X "1 March 1980"
lib2648 \- subroutines for the HP 2648 graphics terminal
is a general purpose library of subroutines useful
for interactive graphics on the Hewlett-Packard 2648 graphics terminal.
To use it you must call the routine
at the beginning of execution,
All terminal input and output must go through the routines
does the necessary ^E/^F handshaking if
returns ``hp2648'', as it will if set by
Any other value, including for example ``2648'', will disable handshaking.
Bit matrix routines are provided to model the graphics memory of the 2648.
These routines are generally useful, but are specifically useful for the
function which efficiently changes what is on the screen to what is
supposed to be on the screen.
The primative bit matrix routines are
if non-null, is expected to be a file descriptor as returned by
will trace the progress of the output by writing onto
It is provided to make debugging output feasible for graphics programs without
messing up the screen or the escape sequences being sent.
Typical use of trace will include:
\fBswitch\fP (argv[1][1]) {
trace = fopen("trace", "w");
fprintf(trace, "x is %d, y is %s\en", x, y);
dumpmat("before update", xmat);
Move the alphanumeric cursor to position (x, y),
measured from the upper left corner of the screen.
Turn the alphanumeric display off.
Turn the alphanumeric display on.
.B areaclear(rmin, cmin, rmax, cmax)
Clear the area on the graphics screen bordered by the four arguments.
In normal mode the area is set to all black, in inverse video mode
Ring the bell on the terminal.
.B bitcopy(dest, src, rows, cols) bitmat dest, src;
Clear the alphanumeric display.
Clear the graphics display.
Note that the 2648 will only clear the part of the screen
that is visible if zoomed in.
Turn the graphics cursor off.
Turn the graphics cursor on.
.B dispmsg(str, x, y, maxlen) char *str;
in graphics text at position
The maximum message length is given by
and is needed to for dispmsg to know how big an area to clear
before drawing the message.
The lower left corner of the first character is at
Should be called before the program exits.
Restores the tty to normal, turns off graphics screen,
turns on alphanumeric screen, flushes the standard output, etc.
Draw a line from the pen location to
As with all graphics coordinates,
is measured from the bottom left corner of the screen.
coordinates represent the first quadrant of the usual Cartesian system.
.B drawbox(r, c, color, rows, cols)
Draw a rectangular box on the graphics screen.
The lower left corner is at location
absolute coordinates represent row and column on the screen,
with the origin at the lower left.
except for being reversed in order.
.B "dumpmat(msg, m, rows, cols) char *msg; bitmat m;"
is non-null, write a readable ASCII representation
is a label to identify the output.
.B emptyrow(m, rows, cols, r) bitmat m;
is all zero, else returns 0.
This routine is provided because it can be implemented more
efficiently with a knowledge of the internal representation
than a series of calls to
This is called by certain routines in
It is also suitable for calling by the user program.
It is probably a good idea for a fancy graphics program
to supply its own error procedure which uses
Set the terminal to the default graphics modes.
Turn the graphics display off.
Turn the graphics display on.
This means that most special keys on the terminal (such as the alphanumeric
arrow keys) will transmit an escape sequence instead of doing their function
Draw a line in the current mode from
.I "move(x1, y1); draw(x2, y2);"
except that a bug in the terminal involving repeated lines from the
same point is compensated for.
Move the alphanumeric cursor to the lower left (home down) position.
.B "mat(m, rows, cols, r, c) bitmat m;"
Used to retrieve an element from a bit matrix.
Returns 1 or 0 as the value of the
Bit matrices are numbered
from the upper left corner of the matrix,
.B message(str) char *str;
at the bottom of the graphics screen.
.B "minmax(g, rows, cols, rmin, cmin, rmax, cmax) bitmat g;"
.B int *rmin, *cmin, *rmax, *cmax;
Find the smallest rectangle that contains all the 1 (on) elements in
The coordinates are returned in the variables
pointed to by rmin, cmin, rmax, cmax.
Such motion is internal and will not cause output
Move the graphics cursor to location
.B bitmat newmat(rows, cols)
The value created (e.g. a pointer to the first location) is returned.
A bit matrix can be freed directly with
All output to the terminal should go through this routine or
.B outstr(str) char *str;
Print the string str on the standard output by repeated calls to
Print the graphics display on the printer.
The printer must be configured as device 6 (the default) on the HPIB.
Read one character from the terminal and return it.
should be used to get all input,
Turn the rubber band line off.
Turn the rubber band line on.
.B char *rdchar(c) char c;
Return a readable representation of the character
is a printing character it returns itself, if a control
character it is shown in the ^X notation, if negative
an apostrophe is prepended. Space returns ^\`, rubout returns ^?.
A pointer to a static place is returned.
For this reason, it will not work to pass rdchar twice to the same
You must instead save one of the values in your own buffer with strcpy.
.B readline(prompt, msg, maxlen) char *prompt, *msg;
on the bottom line of the graphics display
and read one line of text from the user, terminated by a newline.
The line is placed in the buffer
Backspace processing is supported.
Set the display to draw lines in erase mode.
(This is reversed by inverse video mode.)
.B "setmat(m, rows, cols, r, c, val) bitmat m;"
The basic operation to store a value in an element of a bit matrix.
which should be either 0 or 1.
Set the display to draw lines in normal (solid) mode.
(This is reversed by inverse video mode.)
Set the display to draw lines in exclusive or mode.
Force all accumulated output to be displayed on the screen.
This should be followed by fflush(stdout).
The cursor is not affected by this function.
Note that it is normally never necessary to call
Toggle the state of video.
If in normal mode, go into inverse video mode,
The screen is reversed as well as the
internal state of the library.
Set up the terminal for processing.
This routine should be called at the beginning of execution.
It places the terminal in CBREAK mode, turns off echo,
sets the proper modes in the terminal,
and initializes the library.
.B "update(mold, mnew, rows, cols, baser, basec) bitmat mold, mnew;"
Make whatever changes are needed to make a window on the screen
is what the window on the screen currently looks like.
and the lower left corner on
the screen of the window is
was not intended to be used for the entire screen.
It would work but be very slow and take 64K bytes
of memory just for mold and mnew.
It was intended for 100 by 100 windows with objects in the center
of them, and is quite fast for such windows.
.B zermat(m, rows, cols) bitmat m;
Set the hardware zoom to value
which can range from 1 to 15.
This forces the screen to zoom level 1 without affecting the
current internal zoom number.
This restores the screen to the previously specified zoom size.
is called when an error is detected.
The only error currently detected is overflow of the buffer
Subscripts out of bounds to
return without setting anything.
This library is not supported.
It makes no attempt to use all of the features of the terminal,
only those needed by fed.
Contributions from users will be accepted for addition to the library.
The HP 2648 terminal is somewhat unreliable at speeds over 2400 baud,
even with the ^E/^F handshaking.
In an effort to improve reliability, handshaking is done every 32 characters.
(The manual claims it is only necessary every 80 characters.)
Nonetheless, I/O errors sometimes still occur.
There is no way to control the amount of debugging output generated
without modifying the source to the library.