[comp.sources.misc] Grafix - a PC graphics library

allbery@ncoast.UUCP (08/29/87)

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	graf.c
#	graf.h
#	graflib.asm
#	grafsys.h
#	halo.h
#	halofake.c
#	macros.ah
#	macros.h
#	makemsc
#	maketc
#	doc
# This archive created: Thu Aug 27 11:29:51 1987
export PATH; PATH=/bin:$PATH
echo shar: extracting "'graf.c'" '(11654 characters)'
if test -f 'graf.c'
then
	echo shar: will not over-write existing file "'graf.c'"
else
sed 's/^X//' << \SHAR_EOF > 'graf.c'
X/*
X * grafix --- graf.c
X *
X * graphics interface
X *
X * Written 4/87 by Scott Snyder (ssnyder@romeo.caltech.edu or @citromeo.bitnet)
X *
X * 5/29/87 sss - fixed bug in box() and allow for different memory models
X *
X */
X
X#include "macros.h"
X#include "graf.h"
X#include "grafsys.h"
X#include <dos.h>
X
X#define int_video   0x10
X#define video_point 0x0c
X#define ega_altsel  0x12
X#define egaalt_info 0x10
X
X/* utility macros */
X
X#define swap(a, b) {int _tmp; _tmp=a; a=b; b=_tmp;}
X#define inrange(a, x, b) ((a)<=(x) && (x)<=(b))
X#define clipto(x, lo, hi) { \
X  if (x < lo)               \
X    x = lo;                 \
X  else if (x > hi)          \
X    x = hi;                 \
X}
X
X/*****************************************************************************
X *                            variable definitions                           *
X *****************************************************************************/
X
Xunsigned NEAR g_card;		/* graphics card we're using */
Xunsigned NEAR g_display;	/* type of display we're using */
X
Xg_obj far * NEAR g_drawbuf;	/* graphics drawing buffer */
Xg_obj far * NEAR g_physbuf;	/* physical screen address */
Xg_obj far * NEAR g_virtbuf;	/* virtual buffer address  */
Xunsigned NEAR g_colormax;	/* maximum color value     */
Xunsigned NEAR g_xsize, NEAR g_ysize; /* physical size of screen */
Xunsigned NEAR g_xchsize, NEAR g_ychsize; /* size of screen in characters */
Xunsigned NEAR g_xor;		/* xor mode flag */
Xunsigned NEAR g_bufflg;		/* buffered mode flag */
Xunsigned NEAR g_pages;		/* number of pagse available */
Xunsigned NEAR g_curpage;	/* page currently visible */
X
Xint NEAR g_xcliplo, NEAR g_xcliphi; /* clipping boundaries */
Xint NEAR g_ycliplo, NEAR g_ycliphi;
X
Xfloat NEAR g_aspect;		/* aspect ratio */
X
X/*****************************************************************************
X *                       interfaces to graphics drivers                      *
X *****************************************************************************/
X
X/************************* calls for internal use only ***********************/
X
XSTATIC void nocl_regfill(x1, y1, x2, y2, c)
Xunsigned x1, y1, x2, y2, c;
X{
X  switch(g_card) {
X    case (CGA): CGA_regfill(x1, y1, x2, y2, c); break;
X    case (EGA): EGA_regfill(x1, y1, x2, y2, c); break;
X  }
X}
X
XSTATIC void nocl_point(x, y, c)
Xunsigned x, y, c;
X{
X  switch(g_card) {
X    case (CGA): CGA_point(x, y, c); break;
X    case (EGA): EGA_point(x, y, c); break;
X  }
X}
X
XSTATIC void nocl_line(x1, y1, x2, y2, c)
Xunsigned x1, y1, x2, y2, c;
X{
X  switch(g_card) {
X    case (CGA): CGA_line(x1, y1, x2, y2, c); break;
X    case (EGA): EGA_line(x1, y1, x2, y2, c); break;
X  }
X}
X
XSTATIC void write_pix(x1, y1, x2, y2, c)
Xint x1, y1, x2, y2;
Xunsigned c;
X{
X  switch(g_card) {
X    case (CGA): CGA_write_pix(x1, y1, x2, y2, c); break;
X    case (EGA): EGA_write_pix(x1, y1, x2, y2, c); break;
X  }
X}
X
X/* set up for plotting mucho points */
X
XSTATIC void point_set(c)
Xunsigned c;
X{
X  switch(g_card) {
X    case (CGA): CGA_point_set(c); break;
X    case (EGA): EGA_point_set(c); break;
X  }
X}
X
XSTATIC void point_res()
X{
X  switch(g_card) {
X    case (CGA): CGA_point_res(); break;
X    case (EGA): EGA_point_res(); break;
X  }
X}
X
X/******************** calls safe for anyone to use **************************/
X
Xvoid g_clearall(c)
Xunsigned c;
X{
X  switch(g_card) {
X    case (CGA): CGA_clearall(c); break;
X    case (EGA): EGA_clearall(c); break;
X  }
X}
X
Xvoid g_show()
X{
X  switch(g_card) {
X    case (CGA): CGA_show(); break;
X    case (EGA): EGA_show(); break;
X  }
X}
X
Xvoid g_setback(c)
Xunsigned c;
X{
X  switch(g_card) {
X    case (CGA): CGA_setback(c); break;
X    case (EGA): EGA_setback(c); break;
X  }
X}
X
Xvoid g_setpal(pallette, value)
Xunsigned pallette, value;
X{
X  switch(g_card) {
X    case (CGA): CGA_setpal(pallette, value); break;
X    case (EGA): EGA_setpal(pallette, value); break;
X  }
X}
X
X/* g_open also sets clipping boundaries to the physical screen size */
X/* and initializes other things... */
X
Xvoid g_open(mode)
Xunsigned mode;
X{
X  switch(g_card) {
X    case (CGA): CGA_gopen(mode); break;
X    case (EGA): EGA_gopen(mode); break;
X  }
X  g_xcliplo = 0;
X  g_ycliplo = 0;
X  g_xcliphi = g_xsize-1;
X  g_ycliphi = g_ysize-1;
X
X  g_xor = g_bufflg = 0;
X
X/* set g_drawbuf to something appropriately */
X
X  g_setbuf(g_bufflg);
X}
X
Xvoid g_close()
X{
X  switch(g_card) {
X    case (CGA): CGA_gclose(); break;
X    case (EGA): EGA_gclose(); break;
X  }
X}
X
Xvoid g_writech(row, col, ch, c, page)
Xunsigned row, col, c;
Xchar ch;
Xint page;
X{
X  switch(g_card) {
X    case (CGA): CGA_writech(row, col, ch, c, page); break;
X    case (EGA): EGA_writech(row, col, ch, c, page); break;
X  }
X}
X
X/***************************************************************************
X *                    graphics drawing and control routines                *
X ***************************************************************************/
X
X/* fill a region with the specified color */
X
Xvoid g_regfill(x1, y1, x2, y2, c)
Xint x1, y1, x2, y2;
Xunsigned c;
X{
X  if (x1 > x2)
X    swap(x1, x2);
X  if (y1 > y2)
X    swap(y1, y2);
X
X  if (x1 < g_xcliplo)
X    x1 = g_xcliplo;
X  else if (x1 > g_xcliphi)
X    return;
X
X  if (x2 < g_xcliplo)
X    return;
X  else if (x2 > g_xcliphi)
X    x2 = g_xcliphi;
X
X  if (y1 < g_ycliplo)
X    y1 = g_ycliplo;
X  else if (y1 > g_ycliphi)
X    return;
X
X  if (y2 < g_ycliplo)
X    return;
X  else if (y2 > g_ycliphi)
X    y2 = g_ycliphi;
X
X  nocl_regfill(x1, y1, x2, y2, c);
X}
X
X/* plot a point */
X
Xvoid g_point(x, y, c)
Xint x, y;
Xunsigned c;
X{
X  if (inrange(g_xcliplo, x, g_xcliphi) &&
X      inrange(g_ycliplo, y, g_ycliphi))
X    nocl_point(x, y, c);
X}
X
X/* routine to clip one endpoint of a line */
X
XSTATIC int clipln(x1,y1,xc,yc,x2,y2)
Xint x1,y1,x2,y2,*xc,*yc;
X{
X  int delx,dely,xx,yy;
X 
X  if (x1 >= g_xcliplo && x1 <= g_xcliphi &&
X      y1 >= g_ycliplo && y1 <= g_ycliphi) {
X    *xc=x1; *yc=y1;
X     return(1);
X  }
X  dely=y2-y1;
X  delx=x2-x1;
X  if (y1 > g_ycliphi || y1 < g_ycliplo) {
X    if (dely == 0)
X      return(0);
X    if (y1 > g_ycliphi) {
X      if (dely > 0 || y2 > g_ycliphi) return (0);
X      yy=g_ycliphi;
X    }
X    else {
X      if (dely < 0 || y2 < g_ycliplo) return(0);
X      yy=g_ycliplo;
X    }
X    xx=(float)(yy-y1)*delx/dely+x1;
X    if (xx >= g_xcliplo && xx <= g_xcliphi) {
X      *xc=xx; *yc=yy;
X      return(1);
X    }
X  }
X  if (x1 > g_xcliphi || x1 < g_xcliplo) {
X    if (delx == 0)
X      return(0);
X    if (x1 > g_xcliphi) {
X      if (delx > 0 || x2 > g_xcliphi) return(0);
X      xx=g_xcliphi;
X    }
X    else {
X      if (delx < 0 || x2 < g_xcliplo) return(0);
X      xx=g_xcliplo;
X    }
X    yy=(float)(xx-x1)*dely/delx+y1;
X    if (yy >= g_ycliplo && yy <= g_ycliphi) {
X      *xc=xx; *yc=yy;
X      return(1);
X    }
X  }
X  return(0);
X}
X 
X/* draw a clipped line */
X 
Xvoid g_line(x1,y1,x2,y2,c)
Xint x1,y1,x2,y2;
Xunsigned c;
X{
X  if (clipln(x1,y1,&x1,&y1,x2,y2) &&
X      clipln(x2,y2,&x2,&y2,x1,y1)) {
X    nocl_line(x1,y1,x2,y2,c);
X  }
X}
X
X/* draw an ellipse with aspect aspect and half-major axis length r_sum_m */
X/* from a routine by Tim Hogan in Dr. Dobb's Journal May '85 p. 40       */
X
Xvoid g_ellipse(x, y, r_sub_m, aspect, c)
Xint x,y,r_sub_m;
Xunsigned c;
Xfloat aspect;
X{
X  long alpha, beta, two_alpha, four_alpha, two_beta, four_beta, d;
X  int row, col, two_x, two_y, rel_x, rel_y;
X  double square_aspect;
X
X  if (aspect < 0.004) aspect = 0.004;
X
X  square_aspect = aspect*aspect;
X
X  if (aspect < 1.0) {
X    alpha = (long)r_sub_m * (long)r_sub_m;
X    beta = alpha * square_aspect;
X    row = y + r_sub_m*aspect;
X  }
X  else {
X    beta = (long)r_sub_m * (long)r_sub_m;
X    alpha = beta / square_aspect;
X    row = y + r_sub_m;
X  }
X
X  if (alpha == 0L) alpha = 1L;
X  if (beta  == 0L) beta  = 1L;
X
X  col = x;
X  two_x = x<<1;
X  two_y = y<<1;
X  rel_y = row-y;
X  two_alpha  = alpha<<1;
X  four_alpha = alpha<<2;
X  two_beta   =  beta<<1;
X  four_beta  =  beta<<2;
X
X  d = two_alpha*((long)(rel_y-1)*rel_y) + alpha + two_beta*(1-alpha);
X
X  point_set(c);			/* set up for point plotting */
X
X  while (alpha*(rel_y = row-y) > beta*(rel_x = col-x)) {
X    write_pix(col, row, two_x-col, two_y-row, c);
X    if (d>=0) {
X      d += four_alpha*(1-rel_y);
X      row--;
X    }
X    d += two_beta*(3+(rel_x<<1));
X    col++;
X  }
X
X  d = two_beta * ((long)rel_x * (rel_x+1)) + two_alpha*((long)rel_y*(rel_y-2)+1) +
X      beta*(1-two_alpha);
X
X  while ((rel_y = row-y) + 1) {
X    write_pix(col, row, two_x-col, two_y-row, c);
X    if (d<=0) {
X      d += four_beta*(1+col-x);
X      col++;
X    }
X    d += two_alpha*(3-(rel_y<<1));
X    row--;
X  }
X  point_res();				/* reset the graphics device */
X}
X
X/* draw a circle */
X
Xvoid g_circle(x, y, r, c)
Xint x, y, r;
Xunsigned c;
X{
X  g_ellipse(x, y, r, g_aspect, c);
X}
X
X/* draw a box */
X
Xvoid g_box(x1, y1, x2, y2, c)
Xint x1, y1, x2, y2;
Xunsigned c;
X{
X  g_line(x1, y1, x2, y1, c);
X  g_line(x2, y1, x2, y2, c);
X  g_line(x2, y2, x1, y2, c);
X  g_line(x1, y2, x1, y1, c);
X}
X
X/* set xor mode */
X
Xvoid g_setxor(flag)
Xunsigned flag;
X{
X  g_xor = flag;
X}
X
X/* set clipping boundaries */
X
Xvoid g_setclip(x1, y1, x2, y2)
Xint x1, y1, x2, y2;
X{
X  if (x1 > x2)
X    swap(x1, x2);
X  if (y1 > y2)
X    swap(y1, y2);
X
X  clipto(x1, 0, g_xsize-1);
X  clipto(x2, 0, g_xsize-1);
X  clipto(y1, 0, g_ysize-1);
X  clipto(y2, 0, g_ysize-1);
X
X  g_xcliplo = x1;
X  g_xcliphi = x2;
X  g_ycliplo = y1;
X  g_ycliphi = y2;
X}
X
X/* clear screen within clipping boundaries */
X
Xvoid g_clear(c)
Xunsigned c;
X{
X  nocl_regfill(g_xcliplo, g_ycliplo, g_xcliphi, g_ycliphi, c);
X}
X
X/* set buffered mode flag and initialize drawbuf appropriately */
X
Xvoid g_setbuf(flag)
Xunsigned flag;
X{
X  g_bufflg = flag;
X  if (flag)
X    g_drawbuf = g_virtbuf;
X  else
X    g_drawbuf = g_physbuf;
X}
X
X/* initialize graphics system */
X
Xvoid g_init(card, display)
Xunsigned card;
Xunsigned display;			/* ignored if card = 0 */
X{
X  unsigned swt;
X  union REGS inregs, outregs;
X
X/* try to get EGA information. if we have enough memory for 2 hi-res
X   pages, then say we have an EGA. if not, or if the card does not
X   respond, assume we have a CGA. if argument is nonzero however, force
X   result to that.
X*/
X
X  if (card == 0) {
X    inregs.h.ah = ega_altsel;
X    inregs.h.bl = egaalt_info;
X    int86(int_video, &inregs, &outregs);
X    if (outregs.h.bl != 3) {              /* not valid | mem. < 256k */
X      g_card = CGA;
X      g_display = CD;
X    }
X    else {
X      g_card = EGA;
X
X  /* now look at the adapter switch settings (in cl) and try to figure
X     out what sort of display is attached */
X
X      swt = outregs.h.cl & 0x0e;
X      swt = (swt >= 6 ? swt-6 : swt);
X      if (swt == 4)
X        g_display = MO;
X      else if (swt == 2)
X        g_display = EN;
X      else if (swt == 0)
X        g_display = CD;
X      else
X        g_display = CD;
X    }
X  }
X  else {
X    g_card = card;
X    g_display = display;
X  }
X
X  g_xor = 0;
X  g_bufflg = 0;
X  g_xcliplo = g_xcliplo = g_ycliphi = g_ycliplo = 0;
X}
X
X/* write a string tty style with color c at row, col */
X
Xvoid g_writestr(row, col, s, c, page)
Xunsigned row, col;
Xunsigned c;
Xchar *s;
Xint page;
X{
X  while (*s) {
X    if (col >= g_xchsize) {	/* do wrapping */
X      col = 0;
X      row++;
X    }
X    if (row >= g_ychsize) 	/* abort if we run out of screen */
X      return;
X    if (*s == '\012')		/* newline */
X      col = g_xchsize;		/* force a wrap next time around */
X    else if (*s == '\015')	/* ignore any carriage returns (for compat) */
X      ;
X    else {
X      g_writech (row, col, *s, c, page);
X      col++;
X    }
X    s++;
X  }
X}
X
X/* get information about physical graphics device */
X
Xvoid g_info(p)
Xstruct g_info *p;
X{
X  p->card     = g_card;
X  p->display  = g_display;
X  p->xsize    = g_xsize;
X  p->ysize    = g_ysize;
X  p->colormax = g_colormax;
X  p->pages    = g_pages;
X  p->curpage  = g_curpage;
X  p->xchsize  = g_xchsize;
X  p->ychsize  = g_ychsize;
X}
SHAR_EOF
if test 11654 -ne "`wc -c < 'graf.c'`"
then
	echo shar: error transmitting "'graf.c'" '(should have been 11654 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'graf.h'" '(1424 characters)'
