From: hjespersen@lion.uwaterloo.ca (Hans Jespersen)
Newsgroups: unix-pc.sources
Subject: dmd/bitblt demo programs
Keywords: dmd BLIT 630 demo
Message-ID: <1990Nov8.213802.13153@watdragon.waterloo.edu>
Date: 8 Nov 90 21:38:02 GMT
Sender: daemon@watdragon.waterloo.edu (Owner of Many System Processes)
Organization: University of Waterloo
Lines: 3126

Here is my unfinished dmd library which emulates bitblt() and
other functions present in programs written for the AT&T Blit
family of terminals (Blit/5620/630/730) using wrastop(). Eventually
I would like to include VIDPAL support to speed it all up and
port some of the many interesting tools available for these
cool terminals. This package includes some standard demos (called
a, b, m (doesn't quit work), moire, and one. In addition there is
one very unattractive test program called t that I included to
show how to use some of the dmd library of functions ( ie. circle(),
segment(), point(), etc ). Since I can't as yet directly address
video memory I had to contruct a psuedo-display screen dmdinit()
and you must call dmdrefresh() to update the actual screen after
you have manipulated the bitmap using the other dmd routines.

-- 
Hans Jespersen                  "Never underestimate the bandwidth of
hjespersen@lion.waterloo.edu     a station wagon full of tapes hurtling
                                 down the highway." A. Tanenbaum

-----------------------------cut here------------------------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  Makefile a.c b.c circle.c display.c dmd.h font.c font.h
#   general.c jroutines.c m.c mem.c moire.c mouse.c one.c t.c
#   textures.c
# Wrapped by root@arakis on Thu Nov  8 16:10:41 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(751 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
demos: a b m t moire one
X
a: a.o display.o general.o
X	cc -g -o a a.o display.o general.o -ltam -ltermlib
X
b: b.o display.o general.o
X	cc -g -o b b.o display.o general.o -ltam -ltermlib
X
m: m.o display.o general.o
X	cc -g -o m m.o display.o general.o -ltam -ltermlib
X
t: t.o display.o general.o circle.o
X	cc -g -o t t.o display.o general.o circle.o -ltam -ltermlib
X
one: one.o display.o general.o
X	cc -g -o one one.o display.o general.o -ltam -ltermlib
X
moire: moire.o display.o general.o
X	cc -g -o moire moire.o display.o general.o  -ltam -ltermlib
X
display.o: display.c dmd.h
X	cc -g -c display.c
X
general.o: general.c dmd.h
X	cc -g -c general.c
X
circle.o: circle.c dmd.h
X	cc -g -c circle.c
X
clean:
X	rm *.o core
X
clobber:
X	rm a b m t moire one *.o core
END_OF_FILE
if test 751 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'a.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'a.c'\"
else
echo shar: Extracting \"'a.c'\" \(789 characters\)
sed "s/^X//" >'a.c' <<'END_OF_FILE'
X#include "dmd.h"
X
X
X
main()
X{
X	dmdinit();
X	ripple();
X	dmdreset();
X	exit();
X}
X
X
X
X
X#define	avg(a,b) (((a)+(b))>>1)
X
X
X
X
Rectangle
canon(p1, p2)
X
X	Point p1, p2;
X
X{
X
X	Rectangle r;
X
X
X
X	r.origin.x = min(p1.x, p2.x);
X	r.origin.y = min(p1.y, p2.y);
X	r.corner.x = max(p1.x, p2.x);
X	r.corner.y = max(p1.y, p2.y);
X
X	return r;
X}
X
X
X
X
ripple()
X{
X
X	Point p1, p2;
X	register xinc, yinc;
X
X
X
X	p1.x = p2.x = avg(Drect.origin.x, Drect.corner.x);
X	p1.y = p2.y = avg(Drect.origin.y, Drect.corner.y);
X	xinc = 1;
X	yinc = 1;
X
X	rectf(&display, Drect, F_XOR);
X
X	while(1)
X	{
X		rectf(&display, canon(p1, p2), F_XOR);
X		dmdrefresh();
X		if (p1.x==Drect.origin.x || p1.x==Drect.corner.x) xinc= -xinc;
X		if (p1.y==Drect.origin.y || p1.y==Drect.corner.y) yinc= -yinc;
X		p1.x-=xinc; p1.y-=yinc;
X		p2.x+=xinc; p2.y+=yinc;
X	}
X}
X
END_OF_FILE
if test 789 -ne `wc -c <'a.c'`; then
    echo shar: \"'a.c'\" unpacked with wrong size!
fi
# end of 'a.c'
fi
if test -f 'b.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'b.c'\"
else
echo shar: Extracting \"'b.c'\" \(623 characters\)
sed "s/^X//" >'b.c' <<'END_OF_FILE'
X#include <tam.h>
X#include "dmd.h"
X
X#define	SIZE	33
X
main()
X{
X	dmdinit();
X	bounce1();
X	dmdreset();
X	exit();
X}
X
X
X
X
bounce1()
X{
X	int	XSIZE =	Drect.corner.x-SIZE;
X	int	YSIZE =	Drect.corner.y-SIZE;
X	int	x;
X	int	y;
X	int	xinc;
X	int	yinc;
X	int	i;
X
X
X
X	xinc = 1;
X	yinc = 1;
X
X	rectf(&display, Drect, F_XOR);
X
X	x = Drect.origin.x;
X	y = Drect.origin.y;
X
X
X	for(i=0;;i++)
X	{
X		i %= 15;
X		rectf(&display, Rect(x, y, x+SIZE, y+SIZE), F_XOR);
X
X		if ( i == 0 )
X			dmdrefresh();
X
X		x = x + xinc;
X
X		if((x == XSIZE) || (x == Drect.origin.x))
X			xinc = -xinc;
X
X		y = y + yinc;
X
X		if((y == YSIZE) || (y == Drect.origin.y))
X			yinc = -yinc;
X	}
X}
X
END_OF_FILE
if test 623 -ne `wc -c <'b.c'`; then
    echo shar: \"'b.c'\" unpacked with wrong size!
fi
# end of 'b.c'
fi
if test -f 'circle.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'circle.c'\"
else
echo shar: Extracting \"'circle.c'\" \(6155 characters\)
sed "s/^X//" >'circle.c' <<'END_OF_FILE'
X
X#include	"dmd.h"
X
X#define	MULSIN45(x)	(((x) * 33461L) / 47321L)
X
X/* circxtoy(x) - Assumes circle radius 724, returns y for x in range 0-511 */
X/* from center point.                                                      */
X
X#define	CIRCRADIUS	724
X#define	CIRCDATPTS	512
X
X
X#define	circxtoy(x)	(circdat[(x)] + CIRCDATPTS)
X
static unsigned char
circdat[CIRCDATPTS] =
X{
X	212, 211, 211, 211, 211, 211, 211, 211,
X	211, 211, 211, 211, 211, 211, 211, 211,
X	211, 211, 211, 211, 211, 211, 211, 211,
X	211, 211, 211, 211, 211, 211, 211, 211,
X	211, 211, 211, 211, 211, 211, 211, 210,
X	210, 210, 210, 210, 210, 210, 210, 210,
X	210, 210, 210, 210, 210, 210, 209, 209,
X	209, 209, 209, 209, 209, 209, 209, 209,
X	209, 209, 208, 208, 208, 208, 208, 208,
X	208, 208, 208, 208, 208, 207, 207, 207,
X	207, 207, 207, 207, 207, 206, 206, 206,
X	206, 206, 206, 206, 206, 206, 205, 205,
X	205, 205, 205, 205, 205, 204, 204, 204,
X	204, 204, 204, 204, 203, 203, 203, 203,
X	203, 203, 202, 202, 202, 202, 202, 202,
X	201, 201, 201, 201, 201, 201, 200, 200,
X	200, 200, 200, 200, 199, 199, 199, 199,
X	199, 198, 198, 198, 198, 198, 197, 197,
X	197, 197, 197, 196, 196, 196, 196, 196,
X	195, 195, 195, 195, 194, 194, 194, 194,
X	194, 193, 193, 193, 193, 192, 192, 192,
X	192, 191, 191, 191, 191, 191, 190, 190,
X	190, 190, 189, 189, 189, 189, 188, 188,
X	188, 187, 187, 187, 187, 186, 186, 186,
X	186, 185, 185, 185, 184, 184, 184, 184,
X	183, 183, 183, 182, 182, 182, 182, 181,
X	181, 181, 180, 180, 180, 179, 179, 179,
X	179, 178, 178, 178, 177, 177, 177, 176,
X	176, 176, 175, 175, 175, 174, 174, 174,
X	173, 173, 173, 172, 172, 172, 171, 171,
X	171, 170, 170, 170, 169, 169, 168, 168,
X	168, 167, 167, 167, 166, 166, 165, 165,
X	165, 164, 164, 164, 163, 163, 162, 162,
X	162, 161, 161, 160, 160, 160, 159, 159,
X	158, 158, 158, 157, 157, 156, 156, 156,
X	155, 155, 154, 154, 153, 153, 153, 152,
X	152, 151, 151, 150, 150, 150, 149, 149,
X	148, 148, 147, 147, 146, 146, 146, 145,
X	145, 144, 144, 143, 143, 142, 142, 141,
X	141, 140, 140, 139, 139, 138, 138, 137,
X	137, 136, 136, 135, 135, 134, 134, 133,
X	133, 132, 132, 131, 131, 130, 130, 129,
X	129, 128, 128, 127, 127, 126, 126, 125,
X	125, 124, 123, 123, 122, 122, 121, 121,
X	120, 120, 119, 118, 118, 117, 117, 116,
X	116, 115, 115, 114, 113, 113, 112, 112,
X	111, 110, 110, 109, 109, 108, 107, 107,
X	106, 106, 105, 104, 104, 103, 103, 102,
X	101, 101, 100,  99,  99,  98,  97,  97,
X	 96,  96,  95,  94,  94,  93,  92,  92,
X	 91,  90,  90,  89,  88,  88,  87,  86,
X	 86,  85,  84,  84,  83,  82,  81,  81,
X	 80,  79,  79,  78,  77,  77,  76,  75,
X	 74,  74,  73,  72,  71,  71,  70,  69,
X	 68,  68,  67,  66,  65,  65,  64,  63,
X	 62,  62,  61,  60,  59,  59,  58,  57,
X	 56,  55,  55,  54,  53,  52,  51,  51,
X	 50,  49,  48,  47,  47,  46,  45,  44,
X	 43,  42,  42,  41,  40,  39,  38,  37,
X	 36,  36,  35,  34,  33,  32,  31,  30,
X	 30,  29,  28,  27,  26,  25,  24,  23,
X	 22,  21,  20,  20,  19,  18,  17,  16,
X	 15,  14,  13,  12,  11,  10,   9,   8,
X	  7,   6,   5,   4,   3,   2,   1,   0
X};
X
X
X
X
X
X
void
circle(b, p, r, f)
X
X	Bitmap		*b;
X	Point		p;
X	int		r;
X	Code		f;
X
X{
X
X
X	short		arcend;
X	short		wholemul;
X	short		partmul;
X	short		wholediv;
X	short		partdiv;
X	short		x;
X	short		y;
X	short		delta;
X	unsigned short	bestdelta;
X	short		bestarcend;
X
X
X
X	if(r == 0)
X		return;
X
X
X
X	wholemul   = (CIRCRADIUS / r);
X	partmul    = (CIRCRADIUS % r);
X	wholediv   = (r / CIRCRADIUS);
X	partdiv    = (r % CIRCRADIUS);
X
X
X
X
X	arcend    = MULSIN45(r);
X	bestdelta = 32768;
X
X
X	/* Adjust Arcend Until It Almost Touches Itself In The Opposite Axis */
X
X	while(arcend < r)
X	{
X		
X		y = (arcend * wholemul) + (arcend * partmul) / CIRCRADIUS;
X		y %= CIRCDATPTS;
X		y = circxtoy(y);
X		y = (y * wholediv) + (y * partdiv)/CIRCRADIUS;
X
X		if(arcend < y)
X			delta = (y - arcend);
X		else
X			delta = (arcend - y);
X
X
printf("arcend= %d, y= %d, delta= %d, bestdelta= %d\n", arcend, y, delta, bestdelta);
X		if(delta <= 1)
X		{
X			bestarcend = arcend;
X			break;
X		}
X		else
X		{
X			if(delta < bestdelta)
X			{
X				bestdelta = delta;
X				bestarcend = arcend;
X			}
X			arcend++;
X		}
X	}
X
X
X
X	arcend = bestarcend;
X
X
X
X
X
X	/* Draw The Crescents */
X
X	for(x = 0; x < arcend; x++)
X	{
X		y = (x * wholemul) + (x * partmul) / CIRCRADIUS;
X		y %= CIRCDATPTS;
X		y = circxtoy(y);
X		y = (y * wholediv) + (y * partdiv)/CIRCRADIUS;
X		point(b, Pt(p.x + x, p.y + y), f);
X		point(b, Pt(p.x - x, p.y + y), f);
X		point(b, Pt(p.x + x, p.y - y), f);
X		point(b, Pt(p.x - x, p.y - y), f);
X		point(b, Pt(p.x + y, p.y + x), f);
X		point(b, Pt(p.x - y, p.y + x), f);
X		point(b, Pt(p.x + y, p.y - x), f);
X		point(b, Pt(p.x - y, p.y - x), f);
X	}
X
X
X}
X
X
X
X
void
disc(b, p, r, f)
X
X	Bitmap	*b;
X	Point	p;
X	int	r;
X	Code	f;
X
X{
X
X	short		arcend;
X	short		wholemul;
X	short		partmul;
X	short		wholediv;
X	short		partdiv;
X	short		x;
X	short		y;
X	short		delta;
X	unsigned short	bestdelta;
X	short		bestarcend;
X
X
X
X	if(r == 0)
X		return;
X
X
X
X	wholemul   = (CIRCRADIUS / r);
X	partmul    = (CIRCRADIUS % r);
X	wholediv   = (r / CIRCRADIUS);
X	partdiv    = (r % CIRCRADIUS);
X
X
X
X
X	arcend    = MULSIN45(r);
X	bestdelta = 32768;
X
X
X	/* Adjust Arcend Until It Almost Touches Itself In The Opposite Axis */
X
X	while(arcend < r)
X	{
X		
X		y = (arcend * wholemul) + (arcend * partmul) / CIRCRADIUS;
X		y %= CIRCDATPTS;
X		y = circxtoy(y);
X		y = (y * wholediv) + (y * partdiv)/CIRCRADIUS;
X
X		if(arcend < y)
X			delta = (y - arcend);
X		else
X			delta = (arcend - y);
X
X
printf("arcend= %d, y= %d, delta= %d, bestdelta= %d\n", arcend, y, delta, bestdelta);
X		if(delta <= 1)
X		{
X			bestarcend = arcend;
X			break;
X		}
X		else
X		{
X			if(delta < bestdelta)
X			{
X				bestdelta = delta;
X				bestarcend = arcend;
X			}
X			arcend++;
X		}
X	}
X
X
X
X	arcend = bestarcend;
X
X
X
X
X
X	/* Draw The Crescents */
X
X	for(x = 0; x < arcend; x++)
X	{
X		y = (x * wholemul) + (x * partmul) / CIRCRADIUS;
X		y %= CIRCDATPTS;
X		y = circxtoy(y);
X		y = (y * wholediv) + (y * partdiv)/CIRCRADIUS;
X		rectf(b, Rect(p.x - x, p.y + y, p.x + x, p.y + y + 1), f);
X		rectf(b, Rect(p.x - x, p.y - y, p.x + x, p.y - y + 1), f);
X		rectf(b, Rect(p.x - y, p.y - x, p.x + y, p.y - x + 1), f);
X		rectf(b, Rect(p.x - y, p.y + x, p.x + y, p.y + x + 1), f);
X	}
X
X
X
X	rectf(b, Rect(p.x - arcend, p.y - arcend, p.x + arcend, p.y + arcend + 1), f);
X
X}
X
X
X
END_OF_FILE
if test 6155 -ne `wc -c <'circle.c'`; then
    echo shar: \"'circle.c'\" unpacked with wrong size!
fi
# end of 'circle.c'
fi
if test -f 'display.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'display.c'\"
else
echo shar: Extracting \"'display.c'\" \(18791 characters\)
sed "s/^X//" >'display.c' <<'END_OF_FILE'
X#include <sys/window.h>	
X#include <stdio.h>
X#include <fcntl.h>
X#include <tam.h>
X#include "dmd.h"
X
extern unsigned short patwhite[];
extern unsigned short patblack[];
X
X/*
X * Special Globals
X */
X
Bitmap 		display;
short		dmdwn;
X
X/*
X * Since I can't directly access screen memory, define a psuedo-display
X * Bitmap called display which will hold temporary Bitmaps before they
X * are wrastop'ed to the real screen.
X */ 
X
Word	disp_base[ (XMAX * YMAX / WORDSIZE) ];
X
X
X
X/*
X * Routine to initialize DMD environment on a 3B1 console.
X */
X
void dmdinit()
X{
X	int wid;
X
X	/*
X	 * Get rid of stdin/stdout/stderr and open a new window
X	 */
X
X	close( 0 );
X	close( 1 );
X	close( 2 );
X	wid = open( "/dev/window",O_RDWR );
X	if ( wid < 0 ) {
X		fprintf(stderr,"\nDMDINIT: No more windows available.\n");
X		wexit(-1); 
X	}
X	dup( 0 );
X	dup( 0 );
X        winit();
X	
X	/*
X	 * Check if the goof is trying to run this on a terminal
X	 */
X
X        if( !iswind() ) {
X                fprintf(stderr,"\nDMDINIT: Not on console display.\n");
X                wexit(-1);
X        }
X
X	/*
X	 * Make a full screen window
X	 */
X
X        dmdwn = wcreate( 0, 0, 25, 80, NBORDER );
X
X	/*
X	 * Initialize display Bitmap
X	 */
X
X	display.base = disp_base;
X	display.width = (XMAX / WORDSIZE);
X	display.rect = Rect( 0, 0, XMAX, YMAX);
X	display._null = (char *)0;
X	Drect = Rect( 0, 0, XMAX, YMAX );
X	Jrect = Rect( 0, 0, XMAX, YMAX );
X
X	/*
X	 * Tell the window manager what we're doing
X	 */ 
X
X	wuser( dmdwn, "DMD" );
X
X	/*
X	 * Get rid of the damn cursor
X	 */
X	
X	wprintf( dmdwn, "\033[=1C" );
X
X	/*
X	 * Go into cbreak() mode
X	 */
X
X	cbreak(); 
X	nodelay( dmdwn, 1 );
X	noecho();
X        clear();
X}
X 
X
X
void dmdreset()
X{
X        clear();
X
X	/*
X	 * Put the cursor back on
X	 */
X	
X	wprintf( dmdwn, "\033[=0C" );
X
X	/*
X	 * Blow the initial window away      
X	 */
X
X        wdelete( dmdwn );
X
X	wexit( 0 );
X}
X
X
X
X/*
X * The Blit uses bitmaps that are mirror images (bit for bit) 
X * of the bitmaps on the 3B1. The following three routines are
X * used by bitblt() - if the source or destination is the 
X * display - to produce recognizable bitmaps.
X */
X
X
X/*
X * Table lookup to swap an 8-bit byte with it's mirror image
X */
X
short SwapByte[ 256 ] = {
X 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
X 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
X 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
X 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
X 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
X 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
X 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
X 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
X 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
X 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
X 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
X 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
X 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
X 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
X 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
X 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
X 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
X 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
X 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
X 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
X 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
X 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
X 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
X 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
X 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
X 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
X 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
X 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
X 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
X 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
X 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
X 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
X};
X
X
X
X/*
X * Routine to swap a 16-bit Word with it's mirror image
X */
X
Word SwapWord( w )
Word w;
X{
X	short a,b;
X
X	a = (short)((w >> 8) & 0x00ff);
X	b = (short)(w & 0x00ff);
X	w = (Word)(SwapByte[ a ] & 0x00ff) |
X	    (Word)(((SwapByte[ b ] & 0x00ff) << 8) & 0xff00);	
X	return( w );	
X} 
X
X
X
X/*
X * Routine to swap an entire bitplane with it's mirror image
X */
X
void SwapBase( base, basewidth, height )
Word	*base;
unsigned short basewidth;
unsigned short height;
X{
X	unsigned int length;
X	unsigned short i;
X
X	length = basewidth * height;
X	for ( i = 0; i < length; i++ ){
X		base[ i ] = SwapWord( base[ i ] );
X	}
X}
X
X
X
X
X/*
X * Routine to refresh screen with current data stored in display.base
X */
X
void dmdrefresh()
X{
X	wrastop( dmdwn, display.base, 90, 0, 0, 0, 0, 0, 0, XMAX, YMAX, 
X		 SRCSRC, DSTSRC, 0 ); 
X}
X
X/*
X * Routine to update display.base with current screen image
X */
X
void dmdgetdisp()
X{
X	wrastop( dmdwn, 0, 0, display.base, 90, 0, 0, 0, 0, XMAX, YMAX, 
X		 SRCSRC, DSTSRC, 0 ); 
X}
X
X
X/*
X * bitblt() emulation using wrastop() - add VIDPAL support later
X */
X
void bitblt( sb, r, db, p, f)
Bitmap		*sb, *db;
Rectangle 	r;
Point		p;
Code		f;
X{
X	Word *srcbase, *dstbase;
X	unsigned short srcwidth, dstwidth;
X	unsigned short srcx, srcy, dstx, dsty;
X	unsigned short width, height;
X	char srcop, dstop;
X	unsigned short *pattern;
X	short SwapFlag;
X
X
X
X	/*
X	 * Assign address of source and destination base
X	 */
X
X	srcbase = sb->base;
X	dstbase = db->base;
X
X
X
X	/*
X	 * srcwidth/dstwidth is in bytes, Bitmap->width is in Words
X	 */
X
X	srcwidth = 2 * sb->width;
X	dstwidth = 2 * db->width;
X
X
X
X	/*
X	 * Assign origin 
X	 */
X
X	srcx = r.origin.x;
X	srcy = r.origin.y;
X	dstx = p.x;
X	dsty = p.y;
X
X
X
X	/*
X	 * Compute width and height
X	 */
X
X	width = r.corner.x - r.origin.x;
X	height = r.corner.y - r.origin.y; 
X
X
X
X
X	/*
X	 * No operations on source base necessary
X	 */ 
X
X	srcop = SRCSRC;
X
X
X
X	/*
X	 * Map Codes to valid DSTOPs
X	 */
X
X	switch( f ){
X	case F_STORE:	dstop = DSTSRC;
X			break;
X	case F_OR:	dstop = DSTOR;
X			break;
X	case F_CLR:	dstop = DSTCAM;
X			break;
X	case F_XOR:	dstop = DSTXOR;
X			break;
X	default:	dstop = DSTSRC;
X	}
X
X
X
X	/*
X	 * No patterns, use texture16() 
X	 */
X
X	pattern = 0;
X
X
X
X	/*
X	 * Check if one of input/output is the display 
X	 */
X
X	if ( ((dstbase == display.base) || (srcbase == display.base))
X		&& (dstbase != srcbase) ) {
X
X		/*
X		 * Case: Putting stuff on display (ie. dstbase = display.base)
X		 */
X
X		if (dstbase == display.base){
X
X			/* Wrastop Bitmap onto pseudo-display */
X
X			wrastop( dmdwn, srcbase, srcwidth, dstbase, dstwidth, 
X				 srcx, srcy, dstx, dsty, width, height, 
X				 srcop, DSTSRC, pattern ); 
X
X			/* Swap bits in Bitmap to 3B1 orientation */
X
X			SwapBase( dstbase, db->width, height );
X
X			/* Wrastop psuedo-display onto real display */
X
X			wrastop( dmdwn, dstbase, dstwidth, 0, 0,
X				 dstx, dsty, dstx, dsty, width, height, 
X				 srcop, dstop, pattern ); 
X
X		}
X	
X		/*
X		 * Case: Taking stuff from display (ie. srcbase = display.base)
X		 */
X
X		else { 
X
X			/* Wrastop stuff from screen to psuedo-display */
X
X			wrastop( dmdwn, 0, 0, srcbase, srcwidth, srcx, srcy,
X		                 srcx, srcy, width, height, srcop, DSTSRC, 0 ); 
X
X			/* Swap bits in Bitmap to 3B1 orientation */
X
X			SwapBase( srcbase, sb->width, height );
X
X			/* Wrastop stuff from psuedo-display to destination */
X
X			wrastop( dmdwn, srcbase, srcwidth, dstbase, dstwidth, 
X				 srcx, srcy, dstx, dsty, width, height, 
X				 srcop, dstop, pattern ); 
X
X		}
X	}
X
X	/*
X	 * Display not involved in bitblt operation so use wrastop
X	 */
X
X	else{
X		wrastop(dmdwn, srcbase, srcwidth, dstbase, dstwidth, srcx, srcy,
X                dstx, dsty, width, height, srcop, dstop, pattern ); 
X	}
X
X}
X
X/*
X * Routine to figure out the address of a point in a Bitmap
X */
X
Word	*
addr(b, p)
Bitmap	*b;
Point	p;
X{
X	Word	*address;
X
X
X
X	/* Validate Range */
X
X	if((p.x < (b->rect.origin.x)) || (p.x >= (b->rect.corner.x)))
X		return((Word *)0);
X	else if((p.y < (b->rect.origin.y)) || (p.y >= (b->rect.corner.y)))
X		return((Word *)0);
X
X
X
X	/* Compute Address */
X
X	address  = (b->base) + (p.y - b->rect.origin.y) * (b->width);
X	address += ((p.x - b->rect.origin.x) / (WORDSIZE));
X	return(address);
X}
X
X
X
X
X/*
X * Routine to print a Rectangle in a Bitmap according to a given Code.
X */
X
X
void rectf(b, r, f)
Bitmap		*b;
Rectangle	r;
Code		f;
X{
X	short		x1;
X	short		y1;
X	short		x2;
X	register short	y2;
X	register Word	*address;
X	short		x;
X	register short	y;
X	short		width;
X	register Word	bitmask;
X	short		xfullstart;
X	short		xfullwidth;
X	register Word	*endaddress;
X	short		onscreen;	/* Target Bitmap Is On Screen */
X
X
X	if(f == F_OR)
X		f = F_STORE;
X
X
X
X	/* Clip To Target Bitmap Boundaries */
X
X	x1 = max(b->rect.origin.x, r.origin.x);
X	y1 = max(b->rect.origin.y, r.origin.y);
X	x2 = min(b->rect.corner.x, r.corner.x);
X	y2 = min(b->rect.corner.y, r.corner.y);
X
X
X
X
X	/* Check If Target Bitmap Is In Screen Memory */
X
X	address = addr(b, b->rect.origin);
X
X	if( b->base == display.base ){
X		onscreen = 1;
X	}
X	else
X		onscreen = 0;
X
X
X
X
X
X	width = x2 - x1;
X	x = x1;
X
X	/* If Not Starting On Even Word Boundary */
X	/* Do A Partial Word Fill                */
X
X	if(x % (WORDSIZE))
X	{
X		if(width < ((WORDSIZE) - (x % (WORDSIZE))))
X		{	/* Byte Doesn't Fill */
X			bitmask = ((ONES >> (x % (WORDSIZE))) & (ONES << ((WORDSIZE) - (x2 % (WORDSIZE)))));
X			address = addr(b, Pt(x, y1));
X			x      += width;
X			width   = 0;
X		}
X		else	/* Fills To Right Of Byte */
X		{
X			bitmask   = (ONES >> (x % (WORDSIZE)));
X			address   = addr(b, Pt(x, y1));
X			width    -= ((WORDSIZE) - (x % (WORDSIZE)));
X			x        += ((WORDSIZE) - (x % (WORDSIZE)));
X		}
X
X
X
X		if(onscreen)
X			bitmask = SwapWord(bitmask);
X
X
X		if(f == F_XOR)
X		{
X			for(y = y1; y < y2; y++)
X			{
X				*address ^= bitmask;
X				address  += (b->width);
X			}
X		}
X		else if(f == F_STORE)
X		{
X			for(y = y1; y < y2; y++)
X			{
X				*address |= bitmask;
X				address  += (b->width);
X			}
X		}
X		else if(f == F_CLR)
X		{
X			bitmask = ~bitmask;
X
X			for(y = y1; y < y2; y++)
X			{
X				*address &= bitmask;
X				address  += (b->width);
X			}
X		}
X
X	}
X
X
X
X
X	if(width >= (WORDSIZE))
X	{
X		xfullstart = x;
X		xfullwidth = ((WORDSIZE) * (width / (WORDSIZE)));
X		x         += xfullwidth;
X		width     -= xfullwidth;
X	}
X	else
X		xfullwidth = 0;
X
X
X
X
X
X
X
X	/* Do We Still Have Remaining Bits?   */
X	/* If So, Fill With Partial Bytes.    */
X
X	if(width)
X	{
X		bitmask = ((ONES >> ((WORDSIZE) - width)) << ((WORDSIZE) - width));
X		address = addr(b, Pt(x, y1));
X
X
X		if(onscreen)
X			bitmask = SwapWord(bitmask);
X
X		if(f == F_XOR)
X		{
X			for(y = y1; y < y2; y++)
X			{
X				*address ^= bitmask;
X				address  += (b->width);
X			}
X		}
X		else if(f == F_STORE)
X		{
X			for(y = y1; y < y2; y++)
X			{
X				*address |= bitmask;
X				address  += (b->width);
X			}
X		}
X		else if(f == F_CLR)
X		{
X			bitmask = ~bitmask;
X
X			for(y = y1; y < y2; y++)
X			{
X				*address &= bitmask;
X				address  += (b->width);
X			}
X		}
X
X
X	}
X
X
X
X
X
X
X
X
X	if(xfullwidth)
X	{
X
X
X		if(f == F_XOR)
X		{
X
X				for(y = y1; y < y2; y++)
X				{
X					address    = addr(b, Pt(xfullstart, y));
X					endaddress = address + (xfullwidth / (WORDSIZE));
X
X					while(address < endaddress)
X						*(address++) ^= ONES;
X				}
X		}
X		else
X		{
X
X			if(f == F_STORE)
X				bitmask = ONES;
X			else
X				bitmask = ~ONES;
X
X
X
X			for(y = y1; y < y2; y++)
X			{
X				address    = addr(b, Pt(xfullstart, y));
X				endaddress = address + (xfullwidth / (WORDSIZE));
X
X				while(address < endaddress)
X					*(address++) = bitmask;
X			}
X		}
X
X	}
X}
X
X#define	ABS(x)		((x) < 0 ? (-(x)) : (x))
X#define SWAP(s1, s2)	{ int tmp; tmp = s1; s1 = s2; s2 = tmp; }
X
X#define xtopixmask(x)	(dpixmask[(x) % (WORDSIZE)])
X
static Word	dpixmask[16] =
X{
X	0x8000,	0x4000,	0x2000,	0x1000,
X	0x0800,	0x0400,	0x0200,	0x0100,
X	0x0080,	0x0040,	0x0020,	0x0010,
X	0x0008,	0x0004,	0x0002,	0x0001,
X};
X
X
void segment(b, p1, p2, f)
Bitmap	*b;
Point	p1;
Point	p2;
Code	f;
X{
X	short	d, x, y, incr1, incr2, xend;
X	short		rotate;
X	Point		pswap;
X	Point		pdelta;
X	short		onscreen;
X	Word		bitmask;
X	Word		*address;
X
X
X	if(f == F_OR)
X		f = F_STORE;
X
X
X	
X
X	/* FUTURE: Clip The Line To The Confines Of The Bitmap */
X	/* Rather Than Checking At Point Plot Time.            */
X
X
X
X
X
X
X	/* Check If Target Bitmap Is In Screen Memory */
X
X	address = addr(b, b->rect.origin);
X
X	if( b->base == display.base ){
X		onscreen = 1;
X	}
X	else
X		onscreen = 0;
X
X
X
X
X
X
X	pdelta.y = p2.y - p1.y;
X	pdelta.x = p2.x - p1.x;
X
X	/*
X	 * The octants are numbered 1 through 8, counterclockwise,
X	 * starting with octant 1 being east-northeast.
X	 * If we are in octants 2, 3, 6, or 7, then rotate the line
X	 * about the line x=y.  This maps octant 2 into 1,
X	 * octant 3 into 8, octant 6 into 5 and octant 7 into 4.
X	 * We must remember this rotation for later, as we will
X	 * re-rotate the points when we plot them.
X	 */
X
X	if (ABS(pdelta.x) >= ABS(pdelta.y))
X		rotate = 0;
X	else
X	{
X		rotate = 1;
X		pswap  = p1;
X		p1.x = pswap.y;
X		p1.y = pswap.x;
X		pswap  = p2;
X		p2.x = pswap.y;
X		p2.y = pswap.x;
X		pswap  = pdelta;
X		pdelta.x = pswap.y;
X		pdelta.y = pswap.x;
X	}
X
X	if(pdelta.x < 0)
X	{
X		/*
X		 * We're in octants 4 or 5.
X		 * Swap the starting and ending points, mapping
X		 * octant 4 to 8, and octant 5 to 1.
X		 * This will generate the points in reverse order
X		 * for octants 3 and 5 (i.e., we'll go from the end
X		 * to the beginning), but who cares?
X		 */
X
X		pswap = p1;
X		p1    = p2;
X		p2    = pswap;
X		pdelta.x = -(pdelta.x);
X		pdelta.y = -(pdelta.y);
X	}
X
X
X
X
X
X
X
X	/*
X	 * At this point we're guaranteed that dx >= 0, and x0 < x1.
X	 */
X
X	if(pdelta.y < 0)
X	{
X		/*
X		 * Octants 3, 4, 7 or 8.
X		 * x will be: x1, x1-1, x1-2, ..., x0.
X		 */
X
X		xend  = p1.x;
X		y     = p2.y;
X
X		incr1 = 2 * (-(pdelta.y));	/* remember that dy < 0 */
X		d     = incr1 - pdelta.x;	/* 2*dy - dx */
X		incr2 = d - pdelta.x;		/* 2*dy - 2*dx = 2*(dy - dx) */
X
X		if(rotate)
X		{	/* main loop, octants 3 or 7 */
X
X			if(f == F_STORE)
X			{
X				for(x = p2.x; x >= xend; x--)
X				{
X					if(ptinrect(Pt(y, x), b->rect))
X					{
X						bitmask = xtopixmask(y);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(y, x))) |= bitmask;
X					}
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X			else if(f == F_XOR)
X			{
X				for(x = p2.x; x >= xend; x--)
X				{
X					if(ptinrect(Pt(y, x), b->rect))
X					{
X						bitmask = xtopixmask(y);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(y, x))) ^= bitmask;
X					}
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X			else if(f == F_CLR)
X			{
X				for(x = p2.x; x >= xend; x--)
X				{
X					if(ptinrect(Pt(y, x), b->rect))
X					{
X						bitmask = xtopixmask(y);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(y, x))) &= ~bitmask;
X					}
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X
X		}
X		else
X		{	/* main loop, octants 4 or 8 */
X
X			if(f == F_STORE)
X			{
X				for(x = p2.x; x >= xend; x--)
X				{
X
X					if(ptinrect(Pt(x, y), b->rect))
X					{
X						bitmask = xtopixmask(x);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(x, y))) |= bitmask;
X					}
X
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X			else if(f == F_XOR)
X			{
X				for(x = p2.x; x >= xend; x--)
X				{
X
X					if(ptinrect(Pt(x, y), b->rect))
X					{
X						bitmask = xtopixmask(x);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(x, y))) ^= bitmask;
X					}
X
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X			else if(f == F_CLR)
X			{
X				for(x = p2.x; x >= xend; x--)
X				{
X
X					if(ptinrect(Pt(x, y), b->rect))
X					{
X						bitmask = xtopixmask(x);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(x, y))) &= ~bitmask;
X					}
X
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X		}
X
X	}
X	else
X	{
X		/*
X		 * Octants 1, 2, 5 or 6.
X		 * x will be: x0, x0+1, x0+2, ..., x1.
X		 */
X
X		xend  = p2.x;
X		y     = p1.y;
X
X		incr1 = 2 * pdelta.y;
X		d     = incr1 - pdelta.x;	/* 2*dy - dx */
X		incr2 = d - pdelta.x;		/* 2*dy - 2*dx = 2*(dy - dx) */
X
X		if(rotate)
X		{	/* main loop, octants 2 or 6 */
X
X			if(f == F_STORE)
X			{
X				for(x = p1.x; x <= xend; x++)
X				{
X
X					if(ptinrect(Pt(y, x), b->rect))
X					{
X						bitmask = xtopixmask(y);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(y, x))) |= bitmask;
X					}
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X			else if(f == F_XOR)
X			{
X				for(x = p1.x; x <= xend; x++)
X				{
X
X					if(ptinrect(Pt(y, x), b->rect))
X					{
X						bitmask = xtopixmask(y);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(y, x))) ^= bitmask;
X					}
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X			else if(f == F_CLR)
X			{
X				for(x = p1.x; x <= xend; x++)
X				{
X
X					if(ptinrect(Pt(y, x), b->rect))
X					{
X						bitmask = xtopixmask(y);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(y, x))) &= ~bitmask;
X					}
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X		}
X		else
X		{	/* main loop, octants 1 or 5 */
X
X			if(f == F_STORE)
X			{
X				for(x = p1.x; x <= xend; x++)
X				{
X
X					if(ptinrect(Pt(x, y), b->rect))
X					{
X						bitmask = xtopixmask(x);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(x, y))) |= bitmask;
X					}
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X			else if(f == F_XOR)
X			{
X				for(x = p1.x; x <= xend; x++)
X				{
X
X					if(ptinrect(Pt(x, y), b->rect))
X					{
X						bitmask = xtopixmask(x);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(x, y))) ^= bitmask;
X					}
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X			else if(f == F_CLR)
X			{
X				for(x = p1.x; x <= xend; x++)
X				{
X
X					if(ptinrect(Pt(x, y), b->rect))
X					{
X						bitmask = xtopixmask(x);
X
X						if(onscreen)
X							bitmask = SwapWord(bitmask);
X
X						*(addr(&display, Pt(x, y))) &= ~bitmask;
X					}
X
X
X					if(d > 0)
X					{
X						y++;
X						d += incr2;
X					}
X					else
X						d += incr1;
X				}
X			}
X		}
X	}
X}
X
void point(b, p, f)
Bitmap	*b;
Point	p;
Code	f;
X{
X	Word	bitmask;
X	Word	*address;
X	Word	*dstbase;
X	int	onscreen;
X
X
X
X	/* Return If Point Is Outside Target Bitmap Boundaries */
X
X	if(!ptinrect(p, b->rect))
X		return;
X
X	/* Check if bitmap is display */
X
X	if( b->base = display.base )
X		onscreen = 1;
X	else
X		onscreen = 0;
X
X
X	/* Determine Address & Bit Mask For This Point */
X
X	address = addr(b, p);
X
X	if ( onscreen )
X		bitmask = SwapWord(xtopixmask(p.x - b->rect.origin.x));
X	else
X		bitmask = xtopixmask(p.x - b->rect.origin.x);
X
X
X	if((f == F_STORE) || (f == F_OR))
X		*address |= bitmask;
X	else if(f == F_XOR)
X		*address ^= bitmask;
X	else if(f == F_CLR)
X		*address &= ~bitmask;
X
X}
END_OF_FILE
if test 18791 -ne `wc -c <'display.c'`; then
    echo shar: \"'display.c'\" unpacked with wrong size!
fi
# end of 'display.c'
fi
if test -f 'dmd.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dmd.h'\"
else
echo shar: Extracting \"'dmd.h'\" \(2045 characters\)
sed "s/^X//" >'dmd.h' <<'END_OF_FILE'
X/*
X *	AT&T 3B1/UNIXpc/PC 7300 Dot Mapped Display
X */
X
X#define WORDSHIFT	4
X#define WORDSIZE	16
X#define WORDMASK	(WORDSIZE-1)
X#define ONES		0xFFFF
X#define FIRSTBIT	((unsigned short)0x8000)
X#define LASTBIT		((unsigned short)0x0001)
X
X#define max(a,b)	(( a > b ) ? a : b )
X#define min(a,b)	(( a < b ) ? a : b )
X
X#define XMAX	720
X#define YMAX	300
X
X/*
X *	Graphics Definitions
X */
X
X#define POLY_F	-32768
X
typedef short Word;
typedef unsigned short UWord;
X
typedef struct Point {
X	short x;		/* X-axis coordinate */
X	short y;		/* Y-axis coordinate */
X} Point;
X
typedef struct Rectangle {
X	Point	origin;		/* Top left corner */
X	Point	corner;   	/* Bottom right corner */
X} Rectangle;
X
typedef struct Bitmap {
X	Word		*base; 	/* Pointer to start of bitplane */
X	unsigned short 	width;	/* Width of bitplane in Words */
X	Rectangle	rect;	/* Region of bitplane you're addressing */
X	char 		*_null	/* Useless junk, unused */
X} Bitmap;
X
typedef struct Texture16 {
X	Word	bits[16];
X} Texture16;
X
extern Point		Pt();
extern Rectangle	Rpt();
extern Rectangle	Rect();
extern Point		add();
extern Point		sub();
extern Point		mul();
extern Point		div();
extern int		eqpt();
extern int		eqrect();
extern int 		ptinrect();
extern Rectangle	inset();
extern Rectangle	raddpt();
extern Rectangle	rsubpt();
extern int 		rectclip();
extern int 		rectXrect();
extern short		muldiv();
X
X/*
X *	Miscillaneous Codes - used by bitblt(3R)
X */ 
X
typedef int Code;
X
X#define F_STORE	((Code) 0)	/* dest  = source */
X#define F_OR	((Code) 1)	/* dest |= source */
X#define F_CLR	((Code) 2)	/* dest &= source */
X#define F_XOR	((Code) 3)	/* dest ^= source */
X
X/*
X * Global variables used in dmdinit() and dmdreset()
X */
X
extern Bitmap		display;	/* psuedo Bitmap for display */
extern short		dmdwn;		/* window number of DMD window */
extern Rectangle	Drect;
extern Rectangle 	Jrect;
X
X
X#define	request(n)
X#define	sw(n)
X#define	WonB()
X#define	BonW()
X#define	spl0()
X#define	bttn1()		0
X#define	bttn2()		0
X#define	bttn3()		0
X#define	bttn12()	0
X#define	bttn23()	0
X#define	bttn13()	0
X#define	bttn123()	0
END_OF_FILE
if test 2045 -ne `wc -c <'dmd.h'`; then
    echo shar: \"'dmd.h'\" unpacked with wrong size!
fi
# end of 'dmd.h'
fi
if test -f 'font.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'font.c'\"
else
echo shar: Extracting \"'font.c'\" \(372 characters\)
sed "s/^X//" >'font.c' <<'END_OF_FILE'
X
X#include	"dmd.h"
X#include	"font.h"
X
X
XFont defont;
X
X
X
XFont	*
infont(inch)
X
X	int	(*inch)();
X
X{
X}
X
X
X
X
XFont	*
getfont(file)
X
X	char	*file;
X
X{
X}
X
X
X
X
int
outfont(f, ouch)
X
X	Font	*f;
X	int	(*ouch)();
X
X{
X}
X
X
X
X
void
ffree(f)
X
X	Font	*f;
X
X{
X}
X
X
X
Point
string(ft, s, b, p, f)
X
X	Font	*ft;
X	char	*s;
X	Bitmap	*b;
X	Point	p;
X	Code	f;
X
X{
X}
X
X
X
int
strwidth(f, s)
X
X	Font	*f;
X	char	*s;
X
X{
X}
X
X
X
END_OF_FILE
if test 372 -ne `wc -c <'font.c'`; then
    echo shar: \"'font.c'\" unpacked with wrong size!
fi
# end of 'font.c'
fi
if test -f 'font.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'font.h'\"
else
echo shar: Extracting \"'font.h'\" \(383 characters\)
sed "s/^X//" >'font.h' <<'END_OF_FILE'
X
X/* Font Structures */
X
typedef struct Fontchar
X{
X	short	x;
X	char	top;
X	char	bottom;
X	char	left;
X	char	width;
X} Fontchar;
X
X
typedef struct Font
X{
X	short	n;
X	char	height;
X	char	ascent;
X	long	unused;
X	Bitmap	*bits;
X	Fontchar	info[1];
X} Font;
X
X
X
X
X/* Global Definitions */
X
extern Font	defont;
X
X
extern Font	*infont();
extern Font	*getfont();
extern int	outfont();
extern void	ffree();
X
END_OF_FILE
if test 383 -ne `wc -c <'font.h'`; then
    echo shar: \"'font.h'\" unpacked with wrong size!
fi
# end of 'font.h'
fi
if test -f 'general.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'general.c'\"
else
echo shar: Extracting \"'general.c'\" \(3988 characters\)
sed "s/^X//" >'general.c' <<'END_OF_FILE'
X#include	<stdio.h>
X#include	"dmd.h"
X
X/* Special Globals */
X
Rectangle	Drect;
Rectangle	Jrect;
X
short muldiv( a, b, c )
int a, b, c;
X{
X	return( (short)(a * b / c) );
X}
X
X
Point add(p1, p2)
Point	p1;
Point	p2;
X{
X	Point	retval;
X
X	retval.x = (p1.x + p2.x);
X	retval.y = (p1.y + p2.y);
X
X	return(retval);
X}
X
X
X
Point sub(p1, p2)
Point	p1;
Point	p2;
X{
X	Point	retval;
X
X	retval.x = (p1.x - p2.x);
X	retval.y = (p1.y - p2.y);
X
X	return(retval);
X}
X
X
X
Point mul(p1, n)
Point	p1;
int	n;
X{
X	Point	retval;
X
X	retval.x = (p1.x * n);
X	retval.y = (p1.y * n);
X
X	return(retval);
X}
X
X
X
Point div(p1, n)
Point	p1;
int	n;
X{
X	Point	retval;
X
X	retval.x = (p1.x / n);
X	retval.y = (p1.y / n);
X
X	return(retval);
X}
X
X
X
int eqpt(p1, p2)
Point	p1;
Point	p2;
X{
X	if(p1.x != p2.x)
X		return(0);
X	else if(p1.y != p2.y)
X		return(0);
X	else
X		return(1);
X}
X
X
X
int eqrect(r1, r2)
Rectangle	r1;
Rectangle	r2;
X{
X	if(!eqpt(r1.origin, r2.origin))
X		return(0);
X	else if(!eqpt(r1.corner, r2.corner))
X		return(0);
X	else
X		return(1);
X}
X
X
X
X/* This one should really be checked to see if >= should be > */
X/* for true compatability.                                    */
X
int ptinrect(p, r)
Point		p;
Rectangle	r;
X{
X	if(p.x < r.origin.x)
X		return(0);
X	else if(p.y < r.origin.y)
X		return(0);
X	else if(p.x >= r.corner.x)
X		return(0);
X	else if(p.y >= r.corner.y)
X		return(0);
X	else
X		return(1);
X
X}
X
X
X
Rectangle inset(r, n)
Rectangle	r;
int		n;
X{
X	Rectangle	retval;
X
X	retval.origin = add(r.origin, Pt(n, n));
X	retval.corner = add(r.corner, Pt(n, n));
X
X	return(retval);
X}
X
X
X
Rectangle raddp(r, p)
Rectangle	r;
Point		p;
X{
X	return(Rpt(add(r.origin, p), add(r.origin, p)));
X}
X
X
X
Rectangle rsubp(r, p)
Rectangle	r;
Point		p;
X{
X	return(Rpt(sub(r.origin, p), sub(r.origin, p)));
X}
X
X
X
Point Pt(x, y)
short	x;
short	y;
X{
X	Point	retval;
X
X	retval.x = x;
X	retval.y = y;
X
X	return(retval);
X
X}
X
X
X
Rectangle Rect(x1, y1, x2, y2)
short	x1;
short	y1;
short	x2;
short	y2;
X{
X	Rectangle	retval;
X
X	retval.origin.x = x1;
X	retval.origin.y = y1;
X	retval.corner.x = x2;
X	retval.corner.y = y2;
X
X	return(retval);
X}
X
X
X
Rectangle Rpt(p1, p2)
Point	p1;
Point	p2;
X{
X	Rectangle	retval;
X
X	retval.origin = p1;
X	retval.corner = p2;
X
X	return(retval);
X
X}
X
X
X
int rectclip(rp, s)
Rectangle	*rp;
Rectangle	s;
X{
X	int		corners;
X
X	if(!rectXrect(*rp, s))
X		return(0);
X
X	/* We'll Mark The Corners Contained In 'corners' */
X	/*                                               */
X	/*         0x01             0x02                 */
X	/*                                               */
X	/*         0x04             0x08                 */
X	/*                                               */
X	/*                                               */
X
X	corners = 0;
X
X	if(ptinrect(rp->origin, s))
X		corners |= 0x01;
X	if(ptinrect(Pt(rp->corner.x - 1, rp->origin.y), s))
X		corners |= 0x02;
X	if(ptinrect(Pt(rp->origin.x, rp->corner.y - 1), s))
X		corners |= 0x04;
X	if(ptinrect(Pt(rp->corner.x - 1, rp->corner.y - 1), s))
X		corners |= 0x08;
X
X	/* Only 15 Possible Clipping Combinations */
X	/* Redundant Code, But Much Faster        */
X
X	switch(corners)
X	{
X		case 0x00:	*rp = s;
X				break;
X
X		case 0x01:	rp->corner = s.corner;
X				break;
X
X		case 0x02:	rp->origin.x = s.origin.x;
X				rp->corner.y = s.corner.y;
X				break;
X
X		case 0x03:	rp->corner.y = s.corner.y;
X				break;
X
X		case 0x04:	rp->origin.y = s.origin.y;
X				rp->corner.x = s.corner.x;
X				break;
X
X		case 0x05:	rp->corner.x = s.corner.x;
X				break;
X
X		case 0x08:	rp->origin = s.origin;
X				break;
X
X		case 0x0a:	rp->origin.x = s.origin.x;
X				break;
X
X		case 0x0c:	rp->origin.y = s.origin.y;
X				break;
X
X		case 0x0f:	break;
X
X		case 0x06:
X		case 0x07:
X		case 0x09:
X		case 0x0b:
X		case 0x0d:
X		case 0x0e:
X		default:	fputs("rectclip: Semantic Error\n", stderr);
X				break;
X	}
X
X	return(1);
X
X}
X
X
X
int rectXrect(r1, r2)
Rectangle	r1;
Rectangle	r2;
X{
X	if(r1.origin.x >= r2.corner.x)
X		return(0);
X	else if(r1.origin.y >= r2.corner.y)
X		return(0);
X	else if(r1.corner.x < r2.origin.x)
X		return(0);
X	else if(r1.corner.y < r2.origin.y)
X		return(0);
X	else
X		return(1);
X}
END_OF_FILE
if test 3988 -ne `wc -c <'general.c'`; then
    echo shar: \"'general.c'\" unpacked with wrong size!
fi
# end of 'general.c'
fi
if test -f 'jroutines.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'jroutines.c'\"
else
echo shar: Extracting \"'jroutines.c'\" \(1700 characters\)
sed "s/^X//" >'jroutines.c' <<'END_OF_FILE'
X
X
X
X#include	"dmd.h"
X#include	"font.h"
X
X
X
X
static Point	cursor = { 0, 0 };
X
X
X
X
X
void
jinit()
X{
X}
X
X
X
X
X
X
X
X
X
void
jcircle(p, r, f)
X
X	Point	p;
X	int	r;
X	Code	f;
X
X{
X#ifndef	MPX
X	circle(&display, p, r, f);
X#endif	/* MPX */
X}
X
X
X
X
X
void
jdisc(p, r, f)
X
X	Point	p;
X	int	r;
X	Code	f;
X
X{
X#ifndef	MPX
X	disc(&display, p, r, f);
X#endif	/* MPX */
X}
X
X
X
X
X
X
void
jarc(p1, p2, p3, f)
X
X	Point	p1;
X	Point	p2;
X	Point	p3;
X	Code	f;
X
X{
X#ifndef	MPX
X	arc(&display, p1, p2, p3, f);
X#endif	/* MPX */
X}
X
X
X
X
X
X
void
jellipse(p, a, b, f)
X
X	Point	p;
X	int	a;
X	int	b;
X	Code	f;
X
X{
X#ifndef	MPX
X	ellipse(&display, p, a, b, f);
X#endif	/* MPX */
X}
X
X
X
X
X
X
X
void
jeldisc(p, a, b, f)
X
X	Point	p;
X	int	a;
X	int	b;
X	Code	f;
X
X{
X#ifndef	MPX
X	eldisc(&display, p, a, b, f);
X#endif	/* MPX */
X}
X
X
X
X
X
X
X
void
jelarc(p1, a, b, p2, p3, f)
X
X	Point	p1;
X	int	a;
X	int	b;
X	Point	p2;
X	Point	p3;
X	Code	f;
X
X{
X#ifndef	MPX
X	elarc(&display, p1, a, b, p2, p3, f);
X#endif	/* MPX */
X}
X
X
X
X
X
X
void
jline(p, f)
X
X	Point	p;
X	Code	f;
X
X{
X	segment(&display, cursor, p, f);
X	cursor = p;
X}
X
X
X
X
void
jlineto(p, f)
X
X	Point	p;
X	Code	f;
X
X{
X#ifndef	MPX
X	segment(&display, cursor, p, f);
X#endif	/* MPX */
X	cursor = p;
X}
X
X
X
X
void
jsegment(p, q, f)
X
X	Point	p;
X	Point	q;
X	Code	f;
X
X{
X	segment(&display, p, q, f);
X	cursor = q;
X}
X
X
X
X
X
void
jmove(p)
X
X	Point	p;
X
X{
X	cursor = add(cursor, p);
X}
X
X
X
X
void
jmoveto(p)
X
X	Point	p;
X
X{
X	cursor = p;
X}
X
X
X
X
X
void
jpoint(p, f)
X
X	Point	p;
X	Code	f;
X
X{
X	point(&display, p, f);
X}
X
X
X
X
X
void
jrectf(r, f)
X
X	Rectangle	r;
X	Code		f;
X
X{
X	rectf(&display, r, f);
X}
X
X
X
Point
jstring(s)
X
X	char	*s;
X
X{
X	cursor = string(&defont, s, &display, cursor, F_XOR);
X
X	return(cursor);
X}
X
X
X
void
jtexture(r, t, f)
X
X	Rectangle	r;
X	Texture		*t;
X	Code		f;
X
X{
X	texture(&display, r, t, f);
X}
X
X
END_OF_FILE
if test 1700 -ne `wc -c <'jroutines.c'`; then
    echo shar: \"'jroutines.c'\" unpacked with wrong size!
fi
# end of 'jroutines.c'
fi
if test -f 'm.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'m.c'\"
else
echo shar: Extracting \"'m.c'\" \(3083 characters\)
sed "s/^X//" >'m.c' <<'END_OF_FILE'
X#include "dmd.h"
X
X
X
int	Xmin;
int	Ymin;
int	Xmax;
int	Ymax;
X
X
X
X
main()
X{
X	dmdinit();
X	grandmal();
X	dmdreset();
X	exit();
X}
X
X
X
X
X
combox(x, y, xs, ys, f)
X
X	int x, y, xs, ys;
X	Code f;
X
X{
X
X	if (x<Xmin) { 
X		xs+=Xmin-x;
X		x=Xmin; 
X	}
X	if (y<Ymin) { 
X		ys+=Ymin-y;
X		y=Ymin; 
X	}
X	if ((x<Xmax) && (y<Ymax)) {
X		if (x+xs>(Xmax-1)) xs=(Xmax-1)-x;
X		if (y+ys>(Ymax-1)) ys=(Ymax-1)-y;
X		rectf(&display, Rect(x, y, x+xs, y+ys), f);
X	}
X}
sort(p, q, u, v)
X	register int *p, *q, *u, *v;
X{
X	register t;
X	if(*p>*q){
X		t= *p;
X		*p= *q;
X		*q= t;
X		t= *u;
X		*u= *v;
X		*v= t;
X	}
X}
lim5(v)
X	register v;
X{
X	if(v<-5)
X		return -5;
X	if(v>5)
X		return 5;
X}
X
grandmal() {
X	int x0, y0, x1, y1, t, vx0, vy0, vx1, vy1, snooze;
X	Code f;
X	int c;
X
loop:
X	Xmin=Drect.origin.x;
X	Ymin=Drect.origin.y;
X	Xmax=Drect.corner.x;
X	Ymax=Drect.corner.y;
X	rectf(&display, display.rect, F_OR);
X	x1=x0=(Xmax+Xmin)/2;
X	y1=y0=(Ymax+Ymin)/2;
X	vx0=0;
X	vy0=0;
X	vx1=0;
X	vy1=0;
X	f=F_XOR;
X	while (1) {
X		dmdrefresh();
X		if ((x0!=x1) && (y0!=y1))
X			combox (x0, y0, (x1-x0), (y1-y0), f);
X		if (rx(1, 10)!=1) f=F_XOR; 
X		else f=F_OR;
X		vx0=lim5(vx0+rx(-1, 1));
X		x0+=vx0;
X		if (x0<Xmin) {
X			x0=2*Xmin-x0;
X			vx0= -vx0;
X		} else if ((Xmax-1)<x0) {
X			x0=2*(Xmax-1)-x0;
X			vx0= -vx0;
X		}
X		vx1=lim5(vx1+rx(-1, 1));
X		x1+=vx1;
X		if (x1<Xmin) {
X			x1=2*Xmin-x1;
X			vx1= -vx1;
X		} else if ((Xmax-1)<x1) {
X			x1=2*(Xmax-1)-x1;
X			vx1= -vx1;
X		}
X		sort(&x0, &x1, &vx0, &vx1);
X		vy0+=rx(-1, 1);
X		if (vy0<-5) vy0= -5; 
X		else if (5<vy0) vy0=5;
X		y0+=vy0;
X		if (y0<Ymin) {
X			y0=2*Ymin-y0;
X			vy0= -vy0;
X		} else if ((Ymax-1)<y0) {
X			y0=2*(Ymax-1)-y0;
X			vy0= -vy0;
X		}
X		vy1+=rx(-1, 1);
X		if (vy1<-5) vy1= -5; 
X		else if (5<vy1) vy1=5;
X		y1+=vy1;
X		if (y1<Ymin) {
X			y1=2*Ymin-y1;
X			vy1= -vy1;
X		} else if ((Ymax-1)<y1) {
X			y1=2*(Ymax-1)-y1;
X			vy1= -vy1;
X		}
X		sort(&y0, &y1, &vy0, &vy1);
X	}
X	if(c==' ')
X		goto loop;
X}
X#define PP       98
X#define QQ       27
X#define Pm1     (PP-1)
X	
int I=Pm1, J=(Pm1+QQ)%PP;
int Table[PP]={
X	0020651, 0147643, 0164707, 0125262, 0104256, 0074760, 0114470,
X	0052607, 0045551, 0134031, 0024107, 0030766, 0154073, 0114777,
X	0024540, 0111012, 0011042, 0104067, 0056332, 0142244, 0131107,
X	0034074, 0052641, 0163046, 0026303, 0131352, 0077724, 0002462,
X	0110775, 0127346, 0020100, 0137011, 0136163, 0145552, 0144223,
X	0134111, 0075001, 0075221, 0176705, 0000210, 0103625, 0120246,
X	0062614, 0016147, 0054723, 0151200, 0105223, 0021001, 0016224,
X	0073377, 0150716, 0014557, 0112613, 0037466, 0002677, 0052542,
X	0063572, 0105462, 0106436, 0063302, 0053171, 0133243, 0113130,
X	0123222, 0072371, 0041043, 0163614, 0037432, 0147330, 0153403,
X	0130306, 0056455, 0175640, 0120567, 0100601, 0042371, 0154635,
X	0051133, 0074252, 0174525, 0163223, 0052022, 0022564, 0135512,
X	0021760, 0006743, 0006451, 0067445, 0106210, 0025417, 0066566,
X	0062723, 0124224, 0144643, 0164502, 0025342, 0003521, 0024050,
X};
X
int random() {
X	if (I == Pm1) I = 0; 
X	else I++;
X	if (J == Pm1) J = 0; 
X	else J++;
X	return (Table[I]^=Table[J]);
X}
int rx (i, j)
int i, j;
X{
X	int k;
X
X	k = random() % (j-i+1);
X	if (k<0) return(k+j+1);
X	else return(k+i);
X}
END_OF_FILE
if test 3083 -ne `wc -c <'m.c'`; then
    echo shar: \"'m.c'\" unpacked with wrong size!
fi
# end of 'm.c'
fi
if test -f 'mem.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mem.c'\"
else
echo shar: Extracting \"'mem.c'\" \(437 characters\)
sed "s/^X//" >'mem.c' <<'END_OF_FILE'
X
X#include	"dmd.h"
X
X
X
X
X
char *
alloc(n)
X
X	int	n;
X
X{
X	char	*malloc();
X
X
X
X	return(malloc(n));
X}
X
X
X
X
X
Bitmap	*
balloc(r)
X
X	Rectangle	r;
X
X{
X	int		words;
X
X
X
X
X	/* Compute Rectangle Storage Requirements */
X
X
X	words  = (((r.corner.x - r.origin.x) + ((sizeof(Word) * 8) - 1)) / (sizeof(Word) * 8));
X	words *= (r.corner.y - r.origin.y);
X
X
X
X	return((Bitmap *)malloc(words * sizeof(Word)));
X}
X
X
X
X
X
void
bfree(b)
X
X	Bitmap	*b;
X
X{
X	free((char *)b);
X}
X
X
END_OF_FILE
if test 437 -ne `wc -c <'mem.c'`; then
    echo shar: \"'mem.c'\" unpacked with wrong size!
fi
# end of 'mem.c'
fi
if test -f 'moire.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'moire.c'\"
else
echo shar: Extracting \"'moire.c'\" \(1303 characters\)
sed "s/^X//" >'moire.c' <<'END_OF_FILE'
X#include "dmd.h"
X
X#define N 150
X
bump();
X
Point foo[] = {
X	(min(XMAX, YMAX) * 39 / 100), (min(XMAX, YMAX) - 1),
X	(min(XMAX, YMAX) * 13 / 16), (min(XMAX, YMAX) * 13 / 16),
X	(min(XMAX, YMAX) / 2),	(min(XMAX, YMAX) / 2),
X	3,					-2,
X	-4,					3,
X	2,					1,
X};
X
X
main()
X{
X	int i = 0, j;
X	Point from[N], to[N], mid[N];
X	Point dfrom, dto, dmid;
X
X
X	dmdinit();
X	for( j = 0; j < N; j++){
X		from[j].x = 0;
X	 	from[j].y = 0;
X		to[j].x   = 0;
X		to[j].y   = 0;
X		mid[j].x  = 0;
X		mid[j].y  = 0;
X	}
X	from[0] = foo[0];
X	from[1] = foo[0];
X	to[0] = foo[1];
X	to[1] = foo[1];
X	mid[0] = foo[2];
X	mid[1] = foo[2];
X	dfrom = foo[3];
X	dto = foo[4];
X	dmid = foo[5];
X	while(1){
X		dmdrefresh();
X		j = i;
X		if (++i >= N)
X			i = 0;
X		segment(&display, from[i], to[i], F_XOR);
X		segment(&display, to[i], mid[i], F_XOR);
X		segment(&display, mid[i], from[i], F_XOR);
X		from[i] = from[j];
X		bump(&from[i], &dfrom);
X		to[i] = to[j];
X		bump(&to[i], &dto);
X		mid[i] = mid[j];
X		bump(&mid[i], &dmid);
X		segment(&display, from[i], to[i], F_XOR);
X		segment(&display, to[i], mid[i], F_XOR);
X		segment(&display, mid[i], from[i], F_XOR);
X	}
X}
X
bump(p,dp)
Point *p, *dp;
X{
X	if ((p->x += dp->x) > XMAX || p->x < 0) {
X		dp->x = -dp->x;
X		p->x += dp->x << 1;
X	}
X	if ((p->y += dp->y) > YMAX || p->y < 0) {
X		dp->y = -dp->y;
X		p->y += dp->y << 1;
X	}
X}
END_OF_FILE
if test 1303 -ne `wc -c <'moire.c'`; then
    echo shar: \"'moire.c'\" unpacked with wrong size!
fi
# end of 'moire.c'
fi
if test -f 'mouse.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mouse.c'\"
else
echo shar: Extracting \"'mouse.c'\" \(123 characters\)
sed "s/^X//" >'mouse.c' <<'END_OF_FILE'
X#include	"dmd.h"
X
X
X
X
X
void
cursinhibit()
X{
X}
X
X
X
void
cursallow()
X{
X}
X
X
X
X
Texture16	*
cursswitch(t)
X
X	Texture16	*t;
X
X{
X}
X
X
X
END_OF_FILE
if test 123 -ne `wc -c <'mouse.c'`; then
    echo shar: \"'mouse.c'\" unpacked with wrong size!
fi
# end of 'mouse.c'
fi
if test -f 'one.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'one.c'\"
else
echo shar: Extracting \"'one.c'\" \(830 characters\)
sed "s/^X//" >'one.c' <<'END_OF_FILE'
X/*
X * munching squares
X */
X
X
X#include "dmd.h"
X
X
X
X
X#define	DELTA 1
X
X
X
X
X
bit[]={
X	0x80000000, 0x40000000, 0x20000000, 0x10000000,
X	0x08000000, 0x04000000, 0x02000000, 0x01000000,
X	0x00800000, 0x00400000, 0x00200000, 0x00100000,
X	0x00080000, 0x00040000, 0x00020000, 0x00010000,
X	0x00008000, 0x00004000, 0x00002000, 0x00001000,
X	0x00000800, 0x00000400, 0x00000200, 0x00000100,
X	0x00000080, 0x00000040, 0x00000020, 0x00000010,
X	0x00000008, 0x00000004, 0x00000002, 0x00000001
X};
X
X
X
X
X
main()
X{
X	register unsigned x, y;
X	register Word i;
X	register Word d;
X
X
X
X	dmdinit();
X	d=0;
X
X	rectf(&display, Drect, F_CLR);
X
X
X	while(1)
X	{
X		for(x =  0; x < XMAX; x++)
X		{
X			y = (x ^ d) & 1023;
X
X			if((y >= 0) && (y < YMAX))
X				*((display.base) + y * (display.width) + (x >> 5)) ^= bit[x&0x1F];
X		}
X
X		d += DELTA;
X		dmdrefresh();
X	}
X
X	dmdreset();
X}
X
END_OF_FILE
if test 830 -ne `wc -c <'one.c'`; then
    echo shar: \"'one.c'\" unpacked with wrong size!
fi
# end of 'one.c'
fi
if test -f 't.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'t.c'\"
else
echo shar: Extracting \"'t.c'\" \(399 characters\)
sed "s/^X//" >'t.c' <<'END_OF_FILE'
X#include "dmd.h"
X
main()
X{
X	int i;
X
X	dmdinit();
X	circle( &display, Pt(360,150), 50, F_OR);
X	dmdrefresh();
X	disc( &display, Pt(360,150), 25, F_OR);
X	dmdrefresh();
X	rectf( &display, Pt(10,10), Pt(710,290), F_XOR );
X	dmdrefresh();
X	segment( &display, Pt(10,10), Pt(710,290), F_XOR );
X	dmdrefresh();
X	for ( i=0; i < YMAX; i++){
X		point( &display, Pt( i, i ), F_XOR ); 
X		dmdrefresh();
X	}
X	dmdreset();
X}
END_OF_FILE
if test 399 -ne `wc -c <'t.c'`; then
    echo shar: \"'t.c'\" unpacked with wrong size!
fi
# end of 't.c'
fi
if test -f 'textures.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'textures.c'\"
else
echo shar: Extracting \"'textures.c'\" \(3562 characters\)
sed "s/^X//" >'textures.c' <<'END_OF_FILE'
X/* textures.c - This file defines the actual storage associated with the */
X/* textures other wise known to the 630 ROMs.                            */
X/*                                                                       */
X/*                                                                       */
X/*                                                                       */
X/*                                                                       */
X/*                                                                       */
X/*                                                                       */
X
X
X
X#include	"dmd.h"
X
X
X
X
Texture T_black =
X{
X	0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 
X	0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 
X	0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 
X	0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
X	0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 
X	0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 
X	0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 
X	0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
X};
X
X
Texture T_darkgrey =
X{
X	0x77777777, 0xDDDDDDDD, 0x77777777, 0xDDDDDDDD,
X	0x77777777, 0xDDDDDDDD, 0x77777777, 0xDDDDDDDD,
X	0x77777777, 0xDDDDDDDD, 0x77777777, 0xDDDDDDDD,
X	0x77777777, 0xDDDDDDDD, 0x77777777, 0xDDDDDDDD,
X	0x77777777, 0xDDDDDDDD, 0x77777777, 0xDDDDDDDD,
X	0x77777777, 0xDDDDDDDD, 0x77777777, 0xDDDDDDDD,
X	0x77777777, 0xDDDDDDDD, 0x77777777, 0xDDDDDDDD,
X	0x77777777, 0xDDDDDDDD, 0x77777777, 0xDDDDDDDD
X};
X
X
Texture T_grey =
X{
X	0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555,
X	0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555,
X	0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555,
X	0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555,
X	0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555,
X	0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555,
X	0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555,
X	0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555
X};
X
X
Texture T_lightgrey =
X{
X	0x88888888, 0x22222222, 0x88888888, 0x22222222,
X	0x88888888, 0x22222222, 0x88888888, 0x22222222,
X	0x88888888, 0x22222222, 0x88888888, 0x22222222,
X	0x88888888, 0x22222222, 0x88888888, 0x22222222,
X	0x88888888, 0x22222222, 0x88888888, 0x22222222,
X	0x88888888, 0x22222222, 0x88888888, 0x22222222,
X	0x88888888, 0x22222222, 0x88888888, 0x22222222,
X	0x88888888, 0x22222222, 0x88888888, 0x22222222
X};
X
X
Texture T_white =
X{
X	0x00000000, 0x00000000, 0x00000000, 0x00000000, 
X	0x00000000, 0x00000000, 0x00000000, 0x00000000, 
X	0x00000000, 0x00000000, 0x00000000, 0x00000000, 
X	0x00000000, 0x00000000, 0x00000000, 0x00000000,
X	0x00000000, 0x00000000, 0x00000000, 0x00000000, 
X	0x00000000, 0x00000000, 0x00000000, 0x00000000, 
X	0x00000000, 0x00000000, 0x00000000, 0x00000000, 
X	0x00000000, 0x00000000, 0x00000000, 0x00000000
X};
X
X
Texture T_checks =
X{
X	0xCCCCCCCC, 0xCCCCCCCC, 0x33333333, 0x33333333,
X	0xCCCCCCCC, 0xCCCCCCCC, 0x33333333, 0x33333333,
X	0xCCCCCCCC, 0xCCCCCCCC, 0x33333333, 0x33333333,
X	0xCCCCCCCC, 0xCCCCCCCC, 0x33333333, 0x33333333,
X	0xCCCCCCCC, 0xCCCCCCCC, 0x33333333, 0x33333333,
X	0xCCCCCCCC, 0xCCCCCCCC, 0x33333333, 0x33333333,
X	0xCCCCCCCC, 0xCCCCCCCC, 0x33333333, 0x33333333,
X	0xCCCCCCCC, 0xCCCCCCCC, 0x33333333, 0x33333333
X};
X
X
Texture T_stip =
X{
X	0x11111111, 0x44444444, 0x11111111, 0x44444444,
X	0x11111111, 0x44444444, 0x11111111, 0x44444444,
X	0x11111111, 0x44444444, 0x11111111, 0x44444444,
X	0x11111111, 0x44444444, 0x11111111, 0x44444444,
X	0x11111111, 0x44444444, 0x11111111, 0x44444444,
X	0x11111111, 0x44444444, 0x11111111, 0x44444444,
X	0x11111111, 0x44444444, 0x11111111, 0x44444444,
X	0x11111111, 0x44444444, 0x11111111, 0x44444444
X};
X
X
END_OF_FILE
if test 3562 -ne `wc -c <'textures.c'`; then
    echo shar: \"'textures.c'\" unpacked with wrong size!
fi
# end of 'textures.c'
fi
echo shar: End of shell archive.
exit 0



