[comp.sources.misc] v06i104: glib part 3 of 15

allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (05/15/89)

Posting-number: Volume 6, Issue 104
Submitted-by: lee@uhccux.uhcc.Hawaii.Edu (Greg Lee )
Archive-name: glib/part03

#! /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 archive 3 (of 15)."
# Contents:  d10rsu.mnu d10ton.c glib.1 k1vis.c mac-mach.c tx81z.mnu
#   unix-mach.c
# Wrapped by lee@uhccux on Sun May  7 00:40:10 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'd10rsu.mnu' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'d10rsu.mnu'\"
else
echo shar: Extracting \"'d10rsu.mnu'\" \(8147 characters\)
sed "s/^X//" >'d10rsu.mnu' <<'END_OF_FILE'
X/* $Id: d10rsu.mnu,v 1.6 89/05/06 17:13:15 lee Exp $
X * GLIB - a Generic LIBrarian and editor for synths
X *
X * D10 Rhythm Setup Librarian
X *
X * Code started 1 FEB 89 --  Michael R. Kesti mrk@gvgspd.GVG.TEK.COM
X * modified by Greg Lee
X * $Log:	d10rsu.mnu,v $
X * Revision 1.6  89/05/06  17:13:15  lee
X * rel. to comp.sources.misc
X * 
X */
X
X#include "glib.h"
X#include "vis.h"
X
X#define D10RSUSIZE 4
X#define RSUBASEADDR 0x090000
X#define RESERVESIZE 20
X
Xchar *visnum(), *visonoff();
X
X
X/* This array contains arbitrary screen labels */
Xstruct labelinfo Ldrsu[] = {
X#MENU
X
X
X
X
X
X
X
X
X                         Tone Select     %
X                         Level           %
X                         Pan             %
X                         Reverb Switch   %
X
X
X
X
X
X
X
X
X
X
X
X Press SPACE BAR to sound note %   at volume %   for duration %  on channel % .
X#END
X-1,-1,NULL
X};
X
Xstruct paraminfo  Pdrsu[] =  {
X/*
XNAME		TYPE		POS	MAX	OFFSET	MASK	SHIFT	ADHOC
X */
X#O tone		rtone		%%	127	0
X#O level	patchlevel	%%	100	1
X#O pan		pan		%%	14	2
X#O reverbsw	onoff		%%	1	3
X#O autopitch	num		%%	127	-60
X#O autovol	num		%%	127	-63
X#O autodur	num		%%	20	-5	*5
X#O autochan	num		%%	16	-1	*5
XNULL,NULL,-1,-1,-1,-1,visnum,0,0,0,0
X};
X
X/*
X * drsunum
X *
X * Convert a voice number (0 to 84) to the string displayed in the
X * librarian (ie. 01 to 85).
X */
X
Xchar *
Xdrsunum(n)
X{
X	static char v[3];
X
X	sprintf(v, "%02d", n + 1);
X	return(v);
X}
X
X/*
X * dnumrsu
X *
X * Convert a display-style voice number (01 to 85) to internal
X * format (0 to 84).
X */
X
Xdnumrsu(n)
Xint n;
X{
X	return(n-1);
X}
X
X/*
X * drsudin
X *
X * Take library bank 'data' and stuff values in the P array, by using
X * the setval function.
X */
X
Xdrsudin(data)
Xchar *data;
X{
X	/* The first RESERVESIZE bytes are reserved (arbitrarily) for the voice name */
X#SETVAL
X}
X
X/*
X * drsudout
X *
X * Take (possibly changed) parameters values out of the P array and
X * put them back into the library bank 'data'.
X */
X
Xdrsudout(data)
Xchar *data;
X{
X#GETVAL
X}
X
X/*
X * drsusedit
X *
X * Send a single voice to the edit buffer of the D10.  This will be whatever
X * voice is currently selected.
X */
X
Xdrsusedit(data)
Xchar *data;
X{
X	int n;
X	int cksum;
X	
X	sendmidi(0xf0);
X	sendmidi(0x41);
X	sendmidi(0x10);
X	sendmidi(0x16);
X	sendmidi(0x12);		/* DT1 - Data set 1 command */
X	sendmidi(0x03);		/* address msb */
X	cksum = 0x03;
X	sendmidi(0x01);
X	cksum += 0x01;
X	sendmidi(0x10);		/* address lsb */
X	cksum += 0x10;
X	for(n = 0; n < D10RSUSIZE; n++) {
X		sendmidi(data[n + RESERVESIZE] & 0x7f);
X		cksum += data[n + RESERVESIZE] & 0x7f;
X	}
X	sendmidi((-cksum) & 0x7f);	/* checksum */
X	sendmidi(EOX);
X}
X
X/*
X * drsunof
X *
X * Return a pointer to the voice name buried in library bank data.
X */
Xchar *
Xdrsunof(data)
Xchar *data;
X{
X
X	static char buf[4];
X	int n;
X
X	for(n = 0; n < D10RSUSIZE; n++)
X		if ( data[n + RESERVESIZE] != 0 ) break;
X	if ( n != D10RSUSIZE ) {
X		strcpy(buf, visrtone(data[RESERVESIZE + 0]));
X	} else
X		strcpy(buf, "   ");
X
X	return(buf);
X}
X
X/*
X * drsusnof
X *
X * Set the voice name buried in data to name.
X */
Xdrsusnof(data,name)
Xchar *data;
Xchar *name;
X{
X}
X
X/* drsusone - send a single voice to the D10 */
Xdrsusone(iv, data)
Xint iv;
Xchar *data;
X{
X	int n;
X	int cksum;
X	long curadd;
X	int addbyte;
X
X	curadd = RSUBASEADDR;
X
X	for(n = 0; n < iv; n++) {
X		curadd += D10RSUSIZE;
X		if((curadd & 0x80) != 0) {
X			curadd &= 0x7fff7f;
X			curadd += 0x100;
X		}
X		if((curadd & 0x8000) != 0) {
X			curadd &= 0x7f7f7f;
X			curadd += 0x10000;
X		}
X	}
X
X	sendmidi(0xf0);
X	sendmidi(0x41);
X	sendmidi(0x10);
X	sendmidi(0x16);
X	sendmidi(0x12);		/* DT1 - Data set 1 command */
X	addbyte = ((curadd >> 16) & 0x7f);	/* address msb */
X	sendmidi(addbyte);
X	cksum = addbyte;
X	addbyte = ((curadd >> 8) & 0x7f);
X	sendmidi(addbyte);
X	cksum += addbyte;
X	addbyte = (curadd & 0x7f);		/* address lsb */
X	sendmidi(addbyte);
X	cksum += addbyte;
X	for(n = 0; n < D10RSUSIZE; n++) {
X		sendmidi(data[n + RESERVESIZE] & 0x7f);
X		cksum += data[n + RESERVESIZE] & 0x7f;
X	}
X	sendmidi((-cksum) & 0x7f);	/* checksum */
X	sendmidi(EOX);
X
X	return(0);
X}
X
X/* drsugbulk - Request and read a bulk dump from the D10 */
Xdrsugbulk(data)
Xchar *data;
X{
X	static	char Buff[BUFSIZ];
X	int n, v, b2, ret = 1;
X	long begin, toolong;
X	long curadd;
X	int addbyte;
X	int cksum;
X	
X	sprintf(Buff,"\n");
X	windstr(Buff);
X
X	curadd = RSUBASEADDR;
X
X	for(v = 0; v < Nvoices; v++) {
X
X		flushmidi();
X
X		if((v % 10) != 0) {
X			sprintf(Buff, ".");
X		} else {
X			sprintf(Buff,"%d", (v / 10));
X		}
X		windstr(Buff);
X
X	/* request the voice */
X		sendmidi(0xf0);
X		sendmidi(0x41);
X		sendmidi(0x10);
X		sendmidi(0x16);
X		sendmidi(0x11);		/* RQ1 - Data request 1 command */
X
X		addbyte = ((curadd >> 16) & 0x7f);	/* address msb */
X		sendmidi(addbyte);
X		cksum = addbyte;
X		addbyte = ((curadd >> 8) & 0x7f);
X		sendmidi(addbyte);
X		cksum += addbyte;
X		addbyte = (curadd & 0x7f);		/* address lsb */
X		sendmidi(addbyte);
X		cksum += addbyte;
X
X		sendmidi(0x00);		/* length msb */
X		cksum += 0x00;
X		sendmidi(0x00);
X		cksum += 0x00;
X		sendmidi(D10RSUSIZE);	/* length lsb */
X		cksum += D10RSUSIZE;
X
X		sendmidi((-cksum) & 0x7f);	/* checksum */
X		sendmidi(EOX);
X	
X	/* set up timeout */
X		begin = milliclock();
X		toolong = begin + (1000 * TIMEOUT);
X	
X	/* read header */
X		for(n = 0; n < 8; ) {
X			if ( STATMIDI ) {
X				b2 = (getmidi() & 0xff);
X				/* burn active sensing and timing clock */
X				if((b2 != 0xfe) && (b2 != 0xf8))
X					n++;
X			} else {
X				if ( milliclock() > toolong ) {
X					Reason = "Timeout waiting for header";
X					goto getout;
X				}
X			}
X		}
X
X	/* read data */
X		for(n = 0; n < D10RSUSIZE; ) {
X			if ( STATMIDI ) {
X				b2 = (getmidi() & 0xff);
X				/* burn active sensing and timing clock */
X				if((b2 != 0xfe) && (b2 != 0xf8)) {
X					VOICEBYTE(data,v,n + RESERVESIZE) = b2;
X					n++;
X				}
X			} else {
X				if ( milliclock() > toolong ) {
X					Reason = "Timeout reading data";
X					goto timeout;
X				}
X			}
X		}
X
X	timeout:
X		if ( n != D10RSUSIZE ) {
X			Reason = "Timeout reading data!";
X			goto getout;
X		}
X
X	/* read checksum */
X		for(n = 0; n < 1; ) {
X			if ( STATMIDI ) {
X				b2 = (getmidi() & 0xff);
X				/* burn active sensing and timing clock */
X				if((b2 != 0xfe) && (b2 != 0xf8))
X					n++;
X			} else {
X				if ( milliclock() > toolong ) {
X					Reason = "Timeout reading checksum";
X					goto getout;
X				}
X			}
X		}
X
X	/* read EOX */
X		for(n = 0; n < 1; ) {
X			if ( STATMIDI ) {
X				b2 = (getmidi() & 0xff);
X				/* burn active sensing and timing clock */
X				if((b2 != 0xfe) && (b2 != 0xf8))
X					if ( b2 != EOX ) {
X						sprintf(Buff,"EOX not received (%X)\n", b2);
X						Reason = Buff;
X						goto getout;
X					}
X					n++;
X			} else {
X				if ( milliclock() > toolong ) {
X					Reason = "Timeout reading EOX";
X					goto getout;
X				}
X			}
X		}
X
X		curadd += D10RSUSIZE;
X		if((curadd & 0x80) != 0) {
X			curadd &= 0x7fff7f;
X			curadd += 0x100;
X		}
X		if((curadd & 0x8000) != 0) {
X			curadd &= 0x7f7f7f;
X			curadd += 0x10000;
X		}
X
X
X	} /* go back for another voice */
X
X	Reason = "";
X	ret = 0;	/* all's well */
X
Xgetout:
X	return(ret);
X}
X
X/* drsusbulk - send a bulk dump to the D10 */
Xdrsusbulk(data)
Xchar *data;
X{
X	static char Buff[BUFSIZ];
X	int v, n;
X	int cksum;
X	long curadd;
X	int addbyte, databyte;
X	int curoff;
X
X	curadd = RSUBASEADDR;
X	curoff = 0;	
X	sprintf(Buff,"\n");
X	windstr(Buff);
X
X	for(v = 0; v <Nvoices ; v++) {
X		if((v % 10) != 0) {
X			sprintf(Buff, ".");
X		} else {
X			sprintf(Buff,"%d", (v / 10));
X		}
X
X		windstr(Buff);
X		sendmidi(0xf0);
X		sendmidi(0x41);
X		sendmidi(0x10);
X		sendmidi(0x16);
X		sendmidi(0x12);		/* DT1 - Data set 1 command */
X		addbyte = ((curadd >> 16) & 0x7f);	/* address msb */
X		sendmidi(addbyte);
X		cksum = addbyte;
X		addbyte = ((curadd >> 8) & 0x7f);
X		sendmidi(addbyte);
X		cksum += addbyte;
X		addbyte = (curadd & 0x7f);		/* address lsb */
X		sendmidi(addbyte);
X		cksum += addbyte;
X
X		for(n = 0; n < D10RSUSIZE; n++) {
X			databyte = data[curoff + n + RESERVESIZE] & 0x7f;
X			sendmidi(databyte);
X			cksum += databyte;
X		}
X		sendmidi((-cksum) & 0x7f);	/* checksum */
X		sendmidi(EOX);
X
X		curadd += D10RSUSIZE;
X		if((curadd & 0x80) != 0) {
X			curadd &= 0x7fff7f;
X			curadd += 0x100;
X		}
X		if((curadd & 0x8000) != 0) {
X			curadd &= 0x7f7f7f;
X			curadd += 0x10000;
X		}
X		curoff += (D10RSUSIZE + RESERVESIZE);
X	}
X	return(0);
X}
X
X/* end */
END_OF_FILE
if test 8147 -ne `wc -c <'d10rsu.mnu'`; then
    echo shar: \"'d10rsu.mnu'\" unpacked with wrong size!