if test -f 'graf.h'
then
	echo shar: will not over-write existing file "'graf.h'"
else
sed 's/^X//' << \SHAR_EOF > 'graf.h'
X/*
X * grafix --- graf.h
X *
X * graphics definitions
X *
X * Written 4/87 by Scott Snyder (ssnyder@romeo.caltech.edu or @citromeo.bitnet)
X *
X */
X
X/* graphics card definitions */
X
X#define CGA 1
X#define EGA 2
X
X/* display type definitions */
X
X#define EN 1
X#define CD 2
X#define MO 3
X
X/* graphics mode definitions */
X
X#define CGA_640 1
X#define CGA_320 2
X
X/* info structure definition */
X
Xstruct g_info {
X  unsigned card;
X  unsigned display;
X  unsigned xsize, ysize;
X  unsigned xchsize, ychsize;
X  unsigned colormax;
X  unsigned pages;
X  unsigned curpage;
X};
X
X/* graphics interface function definitions */
X
Xextern void g_box(int, int, int, int, unsigned);
Xextern void g_circle(int, int, int, unsigned);
Xextern void g_clear(unsigned);
Xextern void g_clearall(unsigned);
Xextern void g_close(void);
Xextern void g_ellipse(int, int, int, float, unsigned);
Xextern void g_info(struct g_info *);
Xextern void g_init(unsigned, ...);
Xextern void g_line(int, int, int, int, unsigned);
Xextern void g_open(unsigned);
Xextern void g_point(int, int, unsigned);
Xextern void g_regfill(int, int, int, int, unsigned);
Xextern void g_setback(unsigned);
Xextern void g_setbuf(unsigned);
Xextern void g_setclip(int, int, int, int);
Xextern void g_setpal(unsigned, unsigned);
Xextern void g_setxor(unsigned);
Xextern void g_show(void);
Xextern void g_writech(unsigned, unsigned, char, unsigned, int);
Xextern void g_writestr(unsigned, unsigned, char *, unsigned, int);
SHAR_EOF
if test 1424 -ne "`wc -c < 'graf.h'`"
then
	echo shar: error transmitting "'graf.h'" '(should have been 1424 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'graflib.asm'" '(962 characters)'
if test -f 'graflib.asm'
then
	echo shar: will not over-write existing file "'graflib.asm'"
else
sed 's/^X//' << \SHAR_EOF > 'graflib.asm'
X;
X; grafix --- graflib.asm
X;
X; miscellaneous assembly routines
X;
X; Written 4/87 by Scott Snyder (ssnyder@romeo.caltech.edu or @citromeo.bitnet)
X;
X; Modified 5/29/87 by sss to allow for different memory models
X;
X
X	title	graflib
X
Xinclude	macros.ah
X
Xbuflen equ 32768
X
Xsseg
Xendss
X
Xdseg
Xendds
X
Xbuf	segment public 'BUF'
X	db buflen dup(?)
Xbuf	ends
X
X	df	g_fmemcpy
X	df	g_fmemset
X	df	g_bufseg
X 
Xcseg	_graflib
X
XpBegin	g_bufseg
X
X	mov	ax, buf
X	ret
X
XpEnd	g_bufseg
X
XpBegin	g_fmemcpy 
X
X	push	bp
X	mov	bp,sp
X	push	di
X	push	si
X	push	ds
X
X	cld 
X	les	di,[bp+argbase]
X	lds	si,[bp+argbase+4]
X	mov	cx,[bp+argbase+8]
X	shr	cx, 1
X	jnc	c1
X	movsb
Xc1:	rep	movsw
X  
X	pop	ds
X	pop	si
X	pop	di
X	mov	sp,bp
X	pop	bp
X	ret
X
XpEnd	g_fmemcpy
X
XpBegin	g_fmemset
X
X	push	bp
X	mov	bp,sp
X	push	di
X	push	si
X
X	cld 
X	les	di,[bp+argbase]
X	mov	al,[bp+argbase+4]
X	mov	ah,al
X	mov	cx,[bp+argbase+6]
X	shr	cx,1
X	jnc	s1
X	stosb
Xs1:	rep	stosw
X  
X	pop	si
X	pop	di
X	mov	sp,bp
X	pop	bp
X	ret
X
XpEnd	g_fmemset
X
Xendcs	_graflib 
X 
X	end
SHAR_EOF
if test 962 -ne "`wc -c < 'graflib.asm'`"
then
	echo shar: error transmitting "'graflib.asm'" '(should have been 962 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'grafsys.h'" '(2081 characters)'