fi
# end of 'd10rsu.mnu'
fi
if test -f 'd10ton.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'d10ton.c'\"
else
echo shar: Extracting \"'d10ton.c'\" \(7249 characters\)
sed "s/^X//" >'d10ton.c' <<'END_OF_FILE'
X/* $Id: d10ton.c,v 1.6 89/05/06 17:13:16 lee Exp $
X * GLIB - a Generic LIBrarian and editor for synths
X *
X * D10 Tone Librarian Common Functions
X *
X * Code started 3 FEB 89 --  Michael R. Kesti mrk@gvgspd.GVG.TEK.COM
X * $Log:	d10ton.c,v $
X * Revision 1.6  89/05/06  17:13:16  lee
X * rel. to comp.sources.misc
X * 
X */
X
X#include "glib.h"
X
X#define D10TONSIZE 246
X#define TONBASEADDR 0x080000
X#define RESERVESIZE 20
X
X/*
X * dtonnum
X *
X * Convert a voice number (0 to 63) to the string displayed in the
X * librarian (ie. 1 to 64).
X */
X
Xchar *
Xdtonnum(n)
X{
X	static char v[3];
X
X	if ( n < 0 || n > 63 )
X		return("??");
X
X	v[0] = (n+1)/10 + '0';
X	v[1] = (n+1)%10 + '0';
X	v[2] = '\0';
X	return(v);
X}
X
X/*
X * dnumton
X *
X * Convert a display-style voice number (1 to 64) to internal
X * format (0 to 63).
X */
X
Xdnumton(n)
Xint n;
X{
X	int ld, rd;
X	
X	/* crack out the digits as decimal codes */
X	ld = (n - 1) / 10; /* left digit */
X	rd = (n - 1) % 10; /* right digit */
X
X	if(ld < 0 || ld > 6 || rd < 0 || rd > 9) {
X		return(-1);
X	} else {
X		return(n - 1);
X	}
X}
X/*
X * dtonsedit
X *
X * Send a single voice to the edit buffer of the D10.  This will be whatever
X * voice is currently selected.
X */
X
Xdtonsedit(data)
Xchar *data;
X{
X	int n;
X	int cksum;
X	
X	sendmidi(0xf0);
X	sendmidi(0x41);
X	sendmidi(0x10);
X	sendmidi(0x16);
X	sendmidi(0x12);		/* DT1 - Data set 1 command */
X	sendmidi(0x04);		/* address msb */
X	cksum = 0x04;
X	sendmidi(0x00);
X	cksum += 0x00;
X	sendmidi(0x00);		/* address lsb */
X	cksum += 0x00;
X	for(n = 0; n < D10TONSIZE; n++) {
X		sendmidi(data[n + RESERVESIZE] & 0x7f);
X		cksum += data[n + RESERVESIZE] & 0x7f;
X	}
X	sendmidi((-cksum) & 0x7f);	/* checksum */
X	sendmidi(EOX);
X}
X
X/*
X * dtonnof
X *
X * Return a pointer to the voice name buried in library bank data.
X */
Xchar *
Xdtonnof(data)
Xchar *data;
X{
X	static char currbuff[11];
X	char *p;
X	int m;
X
X	p = currbuff;
X	for ( m = 0 ; m < 10 ; m++ )
X		*p++ = data[m + RESERVESIZE];
X	*p = '\0';
X	return(currbuff);
X}
X
X/*
X * dtonsnof
X *
X * Set the voice name buried in data to name.
X */
Xdtonsnof(data,name)
Xchar *data;
Xchar *name;
X{
X	char *p;
X	int m;
X
X	for ( p = name, m = 0 ; *p != '\0' && m < 10 ; p++, m++ )
X		data[m + RESERVESIZE] = *p;
X	for ( ; m < 10 ; m++ )
X		data[m + RESERVESIZE] = ' ';
X}
X
X/* dtonsone - send a single voice to the D10 */
Xdtonsone(iv, data)
Xint iv;
Xchar *data;
X{
X	int n;
X	int cksum;
X	long curadd;
X	int addbyte;
X
X	curadd = TONBASEADDR;
X
X	for(n = 0; n < iv; n++) {
X		curadd += 0x200;
X		if((curadd & 0x8000) != 0) {
X			curadd &= 0x7f7f7f;
X			curadd += 0x10000;
X		}
X	}
X
X	sendmidi(0xf0);
X	sendmidi(0x41);
X	sendmidi(0x10);
X	sendmidi(0x16);
X	sendmidi(0x12);		/* DT1 - Data set 1 command */
X	addbyte = ((curadd >> 16) & 0x7f);	/* address msb */
X	sendmidi(addbyte);
X	cksum = addbyte;
X	addbyte = ((curadd >> 8) & 0x7f);
X	sendmidi(addbyte);
X	cksum += addbyte;
X	addbyte = (curadd & 0x7f);		/* address lsb */
X	sendmidi(addbyte);
X	cksum += addbyte;
X	for(n = 0; n < D10TONSIZE; n++) {
X		sendmidi(data[n + RESERVESIZE] & 0x7f);
X		cksum += data[n + RESERVESIZE] & 0x7f;
X	}
X	sendmidi((-cksum) & 0x7f);	/* checksum */
X	sendmidi(EOX);
X
X	return(0);
X}
X
X/* dtongbulk - Request and read a bulk dump from the D10 */
Xdtongbulk(data)
Xchar *data;
X{
X	static	char Buff[BUFSIZ];
X	int c, n, v, b2, ret = 1;
X	long begin, toolong, wait;
X	long curadd;
X	int addbyte;
X	int cksum;
X	
X	sprintf(Buff,"\n");
X	windstr(Buff);
X	
X	curadd = TONBASEADDR;
X
X	for(v = 0; v < Nvoices; v++) {
X
X		flushmidi();
X
X		if(v % 10 != 0) {
X			sprintf(Buff, ".");
X		} else {
X			sprintf(Buff,"%d", (v / 10));
X		}
X		windstr(Buff);
X
X	/* request the voice */
X		sendmidi(0xf0);
X		sendmidi(0x41);
X		sendmidi(0x10);
X		sendmidi(0x16);
X		sendmidi(0x11);		/* RQ1 - Data request 1 command */
X
X		addbyte = ((curadd >> 16) & 0x7f);	/* address msb */
X		sendmidi(addbyte);
X		cksum = addbyte;
X		addbyte = ((curadd >> 8) & 0x7f);
X		sendmidi(addbyte);
X		cksum += addbyte;
X		addbyte = (curadd & 0x7f);		/* address lsb */
X		sendmidi(addbyte);
X		cksum += addbyte;
X
X		sendmidi(0x00);		/* length msb */
X		cksum += 0x00;
X		sendmidi(0x01);		/* should be D10TONSIZE */
X		cksum += 0x01;
X		sendmidi(0x76);		/* length lsb */
X		cksum += 0x76;
X
X		sendmidi((-cksum) & 0x7f);	/* checksum */
X		sendmidi(EOX);
X	
X	/* set up timeout */
X		begin = milliclock();
X		toolong = begin + (1000 * TIMEOUT);
X	
X	/* read header */
X		for(n = 0; n < 8; ) {
X			if ( STATMIDI ) {
X				b2 = (getmidi() & 0xff);
X				/* burn active sensing and timing clock */
X				if((b2 != 0xfe) && (b2 != 0xf8))
X					n++;
X			} else {
X				if ( milliclock() > toolong ) {
X					Reason = "Timeout waiting for header";
X					goto getout;
X				}
X			}
X		}
X
X	/* read data */
X		for(n = 0; n < D10TONSIZE; ) {
X			if ( STATMIDI ) {
X				b2 = (getmidi() & 0xff);
X				/* burn active sensing and timing clock */
X				if((b2 != 0xfe) && (b2 != 0xf8)) {
X					VOICEBYTE(data,v,n + RESERVESIZE) = b2;
X					n++;
X				}
X			} else {
X				if ( milliclock() > toolong ) {
X					Reason = "Timeout reading data";
X					goto timeout;
X				}
X			}
X		}
X
X	timeout:
X		if ( n != D10TONSIZE ) {
X			Reason = "Timeout reading data!";
X			goto getout;
X		}
X
X	/* read checksum */
X		for(n = 0; n < 1; ) {
X			if ( STATMIDI ) {
X				b2 = (getmidi() & 0xff);
X				/* burn active sensing and timing clock */
X				if((b2 != 0xfe) && (b2 != 0xf8))
X					n++;
X			} else {
X				if ( milliclock() > toolong ) {
X					Reason = "Timeout reading checksum";
X					goto getout;
X				}
X			}
X		}
X
X	/* read EOX */
X		for(n = 0; n < 1; ) {
X			if ( STATMIDI ) {
X				b2 = (getmidi() & 0xff);
X				/* burn active sensing and timing clock */
X				if((b2 != 0xfe) && (b2 != 0xf8))
X					if ( b2 != EOX ) {
X						sprintf(Buff,"EOX not received (%X)\n", b2);
X						Reason = Buff;
X						goto getout;
X					}
X					n++;
X			} else {
X				if ( milliclock() > toolong ) {
X					Reason = "Timeout reading EOX";
X					goto getout;
X				}
X			}
X		}
X		curadd += 0x200;		/* D10TONSIZE */
X
X		if((curadd & 0x8000) != 0) {
X			curadd &= 0x7f7f7f;
X			curadd += 0x10000;
X		}
X
X	} /* go back for another voice */
X
X	Reason = "";
X	ret = 0;	/* all's well */
X
Xgetout:
X	return(ret);
X}
X
X/* dtonsbulk - send a bulk dump to the D10 */
Xdtonsbulk(data)
Xchar *data;
X{
X	static char Buff[BUFSIZ];
X	int v, n;
X	int cksum;
X	long curadd;
X	int addbyte, databyte;
X	int curoff;
X
X	curadd = TONBASEADDR;
X	curoff = 0;	
X	sprintf(Buff,"\nA: ");
X	windstr(Buff);
X
X	for(v = 0; v <Nvoices ; v++) {
X		if(v == 64) {
X			sprintf(Buff,"\nB: ");
X			windstr(Buff);
X		}
X		if((((v > 63) ? (v - 64) : v) % 10) != 0) {
X			sprintf(Buff, ".");
X		} else {
X			sprintf(Buff,"%d", (((v > 63) ? (v - 64) : v) / 10));
X		}
X
X		windstr(Buff);
X		sendmidi(0xf0);
X		sendmidi(0x41);
X		sendmidi(0x10);
X		sendmidi(0x16);
X		sendmidi(0x12);		/* DT1 - Data set 1 command */
X		addbyte = ((curadd >> 16) & 0x7f);	/* address msb */
X		sendmidi(addbyte);
X		cksum = addbyte;
X		addbyte = ((curadd >> 8) & 0x7f);
X		sendmidi(addbyte);
X		cksum += addbyte;
X		addbyte = (curadd & 0x7f);		/* address lsb */
X		sendmidi(addbyte);
X		cksum += addbyte;
X
X		for(n = 0; n < D10TONSIZE; n++) {
X			databyte = data[curoff + n + RESERVESIZE] & 0x7f;
X			sendmidi(databyte);
X			cksum += databyte;
X		}
X		sendmidi((-cksum) & 0x7f);	/* checksum */
X		sendmidi(EOX);
X
X		curadd += 0x200;		/* D10TONSIZE */
X		if((curadd & 0x8000) != 0) {
X			curadd &= 0x7f7f7f;
X			curadd += 0x10000;
X		}
X		curoff += (D10TONSIZE + RESERVESIZE);
X	}
X	return(0);
X}
END_OF_FILE
if test 7249 -ne `wc -c <'d10ton.c'`; then
    echo shar: \"'d10ton.c'\" unpacked with wrong size!