if test -f 'grafsys.h'
then
	echo shar: will not over-write existing file "'grafsys.h'"
else
sed 's/^X//' << \SHAR_EOF > 'grafsys.h'
X/*
X * grafix --- grafsys.h
X *
X * definitions for communication between graf.c and drivers
X *
X * Written 4/87 by Scott Snyder (ssnyder@romeo.caltech.edu or @citromeo.bitnet)
X *
X */
X
X/*
X * the assembly routines assume that all the global data is in the default
X *  data segment. in MSC's large (& compact) model, however, each module
X *  gets its own data segment --- except stuff declared near which goes
X *  into the default segment. TC, however, doesn't allow near, etc. to
X *  modify static data. but TC also puts all static data into one segment
X *  in all models except huge. so we get lucky this time!
X */
X
X#if defined(__TURBOC__)
X# define NEAR
X#else
X# define NEAR near
X#endif
X
X/* display type definitions */
X
X#define EN 1
X#define CD 2
X#define MO 3
X
X/* graphics mode definitions */
X
X#define CGA_640 1
X#define CGA_320 2
X
Xtypedef unsigned char g_obj;
X
X/* physbuf = area that's being displayed;
X   virtbuf = other area;
X   drawbuf = area that's being drawn on
X*/
X
Xextern g_obj far * NEAR g_drawbuf; /* graphics drawing buffer */
Xextern g_obj far * NEAR g_physbuf; /* addr. of physical screen buffer */
Xextern g_obj far * NEAR g_virtbuf; /* addr. of virtual buffer */
Xextern unsigned NEAR g_colormax; /* maximum color value     */
Xextern unsigned NEAR g_xsize, NEAR g_ysize; /* physical size of screen */
Xextern unsigned NEAR g_xchsize, NEAR g_ychsize; /* size of screen in chars */
Xextern unsigned NEAR g_xor;     /* xor mode flag */
Xextern unsigned NEAR g_bufflg;	/* buffered mode flag */
Xextern int NEAR g_xcliplo, NEAR g_xcliphi; /* clipping boundaries */
Xextern int NEAR g_ycliplo, NEAR g_ycliphi;
Xextern float NEAR g_aspect;	/* aspect ratio for circle drawing */
Xextern unsigned NEAR g_pages;	/* number of pages available	   */
Xextern unsigned NEAR g_curpage;	/* page currently visible	   */
Xextern unsigned NEAR g_display;	/* display type		           */
X
X/* utility functions */
X
Xextern g_fmemset(g_obj far *, g_obj, unsigned);
Xextern g_fmemcpy(g_obj far *, g_obj far *, unsigned);
Xextern unsigned g_bufseg(void);
X
X/* driver functions */
X
X#include "cga.h"
X#include "ega.h"
SHAR_EOF
if test 2081 -ne "`wc -c < 'grafsys.h'`"
then
	echo shar: error transmitting "'grafsys.h'" '(should have been 2081 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'halo.h'" '(951 characters)'
if test -f 'halo.h'
then
	echo shar: will not over-write existing file "'halo.h'"
else
sed 's/^X//' << \SHAR_EOF > 'halo.h'
X/*
X * grafix --- halo.h
X *
X * definitions for fake halo routines
X *
X * Written 4/87 by Scott Snyder (ssnyder@romeo.caltech.edu or @citromeo.bitnet)
X *
X */
X
Xextern void box(float *, float *, float *, float *);
Xextern void cir(float *);
Xextern void halo_init(void);
Xextern void lnabs(float *, float *);
Xextern void lnrel(float *, float *);
Xextern void mapdton (int   *, int   *, float *, float *);
Xextern void mapdtow (int   *, int   *, float *, float *);
Xextern void mapntod (float *, float *, int   *, int   *);
Xextern void mapntow (float *, float *, float *, float *);
Xextern void mapwtod (float *, float *, int   *, int   *);
Xextern void mapwton (float *, float *, float *, float *);
Xextern void movabs(float *, float *);
Xextern void movrel(float *, float *);
Xextern void setcolor(int *);
Xextern void setviewport(float *, float *, float *, float *, int *, int *);
Xextern void setworld(float *, float *, float *, float *);
Xextern void setxor(int *);
SHAR_EOF
if test 951 -ne "`wc -c < 'halo.h'`"
then
	echo shar: error transmitting "'halo.h'" '(should have been 951 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'halofake.c'" '(5672 characters)'
if test -f 'halofake.c'
then
	echo shar: will not over-write existing file "'halofake.c'"
else
sed 's/^X//' << \SHAR_EOF > 'halofake.c'
X/*
X * grafix --- halofake.c
X *
X * implement halo-like transformations and calls
X *
X * Written 4/87 by Scott Snyder (ssnyder@romeo.caltech.edu or @citromeo.bitnet)
X *
X */
X
X#include "macros.h"
X#include "graf.h"
X#include <math.h>
X
X/* graphics parameters */
X
XSTATIC unsigned h_xsize, h_ysize, h_colormax;
X
X/* transformation parameters */
X
XSTATIC float w_x_offs = 0;
XSTATIC float w_y_offs = 0;
XSTATIC float w_x_mult = 1;
XSTATIC float w_y_mult = 1;
XSTATIC float v_x_offs = 0;
XSTATIC float v_y_offs = 0;
XSTATIC float v_x_mult = 1;
XSTATIC float v_y_mult = 1;
X
X/* state variables */
X
XSTATIC float cur_wx, cur_wy;
XSTATIC unsigned cur_c;
X
X#define smashcolor(c) ((c) > h_colormax ? h_colormax : c)
X#define swap(a, b) {int tmp; tmp=a; a=b; b=tmp;}
X
X/*****************************************************************************
X *                          transformation macros                            *
X *****************************************************************************/
X
X#define tr_x_wtov(x) (((x) + w_x_offs) * w_x_mult)
X#define tr_x_vton(x) ((x) * v_x_mult + v_x_offs)
X#define tr_x_ntod(x) ((x) * (h_xsize-1))
X
X#define tr_x_dton(x) (((float)(x)) / (h_xsize-1))
X#define tr_x_ntov(x) (((x) - v_x_offs) / v_x_mult)
X#define tr_x_vtow(x) ((x) / w_x_mult - w_x_offs)
X
X#define tr_x_wton(x) tr_x_vton( tr_x_wtov (x))
X#define tr_x_ntow(x) tr_x_vtow( tr_x_ntov (x))
X#define tr_x_dtow(x) tr_x_ntow( tr_x_dton (x))
X
X
X#define tr_y_wtov(y) (((y) + w_y_offs) * w_y_mult)
X#define tr_y_vton(y) ((y) * v_y_mult + v_y_offs)
X#define tr_y_ntod(y) ((y) * (h_ysize-1))
X
X#define tr_y_dton(y) (((float)(y)) / (h_ysize-1))
X#define tr_y_ntov(y) (((y) - v_y_offs) / v_y_mult)
X#define tr_y_vtow(y) ((y) / w_y_mult - w_y_offs)
X
X#define tr_y_wton(y) tr_y_vton( tr_y_wtov (y))
X#define tr_y_ntow(y) tr_y_vtow( tr_y_ntov (y))
X#define tr_y_dtow(y) tr_y_ntow( tr_y_dton (y))
X
X
X#define tr_r_wtov(r) ((r) * w_x_mult)
X#define tr_r_vton(r) ((r) * v_x_mult)
X#define tr_r_ntod(r) tr_x_ntod(r)
X
X#define tr_r_wton(r) tr_r_vton( tr_r_wtov (r))
X
X/*****************************************************************************
X *                        private utility functions                          *
X *****************************************************************************/
X
Xint tr_x(float);
XSTATIC int tr_x(x)
Xfloat x;
X{
X  return( tr_x_ntod( tr_x_wton (x)));
X}
X
Xint tr_y(float);
XSTATIC int tr_y(y)
Xfloat y;
X{
X  return( tr_y_ntod( tr_y_wton (y)));
X}
X
Xint tr_r(float);
XSTATIC int tr_r(r)
Xfloat r;
X{
X  return( tr_r_ntod( tr_r_wton (r)));
X}
X
X/*****************************************************************************
X *                          user-callable routines                           *
X *****************************************************************************/
X
X/* coordinate transforms */
X
Xvoid mapdton(dx, dy, nx, ny)
Xint   *dx, *dy;
Xfloat *nx, *ny;
X{
X  *nx = tr_x_dton(*dx);
X  *ny = tr_y_dton(*dy);
X}
X
Xvoid mapdtow(dx, dy, wx, wy)
Xint   *dx, *dy;
Xfloat *wx, *wy;
X{
X  *wx = tr_x_dtow(*dx);
X  *wy = tr_y_dtow(*dy);
X}
X
Xvoid mapntod(nx, ny, dx, dy)
Xfloat *nx, *ny;
Xint   *dx, *dy;
X{
X  *dx = tr_x_ntod(*nx);
X  *dy = tr_y_ntod(*ny);
X}
X
Xvoid mapntow(nx, ny, wx, wy)
Xfloat *nx, *ny;
Xfloat *wx, *wy;
X{
X  *wx = tr_x_ntow(*nx);
X  *wy = tr_y_ntow(*ny);
X}
X
Xvoid mapwtod(wx, wy, dx, dy)
Xfloat *wx, *wy;
Xint   *dx, *dy;
X{
X  *dx = tr_x(*wx);
X  *dy = tr_y(*wy);
X}
X
Xvoid mapwton(wx, wy, nx, ny)
Xfloat *wx, *wy;
Xfloat *nx, *ny;
X{
X  *nx = tr_x_wton(*wx);
X  *ny = tr_y_wton(*wy);
X}
X
X/* routines controlling transformations */
X
Xvoid setworld(x1,y1,x2,y2)
Xfloat *x1,*y1,*x2,*y2;
X{
X  w_x_offs = -*x1;
X  w_y_offs = -*y2;
X
X  if (*x2 - *x1 != 0.0)
X    w_x_mult = 1.0/(*x2 - *x1);
X  else
X    w_x_mult = 1e15;
X
X  if (*y1 - *y2 != 0.0)
X    w_y_mult = 1.0/(*y1 - *y2);
X  else
X    w_y_mult = 1e15;
X}
X
Xvoid setviewport(x1, y1, x2, y2, bdr, bck)
Xfloat *x1,*x2,*y1,*y2;
Xint *bdr,*bck;
X{
X  int dx1, dx2, dy1, dy2;
X
X  v_x_offs = *x1;
X  v_y_offs = *y1;
X
X  if (*x2 - *x1 != 0.0)
X    v_x_mult = (*x2 - *x1);
X  else
X    v_x_mult = 1e-15;
X
X  if (*y2 - *y1 != 0.0)
X    v_y_mult = (*y2 - *y1);
X  else
X    v_y_mult = 1e-15;
X
X  dx1 = tr_x_ntod(*x1);
X  dx2 = tr_x_ntod(*x2);
X  dy1 = tr_y_ntod(*y1);
X  dy2 = tr_y_ntod(*y2);
X
X  if (*bdr >= 0) {
X    if (dx1 > dx2) swap(dx1, dx2);
X    if (dy1 > dy2) swap(dy1, dy2);
X
X    g_setclip(dx1-1, dy1-1, dx2+1, dy2+1);
X    g_box(dx1-1, dy1-1, dx2+1, dy2+1, smashcolor(*bdr));
X  }
X
X  g_setclip(dx1, dy1, dx2, dy2);
X
X  if (*bck >= 0)
X    g_clear(smashcolor(*bck));
X}
X
X/* drawing routines */
X
Xvoid movabs(wx, wy)
Xfloat *wx, *wy;
X{
X  cur_wx = *wx;
X  cur_wy = *wy;
X}
X
Xvoid movrel(wx, wy)
Xfloat *wx, *wy;
X{
X  cur_wx += *wx;
X  cur_wy += *wy;
X}
X
Xvoid lnabs(wx, wy)
Xfloat *wx, *wy;
X{
X  g_line(tr_x(cur_wx), tr_y(cur_wy), tr_x(*wx), tr_y(*wy), cur_c);
X  cur_wx = *wx;
X  cur_wy = *wy;
X}
X
Xvoid lnrel(wx, wy)
Xfloat *wx, *wy;
X{
X  g_line(tr_x(cur_wx),     tr_y(cur_wy),
X         tr_x(cur_wx+*wx), tr_y(cur_wy+*wy), cur_c);
X  cur_wx += *wx;
X  cur_wy += *wy;
X}
X
Xvoid cir(r)
Xfloat *r;
X{
X  int dx, dy, dr;
X
X  if (*r > 0.0) {
X    dx = tr_x(cur_wx);
X    dy = tr_y(cur_wy);
X    dr = tr_r(*r);
X    g_circle(dx, dy, dr, cur_c);
X  }
X}
X
Xvoid box(wx1, wy1, wx2, wy2)
Xfloat *wx1, *wx2, *wy1, *wy2;
X{
X  g_box(tr_x(*wx1), tr_y(*wy1), tr_x(*wx2), tr_y(*wy2), cur_c);
X}
X
X/* mode setting stuff */
X
Xsetcolor(c)
Xint *c;
X{
X  cur_c = smashcolor(*c);
X}
X
Xsetxor(m)
Xint *m;
X{
X  g_setxor(*m);
X}
X
X/* get parameters - must be called AFTER g_open */
X
Xvoid halo_init()
X{
X  struct g_info info;
X
X  g_info(&info);
X  h_xsize = info.xsize;
X  h_ysize = info.ysize;
X  h_colormax = info.colormax;
X
X  w_x_offs = w_y_offs = 0;
X  w_x_mult = w_y_mult = 1;
X  v_x_offs = v_y_offs = 0;
X  v_x_mult = v_y_mult = 1;
X
X  cur_wx = cur_wy = 0;
X  cur_c = 0;
X}
SHAR_EOF
if test 5672 -ne "`wc -c < 'halofake.c'`"
then
	echo shar: error transmitting "'halofake.c'" '(should have been 5672 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'macros.ah'" '(1420 characters)'