fi
# end of 'd10ton.c'
fi
if test -f 'glib.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'glib.1'\"
else
echo shar: Extracting \"'glib.1'\" \(8007 characters\)
sed "s/^X//" >'glib.1' <<'END_OF_FILE'
X.TH GLIB 1 LOCAL
X.SH NAME
Xglib \- patch editor and librarian for synthesizers
X.SH SYNOPSIS
X.B glib
X.SH DESCRIPTION
X.I Glib
X(one syllable) is a text-screen-oriented librarian
Xand patch editor for electronic synthesizers.
XIt is structured in an attempt to make it easy to add support for new
Xsynthesizers.
X.I Glib
Xpresents three types of menu screens:
Xsynthesizer selection, patch librarian, and patch editor.
XHowever, depending on choices made when
X.I glib
Xwas compiled,
Xthere may be no synthesizer selection menu, or it may
Xbe used to select different sub-parts of a single synth, rather
Xthan among different synths.
XFrom the outermost selection menu
Xyou descend to the librarian.
XIf there is no synth selection menu, you see the librarian
Xscreen immediately after invoking
X.IR glib .
X.PP
XThe librarian part of the program manipulates 1 synth bank of voices
X(which can be uploaded to or downloaded from the synth), and 3
Xbanks of library voices (which can be read/written to disk).
XWhen you exit the librarian and select a different synth,
Xthe contents of the library banks and other settings (e.g.
X.I midi
Xchannel) for each are retained.
X.PP
XFrom the librarian screen you can descend to the patch editor
Xscreen to change or create an individual patch for
Xa given synthesizer.
XDetails about using the librarian and the patch editor
Xare given below.
X.PP
XThe
X.I glib
Xdistribution includes support files for various PCs -- IBM,
XAtari ST, Macintosh, Amiga.
XAnd you can run
X.I glib
Xon Unix (it uses curses), although obviously most
XUnix machines don't have midi I/O.  Trying it out on Unix will give you a
Xfeel for what the program does, so you can decide whether or not it's
Xworth the trouble to port it to your
Xmidi-capable PC.
XOr your could edit patch files on a Unix system and download them
Xto a PC.
X.PP
XThe current version of
X.IR glib ,
Xversion 1.6,
Xsupports the synthesizers:
XDX100, TX81, DEP5, DW8000, Roland D-10, Kawaii K1 \& K5, DX7,
Xand Casio CZ1.
X.SH Using glib - Moving around
XBoth the librarian and editor parts of glib make use of arrow
Xkeys,
X.CT B
X.CT N
X.CT P
X.CT F
Xor
X.B h j k l
Xto move the cursor around.
X(The arrow keys may not work on non-Unix versions, though.)
X.CT L
Xredraws the screen.  These
Xkeys are
X.I #defined
Xin
X.IR glib.h ,
Xso you can change them if you want.
XTo quit from any mode, use
X.BR q .
XIn the librarian screen,
X.B ?
Xgives
Xa command summary.
X.B Esc
Xor grave accent key
Xsends an all-notes-off (though the
Xsupport for arrow keys may interfere with this use
Xof
X.B esc
X).
X.PP
X.SH Using glib - The librarian
XThe screen shows the synth bank on the left, and the current (1 of 3)
Xlibrary bank on the right.  A
X.B *
Xidentifies the \*(lqcurrent\*(rq voice, and
Xyou use the arrow keys to move it around.  As soon as you move to a different
Xvoice, it is sent to the \*(lqedit buffer\*(rq of the synth, so it is very
Xeasy to roam around and see what each voice sounds like.  Commands:
X.TP
X.B b \-
XCycle through the (3) library banks, displayed on the
Xright side of the screen.
X.TP
X.B c \-
XSet the 
X.I midi
Xchannel for sending/receiving voices.
X.TP
X.B d \-
XDownload from the (real) synthesizer, replacing the current
Xcontents of the synth bank.
X.TP
X.B D \-
XDownload from a file, replacing the current
Xcontents of the synth bank.
XSame as above, except input comes from file instead of the synth.
X(Implemented only for Unix version.)
X.TP
X.B e \-
XEdit the current voice (see editor description below).
X.TP
X.B f \-
XList the files on the disk.
X.TP
X.B p \-
XPut the yank buffer, replacing the contents of the current voice.
X.TP
X.B q \-
XQuit, going back to \*(lqchoose a synth\*(rq.
X.TP
X.B r \-
XRead a bank of voices from a file, replacing entirely
Xthe current library bank.
X.TP
X.B R \-
XRead a bank of voices from a text file (created with the
X.B W
Xcommand).
X.TP
X.B s \-
XSwap the current voice with the yank buffer.  2 swaps is a no-op.
X.TP
X.B t \-
XTransfer all voices, either from the current library bank to
Xthe synth bank, or vice versa.
X.TP
X.B u \-
XUpload the current contents of the synth bank to the synth.
XYou are given a choice of sending the entire bank or just
Xthe current voice.
X.TP
X.B U \-
XUpload the current contents of the synth bank to a file.
XSame as above, except output goes to file instead of the synth.
X(Implemented only for Unix version.)
X.TP
X.B w \-
XWrite the current library bank to a file.
X.TP
X.B W \-
XWrite the current library bank to an editable text file.
XThis is slow, and is meant for use in some special
Xcircumstance \- for instance if you changed the binary
Xformat of files, you might want to convert your old patches.
X.TP
X.B y \-
XYank the current voice into the yank buffer, shown
Xin the middle of the screen.
X
X.SH Using glib - The editor
XIn the editor part, arrow keys move the cursor among the parameter
Xvalues.  The cursor will only land on parameter values.  Once on
Xa parameter value, the following keys will affect it:
X.TP
X.B K \-
Xincrease value by 1
X.TP
X.B J \-
Xdecrease value by 1
X.TP
X.B I \-
Xincrease value by 4
X.TP
X.B M \-
Xdecrease value by 4
X.TP
X.B < \-
Xdecrease value to its minimum
X.TP
X.B > \-
Xincrease value to its maximum
X.TP
X.B S \-
Xassign same value as last assigned
X.PP
XThese keys are defined in
X.IR glib.h ,
Xand should be changed to
Xsuit your own tastes.  I'm not thrilled with these choices, myself,
Xbut I had to use something, and at least the hand may stay in one place.
X.PP
XTo change the name of a voice, use \*(lqN\*(rq.
X.PP
XThe \*(lqauto-note\*(rq is played whenever you press the space bar.  This is
Xa convenient way of playing a note as soon as you make a change (ie.
Xyou can do everything from the computer keyboard).  You can change the
Xauto-note parameters (pitch, duration, volume, channel) the same way as all
Xthe other parameters.
X.SH Synthesizers
XHere is a list of the sample patch files for each synthesizer in the
X1.6 release of
X.IR glib ,
Xtogether with occasional notes on the current implementation.
X.TP
X.B DX100
XSample patches: fact1.dx1
X.TP
X.B TX81
XSample patches: fact1.t8p fact1.tx8
X.TP
X.B DEP5
XSample patches: fact1.dp5
X.TP
X.B DW8000
XSample patches: fact1.dw8
X.TP
X.B Roland D-10
XSample patches: d10fact.pat d10fact.rsu d10fact.tim d10fact.ton d10fact.tra d10fact.urp
X.TP
X.B Kawaii K1
XSample patches: k1fact.mlt k1fact.sgl
X.sp
X.RS
XVoices are not sent to the K1's edit buffer.
X.br
XFor Kawai K1 multi patches, names of single patches referred to are
Xdisplayed when they can be found in the synth voice bank of the
Xsingle patches module.  The names are updated whenever a new bank
Xof voices is transferred into this bank.
X.RE
X.TP
X.B Kawaii K5
XSample patches: card1.k5m card1.k5s
X.RS
XEditing of voices is not implemented.
X.RE
X.TP
X.B DX7
XSample patches: n001.dx7 rom1.d7s
X.sp
X.RS
XSome of the parameters on the DX7s editing screen
Xare \*(lqmultiplexed\*(rq.
XMove the cursor to the
X\*(lqModulation Wheel\*(rq legend, then
X\*(lqincrement\*(rq and \*(lqdecrement\*(rq this field:
Xthe fields below it will cycle
Xthrough the \*(lqModulation Wheel\*(rq,
X\*(lqAftertouch\*(rq, \*(lqBreath Control\*(rq,
X\*(lqFoot Control\*(rq, and \*(lqMIDI Control\*(rq parameters.
X.RE
X.TP
X.B Casio CZ1
XSample patches: bank1.cz1
X.sp
X.RS
XThe performance parameters given on the lower part of the editing
Xscreen, Glib, Portamento, etc., are just there
X.I pro
X.IR forma .
XIn the current version, setting them doesn't accomplish anything.
X.RE
X.SH AUTHORS
X.HP 
Xoriginal version for dx100, tx81z, dep5: Tim Thompson,
X...twitch!glimmer!tjt
X.HP 
XMacintosh and dw1000 support: Steve Falco.
X.HP 
Xd10 support: Michael Kesti, mrk@gvgspd.GVG.TEK.COM
X.HP 
XAmiga and k5 support: Alan Bland, mab@druwy.ATT.COM
Xor att!druwy!mab
X.HP  
XK1 support and menu mods: Greg Lee, lee@uhccux.uhcc.hawaii.edu
X.HP 
XDX7 support: Scott Snyder, ssnyder@citjulie.bitnet,
Xssnyder@juliet.caltech.edu (addresses valid until mid-June)
X.HP 
XCZ1 support:  Mark R. Rinfret, mrr@amanpt1.Newport.RI.US,
X...!rayssd!galaxia!amanpt1!mrr
X.HP
Xarp file requester, Amiga version:  Dave Weiler
X.PP
XSome of the code was originally written by Steve Frysinger
X(moss!spf), John Helton, and James Gosling.
END_OF_FILE
if test 8007 -ne `wc -c <'glib.1'`; then
    echo shar: \"'glib.1'\" unpacked with wrong size!
fi
# end of 'glib.1'
fi
if test -f 'k1vis.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'k1vis.c'\"
else
echo shar: Extracting \"'k1vis.c'\" \(8018 characters\)
sed "s/^X//" >'k1vis.c' <<'END_OF_FILE'
X/* $Id: k1vis.c,v 1.6 89/05/06 17:13:28 lee Exp $
X * GLIB - a Generic LIBrarian and editor for synths
X *
X * Data Display Routines
X *
X * K1 version adapted from Kesti's D-10 version by Greg Lee
X * $Log:	k1vis.c,v $
X * Revision 1.6  89/05/06  17:13:28  lee
X * rel. to comp.sources.misc
X * 
X */
X
X#include <stdio.h>
X
Xextern int Redraw;	/* if non-0, edit screen is completely redrawn. */
X
Xchar *visnum();
X
Xchar *
Xvispnum(v)
X{
X	return(visnum(v+1));
X}
X
Xchar *
Xvispan(v)
X{
X	switch (v) {
X	case 0: return("R");
X	case 1: return("L+R");
X	case 2: return("L");
X	}
X	return("*");
X}
X
Xchar *
Xvispoly(v)
X{
X	switch (v) {
X	case 0: return("VR");
X	case 1: return("MUTE");
X	case 2: return("1");
X	case 3: return("2");
X	case 4: return("3");
X	case 5: return("4");
X	case 6: return("5");
X	case 7: return("6");
X	case 8: return("7");
X	case 9: return("8");
X	}
X	return("*");
X}
X
Xchar *
Xvisvelosw(v)
X{
X	switch (v) {
X	case 0: return("ALL");
X	case 1: return("SOFT");
X	case 2: return("LOUD");
X	}
X	return("*");
X}
X
Xchar *
Xvismode(v)
X{
X	switch (v) {
X	case 0: return("KYBD");
X	case 1: return("MIDI");
X	case 2: return("MIX");
X	}
X	return("*");
X}
X
Xchar *
Xvistwofour(v)
X{
X	switch (v) {
X	case 0: return("2");
X	case 1: return("4");
X	}
X	return("*");
X}
X
Xchar *
Xvismute(v)
X{
X	switch (v) {
X	case 0: return("ON");
X	case 1: return("MUTE");
X	}
X	return("*");
X}
X
Xchar *
Xvispolym(v)
X{
X	switch (v) {
X	case 0: return("PL1");
X	case 1: return("PL2");
X	case 2: return("SOLO");
X	}
X	return("*");
X}
X
Xchar *
Xvisvbwh(v)
X{
X	switch (v) {
X	case 0: return("DEP");
X	case 1: return("SPD");
X	}
X	return("*");
X}
X
Xchar *
Xviscrv(v)
X{
X	switch (v) {
X	case 0: return("1  /");
X	case 1: return("2 _--~u_");
X	case 2: return("3 _-~u__");
X	case 3: return("4 _/~u_");
X	case 4: return("5 _|~u_");
X	}
X	return("*");
X}
X
X
Xchar *viskeyshift(v)
X{
Xstatic char viskeyshiftbuf[4];
X
X	if((v >= 0) && (v <= 23)) {
X		(void)sprintf(viskeyshiftbuf,"-%d",abs(v - 24));
X		return(viskeyshiftbuf);
X	} else if(v == 24) {
X		(void)sprintf(viskeyshiftbuf,"0");
X		return(viskeyshiftbuf);
X	} else if((v >= 25) && (v <= 48)) {
X		(void)sprintf(viskeyshiftbuf,"+%d", (v - 24));
X		return(viskeyshiftbuf);
X	} else {
X		if (v < 0) return("-*"); else return("+*");
X	}
X}
X
Xchar *visfinetune(v)
X{
Xstatic char visfinetunebuf[4];
X
X	if((v >= 0) && (v <= 49)) {
X		(void)sprintf(visfinetunebuf,"-%d",abs(v - 50));
X		return(visfinetunebuf);
X	} else if(v == 50) {
X		(void)sprintf(visfinetunebuf,"0");
X		return(visfinetunebuf);
X	} else if((v >= 51) && (v <= 100)) {
X		(void)sprintf(visfinetunebuf,"+%d",(v - 50));
X		return(visfinetunebuf);
X	} else {
X		return("*");
X	}
X}
X
Xstatic	char *cpitch_table[] = {
X	"C",
X	"C#",
X	"D",
X	"D#",
X	"E",
X	"F",
X	"F#",
X	"G",
X	"G#",
X	"A",
X	"A#",
X	"B"
X};
X
Xchar *
Xviscpitch(v)
X{
Xstatic	char	viscpitchbuf[4];
X
X	if((v >= 0) && (v <= 127)) {
X		strcpy(viscpitchbuf, cpitch_table[v % 12]);
X		if(strlen(viscpitchbuf) == 1) {
X			(void)sprintf(viscpitchbuf+1, "%d", v/12 - 2);
X		} else {
X			(void)sprintf(viscpitchbuf+2, "%d", v/12 - 2);
X		}
X		return(viscpitchbuf);
X	} else {
X	return("*");
X	}
X}
X
Xchar *
Xvislpitch(v)
X{
Xstatic	char	vislpitchbuf[4];
X
X	if((v >= 0) && (v <= 127)) {
X		strcpy(vislpitchbuf, cpitch_table[v % 12]);
X		if(strlen(vislpitchbuf) == 1) {
X			(void)sprintf(vislpitchbuf+1, "%d", v/12 - 4);
X		} else {
X			(void)sprintf(vislpitchbuf+2, "%d", v/12 - 4);
X		}
X		return(vislpitchbuf);
X	} else {
X	return("*");
X	}
X}
X
Xchar *visonoff();
X
Xint ky_tk1=0, ky_tk2=0, ky_tk3=0, ky_tk4=0;
X
Xchar *visonoffk1(v) { ky_tk1 = v; Redraw = 1; return(visonoff(v)); }
Xchar *visonoffk2(v) { ky_tk2 = v; Redraw = 1; return(visonoff(v)); }
Xchar *visonoffk3(v) { ky_tk3 = v; Redraw = 1; return(visonoff(v)); }
Xchar *visonoffk4(v) { ky_tk4 = v; Redraw = 1; return(visonoff(v)); }
X
Xchar *
Xviscsfnk1(v) {if (ky_tk1) return(viskeyshift(v-60)); else return(vislpitch(v));}
Xchar *
Xviscsfnk2(v) {if (ky_tk2) return(viskeyshift(v-60)); else return(vislpitch(v));}
Xchar *
Xviscsfnk3(v) {if (ky_tk3) return(viskeyshift(v-60)); else return(vislpitch(v));}
Xchar *
Xviscsfnk4(v) {if (ky_tk4) return(viskeyshift(v-60)); else return(vislpitch(v));}
X
Xchar *
Xvisam1(v)
X{
X	switch(v) {
X	case 0: return("OFF");
X	case 1: return("2>1");
X	case 2: return("1>2");
X	}
X	return("*");
X}
X
Xchar *
Xvisam3(v)
X{
X	switch(v) {
X	case 0: return("OFF");
X	case 1: return("4>3");
X	case 2: return("3>4");
X	}
X	return("*");
X}
X
X
Xchar *visifosh(v)
X{
X	switch (v) {
X	case 0: return("TRI");
X	case 1: return("SAW");
X	case 2: return("SQR");
X	case 3: return("RND");
X	}
X	return("*");
X}
X
Xstatic	char *wave_table[] = {
X	"sin 1st",
X	"sin 2nd",
X	"sin 3rd",
X	"sin 4th",
X	"sin 5th",
X	"sin 6th",
X	"sin 7th",
X	"sin 8th",
X	"sin 9th",
X	"sin 10th",
X	"sin 11th",
X	"sin 12th",
X	"sin 16th",
X	"saw 1",
X	"saw 2",
X	"saw 3",
X	"saw 4",
X	"saw 5",
X	"saw 6",
X	"saw 7",
X	"saw 8",
X	"saw 9",
X	"saw 10",
X	"saw 11",
X	"saw 12",
X	"saw 13",
X	"saw 14",
X	"saw 15",
X	"saw 16",
X	"saw 17",
X	"saw 18",
X	"saw 19",
X	"square 1",
X	"square 2",
X	"square 3",
X	"square 4",
X	"square 5",
X	"inverse-saw",
X	"triangle",
X	"random",
X	"french horn",
X	"string",
X	"string",
X	"string pad",
X	"piano 1",
X	"el. grand",
X	"e. piano 1",
X	"e. piano 2",
X	"e. piano 3",
X	"clavi",
X	"vibe",
X	"a. guitar",
X	"f. guitar",
X	"f. guitar",
X	"ac bass",
X	"ac bass",
X	"digi bass 1",
X	"pick bass",
X	"digi bass 2",
X	"round bass",
X	"fretless",
X	"fretless",
X	"flute",
X	"panflute",
X	"harmonica",
X	"glocken",
X	"tine",
X	"harp",
X	"marimba",
X	"e. tom",
X	"log drum",
X	"jass organ 1",
X	"mello pad",
X	"synth solo",
X	"synth 2",
X	"french horn",
X	"french horn",
X	"brass",
X	"brass",
X	"brass",
X	"brass",
X	"trumpet",
X	"trumpet",
X	"violin",
X	"string",
X	"piano 1",
X	"piano 2",
X	"piano 3",
X	"piano 2",
X	"piano 3",
X	"piano 4",
X	"piano 4",
X	"el. grand",
X	"e. piano 1",
X	"e. piano 2",
X	"e. piano 3",
X	"clavi",
X	"harpsichord",
X	"vibe",
X	"a. guitar",
X	"f. guitar",
X	"strat",
X	"strat",
X	"ac bass",
X	"pull bass",
X	"pull bass",
X	"round bass",
X	"slap bass",
X	"slap bass",
X	"slap bass",
X	"fretless",
X	"fretless",
X	"synth bass",
X	"synth bass",
X	"harmonica",
X	"clarinet",
X	"clarinet",
X	"oboe",
X	"oboe",
X	"shakuhachi",
X	"oriental bell",
X	"oriental bell",
X	"bell",
X	"koto",
X	"sitar",
X	"e. tom",
X	"log drum",
X	"log drum",
X	"steel drum",
X	"steel drum",
X	"voice 1",
X	"voice 2",
X	"accordion",
X	"accordion",
X	"jass organ 2",
X	"rock organ 1",
X	"draw bar 1",
X	"draw bar 2",
X	"pipe organ 1",
X	"pipe organ 2",
X	"rock organ 2",
X	"synth solo",
X	"synth solo",
X	"synth 2",
X	"synth 2",
X	"synth 3",
X	"brass",
X	"brass",
X	"orchestra",
X	"piano 1",
X	"piano 4",
X	"e. piano 1",
X	"e. piano 1",
X	"e. piano 2",
X	"e. piano 3",
X	"clavi",
X	"harpsichord",
X	"harpsichord",
X	"vibe",
X	"digi bass 1",
X	"digi bass 2",
X	"digi bass 2",
X	"pick bass",
X	"glocken",
X	"glocken",
X	"tine",
X	"tine",
X	"tine",
X	"tube bell",
X	"tube bell",
X	"tube bell",
X	"xylophone",
X	"xylophone",
X	"harp",
X	"koto",
X	"sitar",
X	"sitar",
X	"kalimba",
X	"kalimba",
X	"kalimba",
X	"log drum",
X	"steel drum",
X	"pipe organ 3",
X	"pipe organ 3",
X	"synth 1",
X	"synth 2",
X	"synth 3",
X	"synth 3",
X	"synth 4",
X	"synth 4",
X	"clavi",
X	"digi bass 1",
X	"digi bass 1",
X	"pick bass",
X	"pick bass",
X	"round bass",
X	"round bass",
X	"harmonica",
X	"harmonica",
X	"harp",
X	"koto",
X	"sitar",
X	"marimba",
X	"synth 1",
X	"base drum",
X	"ac snare",
X	"tight snare",
X	"e. snare",
X	"rim",
X	"ac tom",
X	"h. hat",
X	"crach",
X	"ride",
X	"strat guitar",
X	"fuzz mute",
X	"a. guitar",
X	"f. guitar",
X	"guitar harmo",
X	"pull bass",
X	"bass harmo",
X	"bowed string",
X	"string attack",
X	"string sus",
X	"pizzicato",
X	"piano",
X	"el. grand",
X	"piano noise",
X	"trumpet",
X	"shakuhachi attack",
X	"shakuhachi sus",
X	"pan flute attack",
X	"pan flute sus",
X	"voice",
X	"white noise",
X	"string loop",
X	"shakuhachi loop",
X	"pan flute loop",
X	"voice loop",
X	"white noise loop",
X	"ac snare loop",
X	"f. guitar loop",
X	"pull bass loop",
X	"omn. loop 1",
X	"omn. loop 2",
X	"omn. loop 3",
X	"omn. loop 4",
X	"omn. loop 5",
X	"omn. loop 6",
X	"omn. loop 7",
X	"omn. loop 8",
X	"ac snare rev",
X	"ac tom rev",
X	"f. guitar rev",
X	"h. hat alt",
X	"crash alt",
X	"piano noise alt"
X};
X
Xchar *
Xviswave(v)
X{	static char wavebuf[30];
X
X	if (v >= 0 && v <= 255) {
X		(void)sprintf(wavebuf, "%3d %s", v+1, wave_table[v]);
X		return(wavebuf);
X	}
X	return("*");
X}
X
X/* end */
END_OF_FILE
if test 8018 -ne `wc -c <'k1vis.c'`; then
    echo shar: \"'k1vis.c'\" unpacked with wrong size!
fi
# end of 'k1vis.c'
fi
if test -f 'mac-mach.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mac-mach.c'\"
else
echo shar: Extracting \"'mac-mach.c'\" \(6397 characters\)
sed "s/^X//" >'mac-mach.c' <<'END_OF_FILE'
X/* $Id: mac-mach.c,v 1.6 89/05/06 17:13:32 lee Exp $
X * GLIB - a Generic LIBrarian and editor for synths
X *
X * Machine dependent stuff.
X *
X * macintosh version  -  Steven A. Falco  8/24/87
X * $Log:	mac-mach.c,v $
X * Revision 1.6  89/05/06  17:13:32  lee
X * rel. to comp.sources.misc
X * 
X */
X
X#include "glib.h"
X#include <ctype.h>
X
Xint Rows, Cols;
X
Xhello()
X{
X
X#ifdef MPW
X	/* Substitute our vt driver for the standard console driver.
X	 * Use slot 1 since that is where the standard driver lives.
X	 * This will magically hook in printf, etc.  We could do dups
X	 * and closes which might be more portable, but we'd still need
X	 * the _addDevHandler() call.  This is all subject to change when
X	 * MPW 2.0 rolls around.
X	 *
X	 * NOTE: vt_read is unused in keynote.  Vt_getch and vt_peekch are
X	 * used instead to avoid all system buffering.
X	 */
X	_addDevHandler(1, 'CONS', vt_faccess, vt_close, vt_read, vt_write, vt_ioctl);
X	setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
X	vt_raw(); /* want ^D to work as vanilla character */
X#endif
X
X	midi_init();
X}
X
Xbye()
X{
X	{ int waste_time;
X	while(midi_txst == MIDI_NE) /* wait for all notes to drain */
X		;
X	for(waste_time = 0; waste_time < (1 << 14); waste_time++)
X		; /* hardware fifo has to drain too */
X	midi_reset(); /* now we can shut it down */
X	}
X	windgoto(23,0);
X	windrefresh();
X	exit(0);
X}
X
Xflushconsole()
X{
X	while ( statconsole() )
X		getconsole();
X}
X
Xstatconsole()
X{
X	fflush(stdout);	/* make sure we see prompts */
X	return(vt_peekch());
X}
X
Xgetconsole()
X{
X	fflush(stdout); /* flush any prompts */
X	return(vt_getch());
X}
X
Xgetmidi()
X{
X	int i;
X	
X	while((i = midi_rx()) == -1)
X		; /* wait for something good */
X	
X	return(i);
X}
X
Xsendmidi(c)
X{
X	while(STATTXBF) /* it is easy to overrun on bulk dumps - slow down to uart rate */
X		; /* wait till last character goes to uart */
X		
X	midi_tx(c);
X}
X
Xflushmidi()
X{
X	while ( STATMIDI )
X		getmidi(); /* flush any and all characters */
X}
X
X/* return relative time in 1mS steps */
Xlong milliclock()
X{
X	/* relative, free-running millisecond counter (5mS granularity) */
X	return(midi_time);
X}
X
Xmillisleep(i)
Xint i;
X{
X	long j = milliclock();
X	
X	while(i + j > milliclock())
X		;
X	
X	return;
X}
X
Xint Paw;
XFileParam pblock;
XVolumeParam dblock;
XFInfo *fp;
XStr255 dummystr;
X
X/* Establish a "working directory reference number" for the user-specified
X * directory (path) in character array "pre".  This only affects
X * those calls that explicitly use the reference number - namely, the 
X * PBGetFInfo() call below.  In particular, none of this has any effect
X * whatsoever on fopen() calls.  For those, a full path name must be used.
X */
Xopenphr(pre)
Xchar *pre; /* the path prefix */
X{
X	strcpy(&dummystr, pre);	/* make a copy 'cause we change it */
X	c2pstr(&dummystr);	/* we need a pascal string */
X	dblock.ioCompletion = 0;
X	dblock.ioNamePtr = &dummystr;	/* this is the directory path in pascal */
X	dblock.ioVRefNum = 0;	/* start at the root */
X	
X	if(*((short *) FSFCBLen) > 0) {	/* we are running HFS */
X		((WDPBRec *) &dblock)->ioWDProcID = SIGNATURE;	/* our ID */
X		((WDPBRec *) &dblock)->ioWDDirID = 0;
X		if(PBOpenWD(&dblock, false) != noErr) {
X			printf("No such directory! (%s)\n", pre);
X			dblock.ioVRefNum = 0; /* force back to current directory */
X			pre[0] = 0; /* nuke the path or we'll get in trouble! */
X			/* we could also use a return code to abort the whole
X			 * thing if desired.
X			 */
X		}
X	} else {
X		dblock.ioVolIndex = -1;
X		if(PBGetVInfo(&dblock, false) != noErr) {
X			printf("No such directory! (%s)\n", pre);
X			dblock.ioVRefNum = 0; /* force back to current directory */
X			pre[0] = 0; /* nuke the path or we'll get in trouble! */
X			/* we could also use a return code to abort the whole
X			 * thing if desired.
X			 */	
X		}
X	}
X	
X	Paw = 0;
X	fp = &(pblock.ioFlFndrInfo);
X	pblock.ioCompletion = 0;
X	pblock.ioVRefNum = dblock.ioVRefNum;	/* use new directory number */
X	pblock.ioFVersNum = 0;
X}
X
X/* Return JUST THE FILENAME COMPONENT of the next phrase file we find. */
Xchar *
Xnextphr()
X{
X	static char fname[36];
X	char *p, *strrchr();
X
X    retry:
X	Paw++;
X
X	/* this is a little complicated... */
X	/* we go through the whole directory in sequence */
X	pblock.ioNamePtr = &dummystr;
X	pblock.ioFDirIndex = Paw;
X	if(PBGetFInfo(&pblock, false) != noErr) {
X		/* no such file - we hit the end of the directory */
X		return(NULL);
X	}
X
X	/* OK - we have some file info */
X	p2cstr(pblock.ioNamePtr); /* convert from Pascal to C format */
X	/* NOTE - '' rather than "" is correct! */
X	if(fp->fdType != 'TEXT') {
X		goto retry; /* not one of ours */
X	}
X	/* make it available as a static string */
X	strncpy(fname, pblock.ioNamePtr, 35); /* the file name */
X	fname[35] = 0; /* insist on a null - really can't happen :-) */
X	return(fname);
X}
Xclosephr()
X{
X}
X
X/* getmouse - get currect row and column of mouse */
Xgetmouse(amr,amc)
Xint *amr;
Xint *amc;
X{
X	*amr = -1;
X	*amc = -1;
X}
X
X/* statmouse - return mouse button state (0=nothing pressed,1=left,2=right) */
Xstatmouse()
X{
X	return(-1);
X}
X
Xmouseon()
X{
X}
X
Xmouseoff()
X{
X}
X
X/* Return when either a console key or mouse button is pressed. */
Xmouseorkey()
X{
X	return(getconsole());
X}
X
Xchar *
Xalloc(n)
X	unsigned n;
X{
X	char *p;
X
X	if ( (p = malloc(n)) == NULL ) {
X		printf("*** Whoops *** alloc has failed?!?  No more memory!\n");
X		fflush(stdout);
X		bye();
X	}
X	return(p);
X}
X
Xwindinit()
X{
X	Rows = 24;
X	Cols = 80;
X	
X	return;
X}
X
Xwindgoto(r,c)
Xint r,c;
X{
X	printf("\033[%d;%dH",r+1,c+1);
X}
X
Xwindeeol()
X{
X	printf("\033[K");
X}
X
Xwinderaserow(r)
X{
X	windgoto(r,0);
X	windeeol();
X}
X
Xwindexit(r)
Xint r;
X{
X	bye();
X}
X
Xwindclear()
X{
X	printf("\033[H");
X	printf("\033[J");
X}
X
X/* windgets - get a line of input from the console, handling backspaces */
Xwindgets(s)
Xchar *s;
X{
X	char *origs = s;
X	int c;
X
X	while ( (c=getconsole()) != '\n' && c!='\r' && c!= EOF ) {
X		if ( c == '\b' ) {
X			if ( s > origs ) {
X				windstr("\b \b");
X				s--;
X			}
X		}
X		else {
X			windputc(c);
X			*s++ = c;
X		}
X		windrefresh();
X	}
X	*s = '\0';
X}
X
Xwindstr(s)
Xchar *s;
X{
X	int c;
X
X	while ( (c=(*s++)) != '\0' )
X		windputc(c);
X}
X
Xwindputc(c)
Xint c;
X{
X	putchar(c);
X}
X
Xwindrefresh()
X{
X}
X
Xbeep()
X{
X	putchar('\007');
X}
X
Xwindhigh()
X{
X}
X
Xwindnorm()
X{
X}
X
Xchar *
Xopenls()
X{
X	/* this should be a whole lot fancier to take care of the path
X	 * problems on the mac.  But glib currently has no path
X	 * variables.  The current directory (just ":") will do for now... SAF
X	 */
X	openphr(":");
X	return("");
X}
X
Xchar *
Xnextls()
X{
X	return(nextphr());
X}
X
Xclosels()
X{
X}
END_OF_FILE
if test 6397 -ne `wc -c <'mac-mach.c'`; then
    echo shar: \"'mac-mach.c'\" unpacked with wrong size!
fi
# end of 'mac-mach.c'
fi
if test -f 'tx81z.mnu' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tx81z.mnu'\"
else
echo shar: Extracting \"'tx81z.mnu'\" \(6230 characters\)
sed "s/^X//" >'tx81z.mnu' <<'END_OF_FILE'
X/* $Id: tx81z.mnu,v 1.6 89/05/06 17:13:45 lee Exp $
X * GLIB - a Generic LIBrarian and editor for synths
X *
X * TX81Z routines for Patch parameters
X * Tim Thompson
X * modifications: Greg Lee
X * $Log:	tx81z.mnu,v $
X * Revision 1.6  89/05/06  17:13:45  lee
X * rel. to comp.sources.misc
X * 
X */
X
X#define OVERLAY1
X
X#include "glib.h"
X#include <ctype.h>
X
Xchar *visnum(), *visonoff(), *vism3num(), *viswave(), *vismono();
Xchar *visdx1a(), *vistxwave(), *vistxsft();
Xchar *vistf1(), *vistf2(), *vistf3(), *vistf4();
Xchar *visfx(), *visfx1(), *visfx2(), *visfx3(), *visfx4();
Xextern int Dopmap[];
X
X#define RESERVESIZE 0
X
X/* This array contains arbitrary screen labels */
Xstruct labelinfo Ltx81z[] = {
X#MENU
X
X                                                 Algorithm   %
X                                                 =============
X
X
X O       Dcy Lev Dcy               De  Out     Amp Eg  Key Key EG
X P   Atk  1   1   2  Rls Wav  Freq tun Lvl Vel Mod Bia Rat Scl Sft Fix/Ratio
X -   --- --- --- --- --- --- ----- --- --- --- --- --- --- --- --- ---------
X 1    %   %   %   %   %   %   %     %   %   %  %    %   %   %  %     %
X 2    %   %   %   %   %   %   %     %   %   %  %    %   %   %  %     %
X 3    %   %   %   %   %   %   %     %   %   %  %    %   %   %  %     %
X 4    %   %   %   %   %   %   %     %   %   %  %    %   %   %  %     %
X
X           Reverb Rate  %        Feedback    %         Mono/Poly          %
X           FC Pitch     %        Transpose   %         Amp Mod Depth      %
X           FC Amp       %        LFO Speed   %         Amp Mod Sense      %
X                                 LFO Delay   %         Pitch Mod Depth    %
X-------------------------+       LFO Wave    %         Pitch Mod Sense    %
XN = set name  q = quit   |       LFO Sync    %         Mod Pitch Range    %
XK = incr      J = decr   |       Pitch Bend  %         Mod Amp Range      %
Xspace = play auto-note   |       Port. Time  %         Breath Pitch       %
X                         |       Port. Mode  %         Breath Amp         %
XAuto-Note: Pitch %       |       Port. Foot  %         Breath Pitch Bias  %
XVol %   Dur %   Chan %   |       Sus. Foot   %         Breath EG Bias     %
X#END
X-1,-1,NULL
X};
X
Xstruct paraminfo  Ptx81z[] =  {
X/*
XNAME		TYPE	POS	MAX	OFFSET	MASK	SHIFT	ADHOC
X */
X#O algorithm	dx1a	%%	7	0
X#O op1attack	num	%%	31	0
X#O op1decay1	num	%%	31	0
X#O op1level1	num	%%	15	0
X#O op1decay2	num	%%	31	0
X#O op1release	num	%%	31	0
X#O op1wave	txwave	%%	7	0
X#O op1freq	tf1	%%	878	0
X#O op1detune	m3num	%%	6	0
X#O op1outlevel	num	%%	99	0
X#O op1velocity	num	%%	7	0
X#O op1ampmod	onoff	%%	1	0
X#O op1egbias	num	%%	7	0
X#O op1keyrate	num	%%	3	0
X#O op1keyscale	num	%%	99	0
X#O op1egsft	txsft	%%	3	0
X#O op1fix	fx1	%%	1	0
X#O op2attack	num	%%	31	0
X#O op2decay1	num	%%	31	0
X#O op2level1	num	%%	15	0
X#O op2decay2	num	%%	31	0
X#O op2release	num	%%	31	0
X#O op2wave	txwave	%%	7	0
X#O op2freq	tf2	%%	878	0
X#O op2detune	m3num	%%	6	0
X#O op2outlevel	num	%%	99	0
X#O op2velocity	num	%%	7	0
X#O op2ampmod	onoff	%%	1	0
X#O op2egbias	num	%%	7	0
X#O op2keyrate	num	%%	3	0
X#O op2keyscale	num	%%	99	0
X#O op2egsft	txsft	%%	3	0
X#O op2fix	fx2	%%	1	0
X#O op3attack	num	%%	31	0
X#O op3decay1	num	%%	31	0
X#O op3level1	num	%%	15	0
X#O op3decay2	num	%%	31	0
X#O op3release	num	%%	31	0
X#O op3wave	txwave	%%	7	0
X#O op3freq	tf3	%%	878	0
X#O op3detune	m3num	%%	6	0
X#O op3outlevel	num	%%	99	0
X#O op3velocity	num	%%	7	0
X#O op3ampmod	onoff	%%	1	0
X#O op3egbias	num	%%	7	0
X#O op3keyrate	num	%%	3	0
X#O op3keyscale	num	%%	99	0
X#O op3egsft	txsft	%%	3	0
X#O op3fix	fx3	%%	1	0
X#O op4decay1	num	%%	31	0
X#O op4attack	num	%%	31	0
X#O op4level1	num	%%	15	0
X#O op4decay2	num	%%	31	0
X#O op4release	num	%%	31	0
X#O op4wave	txwave	%%	7	0
X#O op4freq	tf4	%%	878	0
X#O op4detune	m3num	%%	6	0
X#O op4outlevel	num	%%	99	0
X#O op4velocity	num	%%	7	0
X#O op4ampmod	onoff	%%	1	0
X#O op4egbias	num	%%	7	0
X#O op4keyrate	num	%%	3	0
X#O op4keyscale	num	%%	99	0
X#O op4egsft	txsft	%%	3	0
X#O op4fix	fx4	%%	1	0
X#O feedback	num	%%	7	0
X#O playmode	mono	%%	1	0
X#O reverbrate	num	%%	7	0
X#O transpose	num	%%	45	0
X#O amoddepth	num	%%	99	0
X#O fcpitch	num	%%	99	0
X#O lfospeed	num	%%	99	0
X#O amodsens	num	%%	3	0
X#O fcamp	num	%%	99	0
X#O lfodelay	num	%%	99	0
X#O pmoddepth	num	%%	99	0
X#O lfowave	wave	%%	3	0
X#O pmodsens	num	%%	7	0
X#O lfosync	onoff	%%	1	0
X#O modprange	num	%%	99	0
X#O pitchbend	num	%%	12	0
X#O modarange	num	%%	99	0
X#O portatime	num	%%	99	0
X#O breathprange	num	%%	99	0
X#O portmode	num	%%	1	0
X#O breatharange	num	%%	99	0
X#O autopitch	num	%%	127	-60
X#O portfoot	onoff	%%	1	0
X#O breathpbias	num	%%	99	0
X#O autochan	num	%%	16	-1	*5
X#O autodur	num	%%	20	-5	*5
X#O autovol	num	%%	127	-63
X#O susfoot	onoff	%%	1	0
X#O breathegbias	num	%%	99	0
XNULL,NULL,-1,-1,-1,-1,visnum,0,0,0,0
X};
X
X
Xextern int *txindex;
Xextern int txleng;
X
Xchar *
Xvistxwave(v)
X{
X	static char txbuff[3] = "W ";
X	txbuff[1] = v + '1';
X	return(txbuff);
X}
X
Xchar *visfx1(v) { return(visfx(1,v)); }
Xchar *visfx2(v) { return(visfx(2,v)); }
Xchar *visfx3(v) { return(visfx(3,v)); }
Xchar *visfx4(v) { return(visfx(4,v)); }
X
Xchar *visfx(n,v)
X{
X	static int lastfx[] = { 0, -1, -1, -1, -1 };
X	char buff2[8];
X	int fqindex;
X
X	if ( lastfx[n] != -1 && lastfx[n] == v )
X		goto nochange;
X
X	lastfx[n] = v;
X	sprintf(buff2,"op%dfreq",n);
X	fqindex = parmindex(buff2);
X	if ( v == 0 )
X		P[fqindex].p_max = txleng-1;
X	else
X		P[fqindex].p_max = 247;
X	if ( P[fqindex].p_val > P[fqindex].p_max )
X		P[fqindex].p_val = P[fqindex].p_max;
X	showparam(fqindex,0);
Xnochange:
X	if ( v == 0 )
X		return("ratio");
X	else
X		return("fixed");
X}
X
Xchar *
Xvistxsft(v)
X{
X	switch(v){
X	case 0: return("off");
X	case 1: return("48");
X	case 2: return("24");
X	case 3: return("12");
X	}
X	return("??");
X}
X
Xextern int txfreq[];
X
Xchar *
Xvistxq(v)
X{
X	static char fbuff[8];
X	int f, n1, n2;
X
X	txinit();
X	f = txfreq[txindex[v]];
X	n1 = f/100;
X	n2 = f%100;
X	sprintf(fbuff,n2<10?"%d.0%d":"%d.%d",n1,n2);
X	return(fbuff);
X}
X
Xchar *
Xvisfq(v)
X{
X	static char fixbuff[8];
X
X	sprintf(fixbuff,"%-5d",v+8);
X	return(fixbuff);
X}
X
Xchar *
Xvisnfix(n,v)
X{
X	char buff[8];
X	int fx;
X
X	sprintf(buff,"op%dfix",n);
X	fx = getval(buff);
X	if ( fx == 0 )
X		return(vistxq(v));
X	else
X		return(visfq(v));
X}
X
Xchar *vistf1(v) { return(visnfix(1,v)); }
Xchar *vistf2(v) { return(visnfix(2,v)); }
Xchar *vistf3(v) { return(visnfix(3,v)); }
Xchar *vistf4(v) { return(visnfix(4,v)); }
END_OF_FILE
if test 6230 -ne `wc -c <'tx81z.mnu'`; then
    echo shar: \"'tx81z.mnu'\" unpacked with wrong size!
fi
# end of 'tx81z.mnu'
fi
if test -f 'unix-mach.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'unix-mach.c'\"
else
echo shar: Extracting \"'unix-mach.c'\" \(7945 characters\)
sed "s/^X//" >'unix-mach.c' <<'END_OF_FILE'
X# line 1 "unix-mach.c"
X/* $Id: unix-mach.c,v 1.6 89/05/06 17:13:45 lee Exp $
X * GLIB - a Generic LIBrarian and editor for synths
X *
X * Machine dependent stuff.
X *
X * Unix version
X * Tim Thompson
X * modifications: Greg Lee
X * $Log:	unix-mach.c,v $
X * Revision 1.6  89/05/06  17:13:45  lee
X * rel. to comp.sources.misc
X * 
X */
X/* LINTLIBRARY */
X
X#include "glib.h"
X#include <ctype.h>
X
Xint Rows, Cols;
X
X#include <curses.h>
X
X/* Ultrix curses fix -- gl */
X#ifdef ULTRIX
X#undef nl()
X#undef nonl()
X#define nl()	(_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty))
X#define nonl()	(_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty))
X#endif
X
X#ifdef ARROW
X#include <sys/ioctl.h>
X#include <signal.h>
X#include <setjmp.h>
Xjmp_buf wakeup;
X#endif
X
X
X#ifndef ARROW
X
Xinitkbd()
X{}
X
Xresetkbd()
X{}
X
Xnmgetch()
X{
X    return (getchar() & 0x7f);
X}
X
X#else /*ARROW*/
X
X/* Following code for arrow key support lifted from
X * James Gosling's sc spreadsheet calculator -- gl
X */
X#define N_KEY 4
X
Xstruct key_map {
X    char *k_str;
X    char k_val;
X    char k_index;
X}; 
X
Xstruct key_map km[N_KEY];
X
Xchar keyarea[N_KEY*10];
X
Xchar *tgetstr();
Xchar *getenv();
X
X#ifdef TIOCSLTC
Xstruct ltchars old_chars, new_chars;
X#endif
X
Xchar dont_use[] = {
X    ctl('z'), ctl('r'), ctl('l'), ctl('b'), ctl('c'), ctl('f'), ctl('g'), ctl('['),
X    ctl('h'), ctl('m'), ctl('j'), ctl('n'), ctl('p'), ctl('q'), ctl('s'), ctl('t'),
X    ctl('u'), ctl('v'), ctl('e'), ctl('a'), 0,
X};
X
Xinitkbd()
X{
X    register struct key_map *kp;
X    register i,j;
X    char *ks;
X    char *p = keyarea;
X    static char buf[1024]; /* Why do I have to do this again? */
X
X    if (tgetent(buf, getenv("TERM")) <= 0)
X	return;
X
X    km[0].k_str = tgetstr("kl", &p); km[0].k_val = ctl('b');
X    km[1].k_str = tgetstr("kr", &p); km[1].k_val = ctl('f');
X    km[2].k_str = tgetstr("ku", &p); km[2].k_val = ctl('p');
X    km[3].k_str = tgetstr("kd", &p); km[3].k_val = ctl('n');
X    ks = tgetstr("ks",&p);
X    if (ks) 
X	printf("%s",ks);
X
X    /* Unmap arrow keys which conflict with our ctl keys   */
X    /* Ignore unset, longer than length 1, and 1-1 mapped keys */
X
X    for (i = 0; i < N_KEY; i++) {
X	kp = &km[i];
X	if (kp->k_str && (kp->k_str[1] == 0) && (kp->k_str[0] != kp->k_val))
X	    for (j = 0; dont_use[j] != 0; j++)
X	        if (kp->k_str[0] == dont_use[j]) {
X		     kp->k_str = (char *)0;
X		     break;
X		}
X    }
X
X
X#ifdef TIOCSLTC
X    ioctl(fileno(stdin), TIOCGLTC, (char *)&old_chars);
X    new_chars = old_chars;
X    if (old_chars.t_lnextc == ctl('v'))
X	new_chars.t_lnextc = -1;
X    if (old_chars.t_rprntc == ctl('r'))
X	new_chars.t_rprntc = -1;
X    ioctl(fileno(stdin), TIOCSLTC, (char *)&new_chars);
X#endif
X}
X
Xresetkbd()
X{
X#ifdef TIOCSLTC
X    ioctl(fileno(stdin), TIOCSLTC, (char *)&old_chars);
X#endif
X}
X
Xnmgetch() 
X{
X    register int c;
X    register struct key_map *kp;
X    register struct key_map *biggest;
X    register int i;
X    int almost;
X    int maybe;
X
X    static char dumpbuf[10];
X    static char *dumpindex;
X
X    int timeout();
X
X    if (dumpindex && *dumpindex)
X	    return (*dumpindex++);
X
X    c = getchar() & 0x7f;
X    biggest = 0;
X    almost = 0;
X
X    for (kp = &km[0]; kp < &km[N_KEY]; kp++) {
X	if (!kp->k_str)
X	    continue;
X	if (c == kp->k_str[kp->k_index]) {
X	    almost = 1;
X	    kp->k_index++;
X	    if (kp->k_str[kp->k_index] == 0) {
X		c = kp->k_val;
X       	        for (kp = &km[0]; kp < &km[N_KEY]; kp++)
X	            kp->k_index = 0;
X	        return(c);
X	    }
X	}
X	if (!biggest && kp->k_index)
X	    biggest = kp;
X        else if (kp->k_index && biggest->k_index < kp->k_index)
X	    biggest = kp;
X    }
X
X    if (almost) { 
X
X        (void)signal(SIGALRM, timeout);
X        alarm(1);
X
X	if (setjmp(wakeup) == 0) { 
X	    maybe = nmgetch();
X	    alarm(0);
X	    return(maybe);
X	}
X
X    }
X    
X    if (biggest) {
X	for (i = 0; i<biggest->k_index; i++) 
X	    dumpbuf[i] = biggest->k_str[i];
X	dumpbuf[i++] = c;
X	dumpbuf[i] = 0;
X	dumpindex = &dumpbuf[1];
X       	for (kp = &km[0]; kp < &km[N_KEY]; kp++)
X	    kp->k_index = 0;
X	return (dumpbuf[0]);
X    }
X
X    return(c);
X}
X
Xtimeout()
X{
X    longjmp(wakeup, -1);
X}
X
X#endif /* ARROW */
X
Xhello()
X{
X}
X
Xbye()
X{
X	windgoto(22,0);
X	windrefresh();
X	resetkbd();
X	windexit(0);
X}
X
X/* getmouse - get currect row and column of mouse */
Xgetmouse(amr,amc)
Xint *amr;
Xint *amc;
X{
X#ifdef USEMOUSE
X	/* no such */
X#else
X	*amr = -1;
X	*amc = -1;
X#endif
X}
X
X/* statmouse - return mouse button state (0=nothing pressed,1=left,2=right) */
Xstatmouse()
X{
X#ifdef USEMOUSE
X	/* no such */
X#else
X	return(-1);
X#endif
X}
X
X/* Return when either a console key or mouse button is pressed. */
Xmouseorkey()
X{
X#ifdef USEMOUSE
X	/* no such */
X#else
X	return(nmgetch());
X/*
X	return(getconsole());
X*/
X#endif
X}
X
Xflushconsole()
X{
X}
X
Xstatconsole()
X{
X	return(1);
X}
X
Xgetconsole()
X{
X	return(getchar());
X}
X
Xint siopenflag = 0;
XFILE *sifile;
Xint soopenflag = 0;
XFILE *sofile;
Xextern char Syinfname[100];
Xextern char Syofname[100];
X
Xgetmidi()
X{	int c;
X
X	if (!synthinfileflag) return(-1);
X
X	if (!siopenflag) {
X#ifdef BSD
X		OPENBINFILE(sifile,Syinfname,"r");
X#else
X		OPENBINFILE(sifile,Syinfname,"rb");
X#endif
X		if (sifile != NULL)
X			siopenflag = 1;
X	}
X	if (siopenflag) {
X		c = getc(sifile);
X		if (c == EOF) {
X			(void)fclose(sifile);
X			siopenflag = 0;
X		} else
X			return(c);
X	}
X	return(-1);
X}
X
Xstatmidi()
X{
X	if (!synthinfileflag) return(0);
X	return(1);
X}
X
X/*ARGSUSED*/
Xsendmidi(c)
Xint c;
X{
X	if (!synthoutfileflag) return;
X
X	if (!soopenflag) {
X#ifdef BSD
X		OPENBINFILE(sofile,Syofname,"w");
X#else
X		OPENBINFILE(sofile,Syofname,"wb");
X#endif
X		if (sofile != NULL)
X			soopenflag = 1;
X	}
X	if (soopenflag)
X		putc(c, sofile);
X}
X
Xflushmidi()
X{
X	if (!synthinfileflag && !synthoutfileflag)
X	while ( STATMIDI )
X		(void)getmidi();
X
X	if (!synthoutfileflag) return;
X
X/* To close files used in redirection of midi output, set
X * synthoutfileflag and call me.
X */
X	if (siopenflag) {
X		(void)fclose(sifile);
X		siopenflag = 0;
X	}
X	if (soopenflag) {
X		(void)fclose(sofile);
X		soopenflag = 0;
X	}
X}
X
Xlong milliclock()
X{
X	static long hzcount = 0;
X
X	return(hzcount++);
X}
X
Xmillisleep(n)
X{
X	sleep((unsigned)((n+500)/1000));
X}
X
Xchar *
Xalloc(n)
X{
X	char *p;
X
X	if ( (p=malloc((unsigned)n)) == (char *)NULL ) {
X		printf("*** Whoops *** alloc has failed?!?  No more memory!\n");
X		(void)fflush(stdout);
X		bye();
X	}
X	return(p);
X}
X
Xwindinit()
X{
X	char *getenv();
X
X	initscr();
X	Cols = 80;
X	Rows = 24;
X	noecho();
X	nonl();
X#ifdef BSD
X	crmode();
X#else
X	cbreak();
X#endif
X	initkbd();
X}
X
Xwindgoto(r,c)
Xint r,c;
X{
X	move(r,c);
X}
X
Xwindeeol()
X{
X	clrtoeol();
X}
X
Xwinderaserow(r)
X{
X	windgoto(r,0);
X	windeeol();
X}
X
Xwindexit(r)
Xint r;
X{
X#ifdef BSD
X	nocrmode();
X#else
X	nocbreak();
X#endif
X	nl();
X	echo();
X	endwin();
X	(void)exit(r);
X}
X
Xwindclear()
X{
X	clear();
X}
X
X/* windgets - get a line of input from the console, handling backspaces */
Xwindgets(s)
Xchar *s;
X{
X	char *origs = s;
X	int c;
X
X	while ( (c=getconsole()) != '\n' && c!='\r' && c!= EOF ) {
X		if ( c == '\b' ) {
X			if ( s > origs ) {
X				windstr("\b \b");
X				s--;
X			}
X		}
X		else {
X			windputc(c);
X			*s++ = c;
X		}
X		windrefresh();
X	}
X	*s = '\0';
X}
X
Xwindstr(s)
Xchar *s;
X{
X	int c;
X
X	while ( (c=(*s++)) != '\0' )
X		windputc(c);
X}
X
Xwindputc(c)
Xint c;
X{
X	addch(c);
X}
X
Xwindrefresh()
X{
X	refresh();
X}
X
Xbeep()
X{
X	putchar('\007');
X}
X
Xwindhigh()
X{
X	standout();
X}
X
Xwindnorm()
X{
X	standend();
X}
X
X/****************
X * openls(), nextls(), and closels() are used to scan the current directory.
X ***************/
X
XFILE *Phrlist = NULL;
X
Xopenls()
X{
X	FILE *popen();
X	
X	Phrlist = popen("ls","r");
X}
Xchar *
Xnextls()
X{
X	static char fname[65];
X
X	if ( fscanf(Phrlist,"%s",fname) != 1 )
X		return(NULL);
X	return(fname);
X}
Xclosels()
X{
X	pclose(Phrlist);
X}
X
X#ifdef FAKECBREAK
X#include <sys/termio.h>
Xstruct termio Initterm;
Xstatic int First = 1;
Xcbreak()
X{
X	struct termio termbuff;
X
X	if ( First  ) {
X		First = 0;
X		ioctl(0,TCGETA,&Initterm);
X	}
X	termbuff = Initterm;
X	termbuff.c_lflag &= (~ICANON);
X	termbuff.c_cc[4] = 1;
X	termbuff.c_cc[5] = 1;
X	ioctl(0,TCSETA,&termbuff);
X}
Xnocbreak()
X{
X	ioctl(0,TCSETA,&Initterm);
X}
X#endif
END_OF_FILE
if test 7945 -ne `wc -c <'unix-mach.c'`; then
    echo shar: \"'unix-mach.c'\" unpacked with wrong size!
fi
# end of 'unix-mach.c'
fi
echo shar: End of archive 3 \(of 15\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 15 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0