if test -f 'macros.ah'
then
	echo shar: will not over-write existing file "'macros.ah'"
else
sed 's/^X//' << \SHAR_EOF > 'macros.ah'
X;
X; grafix --- macros.ah 
X;
X; general purpose definitions
X;
X; Written 4/87 by Scott Snyder (ssnyder@romeo.caltech.edu or @citromeo.bitnet)
X;
X; Memory model stuff added 5/29/87 by sss
X;
X
X;include model.inc
X
X;
X; break down modules
X;
Xifdef SMALL
X  NEARDATA equ 1
X  NEARCODE equ 1
Xendif
X
Xifdef COMPACT
X   FARDATA equ 1
X  NEARCODE equ 1
Xendif
X
Xifdef MEDIUM
X  NEARDATA equ 1
X   FARCODE equ 1
Xendif
X
Xifdef LARGE
X   FARDATA equ 1
X   FARCODE equ 1
Xendif
X
X;
X; define model-dependent parameters
X;
X
Xifdef NEARCODE
X  argbase equ 4
Xendif
X
Xifdef FARCODE
X  argbase equ 6
Xendif
X
X;
X; macros
X;
X
Xcseg	macro moduleName
X	ifdef FARCODE
X	  moduleName&_TEXT segment byte public 'CODE'
X	  assume cs: moduleName&_TEXT
X	else
X	  _TEXT segment byte public 'CODE'
X	  assume cs: _TEXT
X	endif
X	endm
X
Xendcs	macro moduleName
X	ifdef FARCODE
X	  moduleName&_TEXT ends
X	else
X	  _TEXT ends
X	endif
X	endm
X
XpBegin	macro pName
X	ifdef FARCODE
X	  pName proc far
X	else
X	  pName proc near
X	endif
X	endm
X
XpEnd	macro pName
X	pName endp
X	endm
X
Xdseg	macro
X	assume	ds:DGROUP
X_DATA	segment byte public 'DATA'
X	endm
X
Xendds	macro
X_DATA	ends
X	endm
X
Xsseg	macro
XDGROUP	group	_STACK, _DATA
X	assume	ss:DGROUP
X_STACK	segment word stack 'STACK'
X	endm
X
Xendss	macro
X_STACK	ends
X	endm
X
Xdf	macro	sym
Xpublic	sym
X_&sym	=	sym
Xpublic	_&sym
X	endm
X
Xex	macro	sym, typ
Xextrn	_&sym : typ
Xsym	equ	_&sym
X	endm
X
XexProc	macro pName
X	ifdef FARCODE
X	  ex pName, far
X	else
X	  ex pName, near
X	endif
X	endm
X
SHAR_EOF
if test 1420 -ne "`wc -c < 'macros.ah'`"
then
	echo shar: error transmitting "'macros.ah'" '(should have been 1420 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'macros.h'" '(410 characters)'
if test -f 'macros.h'
then
	echo shar: will not over-write existing file "'macros.h'"
else
sed 's/^X//' << \SHAR_EOF > 'macros.h'
X/*
X * macros.h
X *
X * general purpose macros
X *
X * Written 4/87 by Scott Snyder (ssnyder@romeo.caltech.edu or @citromeo.bitnet)
X *
X */
X
X#define LINT_ARGS
X/*#define DEBUG*/
X
X#ifdef DEBUG
X# define debug(x) x
X# define STATIC
X#else
X# define debug(x)
X# define STATIC static
X#endif
X
X#define ever ;;
X#define until(c) while(!(c))
X#define true (1)
X#define false (0)
X#define maxfloat (1.701411e38)
X#define pi (3.1415926)
SHAR_EOF
if test 410 -ne "`wc -c < 'macros.h'`"
then
	echo shar: error transmitting "'macros.h'" '(should have been 410 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'makemsc'" '(1347 characters)'
if test -f 'makemsc'
then
	echo shar: will not over-write existing file "'makemsc'"
else
sed 's/^X//' << \SHAR_EOF > 'makemsc'
X#
X# Make file for Grafix, Microsoft C. Typing 'make makemsc' will build
X#   a small model library called grafix.lib. To compile a different
X#   memory model, set other compiler options, or change the name of
X#   the library, set the cflags, asmflags, and/or libname macros
X#   from the command line. For example, if you want to build a
X#   medium model library, you should type:
X#      make cflags=/AM asmflags=/DMEDIUM libname=grafixm makemsc
X#   Be sure that no object modules that were compiled with a different
X#   memory model are lying around! The batch file buildmsc.bat will
X#   automatically build all four libraries from scratch. Oh, and also
X#   be sure you have the compiler properly configured so that it
X#   can find its include files. You will also need to have MASM and
X#   Microsoft's LIB utility on your search path.
X#
X
Xcflags=
Xasmflags=
Xlibname=grafix
X
X# /Gs = no stack probes
X.c.obj:
X  msc/Gs $(cflags) $*;
X  lib $(libname) -+$*;
X
X# /Mx = case is signifigant
X.asm.obj:
X  masm/Mx $(asmflags) $*;
X  lib $(libname) -+$*;
X
Xcgagraf.obj: cgagraf.c macros.h grafsys.h cga.h
X
Xcgagrafa.obj: cgagrafa.asm macros.ah
X
Xegagraf.obj: egagraf.c macros.h grafsys.h ega.h
X
Xegagrafa.obj: egagrafa.asm macros.ah
X
Xgraf.obj: graf.c macros.h graf.h grafsys.h cga.h ega.h
X
Xgraflib.obj: graflib.asm macros.ah
X
Xhalofake.obj: halofake.c macros.h graf.h
X
SHAR_EOF
if test 1347 -ne "`wc -c < 'makemsc'`"
then
	echo shar: error transmitting "'makemsc'" '(should have been 1347 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'maketc'" '(1883 characters)'
if test -f 'maketc'
then
	echo shar: will not over-write existing file "'maketc'"
else
sed 's/^X//' << \SHAR_EOF > 'maketc'
X#
X# Make file for Grafix, Turbo C. Typing 'make -fmaketc' will build
X#   a small model library called grafix.lib. To compile a different
X#   memory model, set other compiler options, or change the name of
X#   the library, set the cflags, asmflags, and/or libname macros
X#   from the command line. For example, if you want to build a
X#   medium model library, you should type:
X#      make -Dcflags=-mm -Dasmflags=/DMEDIUM -Dlibname=grafixm -fmaketc
X#   Be sure that no object modules that were compiled with a different
X#   memory model are lying around! The batch file buildtc.bat will
X#   automatically build all four libraries from scratch. Oh, and also
X#   be sure you have the compiler properly configured so that it
X#   can find its include files. You will also need to have MASM and
X#   Microsoft's LIB utility on your search path.
X#
X
X#
X# Note: on the version of Turbo Make I have (dated 1:00 may 13), the $d
X#  macro doesn't seem to work. Thus, you'll always have to specify cflags,
X#  asmflags, and libname from the command line (buildtc.bat does this, so
X#  it's all right). If the make you have works in this regard, remove
X#  the #'s from the following lines.
X#
X
X#!if $d(cflags)
X#cflags=
X#!endif
X#!if !$d(asmflags)
X#asmflags=/DSMALL
X#!endif
X#!if !$d(libname)
X#libname=grafix
X#!endif
X
X# -c = don't link
X.c.obj:
X  tcc -c $(cflags) $*
X  lib $(libname) -+$*;
X
X# /Mx = case is signifigant
X.asm.obj:
X  masm /Mx $(asmflags) $*;
X  lib $(libname) -+$*;
X
X$(libname).lib: graf.obj graflib.obj cgagrafa.obj egagrafa.obj cgagraf.obj \
X                egagraf.obj halofake.obj
X
Xgraf.obj: graf.c macros.h graf.h grafsys.h cga.h ega.h
X
Xgraflib.obj: graflib.asm macros.ah
X
Xcgagrafa.obj: cgagrafa.asm macros.ah
X
Xegagrafa.obj: egagrafa.asm macros.ah
X
Xcgagraf.obj: cgagraf.c macros.h grafsys.h cga.h
X
Xegagraf.obj: egagraf.c macros.h grafsys.h ega.h
X
Xhalofake.obj: halofake.c macros.h graf.h
X
SHAR_EOF
if test 1883 -ne "`wc -c < 'maketc'`"
then
	echo shar: error transmitting "'maketc'" '(should have been 1883 characters)'
fi
fi # end of overwriting check
if test ! -d 'doc'
then
	echo shar: creating directory "'doc'"
	mkdir 'doc'
fi
echo shar: entering directory "'doc'"
cd 'doc'
echo shar: extracting "'fonts.txi'" '(1669 characters)'
if test -f 'fonts.txi'
then
	echo shar: will not over-write existing file "'fonts.txi'"
else
sed 's/^X//' << \SHAR_EOF > 'fonts.txi'
X%
X% fonts.txi
X%
X\font\fourteenbf=ambx10 scaled\magstep2
X\font\twelverm =amr10  at 12pt
X\font\twelveit =amti10 at 12pt
X\font\twelvebf =ambx10 at 12pt
X\font\twelvett =amtt10 at 12pt
X\font\twelvemit=ammi10 at 12pt
X\font\twelvecal=amsy10 at 12pt
X\font\tenmex=amex10
X\font\eightbf=ambx8
X\font\eightrm=amr8
X\font\eightmit=ammi8
X\font\eightcal=amsy8
X\font\sixbf=ambx6
X\font\sixrm=amr6
X\font\sixmit=ammi6
X\font\sixcal=amsy6
X
X\def\normbs{\def\\{{\cal \char"6E}}}
X\def\ttbs{\def\\{\char`\\}}
X
X\def\twelvepoint{\def\rm{\fam0\twelverm\normbs}%
X  \textfont0=\twelverm  \scriptfont0=\eightrm  \scriptscriptfont0=\sixrm
X  \textfont1=\twelvemit \scriptfont1=\eightmit \scriptscriptfont1=\sixmit
X  \textfont2=\twelvecal \scriptfont2=\eightcal \scriptscriptfont2=\sixcal
X  \textfont3=\tenmex    \scriptfont3=\tenmex   \scriptscriptfont3=\tenmex
X  \textfont\itfam=\twelveit  \def\it{\fam\itfam\twelveit\normbs}%
X  \textfont\ttfam=\twelvett  \def\tt{\fam\ttfam\twelvett\ttbs}%
X  \textfont\bffam=\twelvebf  \scriptfont\bffam=\eightbf
X   \scriptscriptfont\bffam=\sixbf  \def\bf{\fam\bffam\twelvebf\normbs}%
X  \def\bigbf{\fourteenbf}%
X  \def\cal{\twelvecal\normbs}
X  \def\mit{\twelvemit\normbs}
X  \def\mex{\twelvemex\normbs}
X  \def\normalspacing{\baselineskip=14pt
X    \setbox\strutbox=\hbox{\vrule height 9.9pt depth 4.1pt width 0pt}}%
X  \def\doublespacing{\baselineskip=24pt
X    \setbox\strutbox=\hbox{\vrule height 17pt depth 7pt width 0pt}}%
X  \def\codespacing  {\baselineskip=12pt
X    \setbox\strutbox=\hbox{\vrule height 8.5pt depth 3.5pt width 0pt}}%
X  \def\tablespacing {\baselineskip=12pt
X    \setbox\strutbox=\hbox{\vrule height 8.5pt depth 3.5pt width 0pt}}%
X  \normalspacing\rm}
X
SHAR_EOF
if test 1669 -ne "`wc -c < 'fonts.txi'`"
then
	echo shar: error transmitting "'fonts.txi'" '(should have been 1669 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'lib.txi'" '(3642 characters)'
if test -f 'lib.txi'
then
	echo shar: will not over-write existing file "'lib.txi'"
else
sed 's/^X//' << \SHAR_EOF > 'lib.txi'
X%
X% various TeX macros
X%
X%
X% insert a MacDraw picture into a document
X%
X\def\PrintMacDraw#1#2{\par
X  \vtop to #2{%
X    \special{ps::[asis,begin]
X      0 SPB
X      /MacDrawCheckPoint save def
X        md begin /page {pop} def end
X        Xpos Ypos translate
X        0 10.75 72 mul neg translate
X    }%
X    \special{ps: plotfile #1 asis}%
X    \special{ps::[asis,end]
X      MacDrawCheckPoint restore
X      0 SPE
X    }%
X    \vss
X  }%
X}
X%
X% insert a CrikDraw picture into a document
X%
X\def\PrintCrikDraw#1#2{\par
X  \vtop to #2{%
X    \special{ps::[asis,begin]
X      0 SPB
X      /MacDrawCheckPoint save def
X        /md 200 dict def
X        md begin /page {pop} def end
X        8.5 72 mul 11 72 mul translate
X        -1 -1 scale
X        Xpos neg Ypos neg translate
X        0 11 72 mul translate
X        systemdict begin md begin
X    }%
X    \special{ps: plotfile #1 asis}%
X    \special{ps::[asis,end]
X      end end
X      MacDrawCheckPoint restore
X      0 SPE
X    }%
X    \vss
X  }
X}
X
X\def\HPrintCrikDraw#1#2#3{\hbox to #3{\PrintCrikDraw{#1}{#2}}}
X%
X%
X%
X\def\itwd #1 {{\it #1\/ }}
X\def\itnc #1 {{\it #1}}
X\def\itwdn #1 {{\it #1\/}}
X\def\itncs #1 {{\it #1 }}
X
X\def\bfwd #1 {{\bf #1\/ }}
X\def\bfnc #1 {{\bf #1}}
X\def\bfwdn #1 {{\bf #1\/}}
X\def\bfncs #1 {{\bf #1 }}
X
X\def\ttwd #1 {{\tt #1 }}
X\def\ttwdn #1 {{\tt #1}}
X
X\def\chapno{0}
X\def\chapter #1 #2\par{{\bigbf
X                        \centerline{Chapter #1}%
X                        \medskip
X                        \centerline{#2}}%
X                       \vskip 1cm
X                       \global\def\chapno{#1}}
X\def\endchap{\vfill\supereject}
X
X\def\ss #1 #2\par{\medbreak\medskip\noindent{\bf \chapno.#1 \enspace #2}%
X                  \par\nobreak\medskip\nobreak}
X
X\def\hint{\penalty -100}
X\def\break{\penalty -10000}
X
X\newcount\paritemno
X\outer\def\paritemzero{\paritemno=0}
X\outer\def\paritem #1. {\medbreak\advance\paritemno by 1
X  \noindent{\it \the\paritemno.\enspace #1.\enspace}}
X\outer\def\paritemnull {\medbreak\advance\paritemno by 1
X  \noindent{\it \the\paritemno.\enspace}}
X
X\newcount\itmno
X\outer\def\itmzero{\itmno=0}
X\outer\def\itm{\advance\itmno by 1\item{\the\itmno.}}
X
X\def\case #1{\medskip\hangindent=\parindent \hangafter=1\noindent{\it #1}\hfil
X             \break}
X
X\def\<{{\mit <}}
X\def\>{{\mit >}}
X\def\brocket#1{\<{\it #1}\>}
X
X\def\head#1\par{\medbreak\noindent {\bf #1}\par\nobreak\medskip\nobreak}
X
X\def\begintable{\bigskip\begingroup\tablespacing}
X\def\endtable{\endgroup}
X
X\def\+{\tabalign}
X\def\begintablec#1{\begintable\centerline{\vbox{#1}}}
X\def\endtablec{\endtable}
X
X\def\tbltxt#1{\vtop{\strut#1\strut}}
X
X\def\textbeg{\medskip\begingroup\tt
X             \def\par{\leavevmode\endgraf}\catcode`\`=\active
X             \advance\parindent by 1em
X             \obeylines\obeyspaces\codespacing}
X\def\textend{\endgroup\medskip}
X
X\def\altitem#1{\setbox0=\hbox{#1}\hangindent=\wd0\hangafter=1\noindent\box0}
X
X%
X% verbatim stuff
X%
X{\catcode`\`=\active \gdef`{\relax\lq}}
X{\obeyspaces\global\let =\ }
X
X\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}
X\def\vinput#1 {\par\begingroup\setupverbatim\input #1 \endgroup}
X\def\setupverbatim{\tt
X  \codespacing\catcode`\_=11
X  \def\par{\leavevmode\endgraf} \catcode`\`=\active
X  \obeylines \uncatcodespecials \obeyspaces}
X
X\def\almostuncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials
X  \catcode`\\=0}
X\def\setupalmostverbatim{\tt
X  \codespacing\catcode`\_=11
X  \def\par{\leavevmode\endgraf} \catcode`\`=\active
X  \obeylines \almostuncatcodespecials \obeyspaces}
X
X\def\vninput#1 {{\parindent=0pt \vinput#1 }}
X
X\def\codebeg{\par\begingroup\advance\parindent by 1em\setupalmostverbatim}
X\def\codeend{\endgroup}
SHAR_EOF
if test 3642 -ne "`wc -c < 'lib.txi'`"
then
	echo shar: error transmitting "'lib.txi'" '(should have been 3642 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'man.txi'" '(1387 characters)'
if test -f 'man.txi'
then
	echo shar: will not over-write existing file "'man.txi'"
else
sed 's/^X//' << \SHAR_EOF > 'man.txi'
X%
X% manual.txi
X%
X% tex macros for formatting man pages
X%
X% get \parskip right when going to single spacing!!!
X
X%
X% set up global stuff
X%
X\raggedbottom
X\interlinepenalty=1000		% try to put page breaks between pars
X\voffset=24pt
X\advance\vsize by-\voffset
X\leftskip=\parindent
X\parindent=0pt
X\headline={\thepagename\hfil\wholemanname\hfil\thepagename}
X\footline={\hss\tenrm-- \folio\ --\hss}
X\parskip=\medskipamount
X
X\def\noskip{\leftskip=0pt}
X
X%
X% generate the various sections on a page
X%
X\def\manpage#1 {\gdef\thepagename {#1}\begingroup}
X
X\def\manname{\par\endgroup{\noskip NAME\par\nobreak}\begingroup}
X\def\mansyn{\par\endgroup{\noskip SYNOPSIS\par\nobreak}
X            \begingroup\tt
X            \codespacing\catcode`\_=11
X            \def\par{\leavevmode\endgraf}
X            \obeylines\obeyspaces}
X\def\mandscr{\par\endgroup{\noskip DESCRIPTION\par\nobreak}\begingroup}
X\def\manbugs{\par\endgroup{\noskip BUGS\par\nobreak}\begingroup}
X\def\manex{\par\endgroup{\noskip EXAMPLE\par\nobreak}\begingroup}
X\def\mansee{\par\endgroup{\noskip SEE ALSO\par\nobreak}
X            \begingroup\hyphenpenalty=10000\raggedright}
X\def\manpend{\par\endgroup\vfill\supereject}
X
X%
X% subheadings
X%
X\def\manhead #1\par{\par{\noskip #1\par\nobreak}}
X%
X% other stuff
X%
X\def\mancodebeg{\codebeg}
X\def\mancodeend{\codeend}
X%\def\mancodebeg{\par\begingroup\setupalmostverbatim}
X%\def\mancodeend{\endgroup}
SHAR_EOF
if test 1387 -ne "`wc -c < 'man.txi'`"
then
	echo shar: error transmitting "'man.txi'" '(should have been 1387 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'setup.txi'" '(131 characters)'
if test -f 'setup.txi'
then
	echo shar: will not over-write existing file "'setup.txi'"
else
sed 's/^X//' << \SHAR_EOF > 'setup.txi'
X\input fonts.txi
X\input lib.txi
X
X\catcode`\_=\active	% we want to use this in identifiers
X\def_{\_}
X
X\twelvepoint\doublespacing\rm
SHAR_EOF
if test 131 -ne "`wc -c < 'setup.txi'`"
then
	echo shar: error transmitting "'setup.txi'" '(should have been 131 characters)'
fi
fi # end of overwriting check
echo shar: done with directory "'doc'"
cd ..
#	End of shell archive
exit 0