[comp.sources.amiga] v91i077: FZIFF - Convert 16-bit Casio FZ-1 samples to Amiga IFF 8SVX, Part01/01

amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator) (03/29/91)

Submitted-by: karl@sugar.hackercorp.com (Karl Lehenbauer)
Posting-number: Volume 91, Issue 077
Archive-name: audio/fziff/part01

As promised, here is FZIFF, the companion program to CASIO.
After you use CASIO to download a 16-bit sample from your
Casio FZ-1, you can use FZIFF to convert it to an IFF 8SVX
sample file.  There are some gotchas, see the README file
for details.

#!/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 1 (of 1)."
# Contents:  8svx.h Makefile README cleanup.c fziff.c fziff.uu iff.c
#   iff.h libraries.c prototypes.h
# Wrapped by tadguy@ab20 on Thu Mar 28 11:20:36 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f '8svx.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'8svx.h'\"
else
echo shar: Extracting \"'8svx.h'\" \(2262 characters\)
sed "s/^X//" >'8svx.h' <<'END_OF_FILE'
X/* 8svx.h  include file for IFF 8-bit sampled voices
X *		   essentially cribbed from EA IFF documentation
X *		   KEL 21-Feb-87
X */
X
X#ifndef I8SVX_H
X
X#define I8SVX_H
X
X#define ID_8SVX MakeID('8', 'S', 'V', 'X')
X#define ID_VHDR MakeID('V', 'H', 'D', 'R')
X
Xtypedef LONG Fixed;		/* A fixed-point value, 16 bits to the left of the
X						 * point and 16 to the right.  A Fixed is a number
X						 * of 216ths, i.e. 65536ths. */
X
X#define Unity 0x1000L		/* Unity = Fixed 1.0 = maximum volume */
X
X/* sCompression: Choice of compression algorithm applied to the samples */
X
X#define sCmpNone	0		/* not compressed */
X#define sCmpFibDelta 1		/* Fibonacci-delta encoding */
X/* can be more kinds in the future */
X
Xtypedef struct {
X	ULONG oneShotHiSamples,	/* # samples in the high octave 1-shot part */
X	repeatHiSamples,		/* # samples in the high octave repeat part */
X	samplesPerHiCycle;		/* # samples/cycle in high octave, else 0 */
X	UWORD samplesPerSec;	/* data sampling rate */
X	UBYTE ctOctave,			/* # octaves of waveforms */
X	sCompression;			/* data compression technique used */
X	Fixed volume;			/* playback volume from 0 to Unity (full
X							 * volume).  Map this value into the output
X							 * hardware's dynamic range. */
X	} Voice8Header;
X
X#define ID_NAME MakeID('N', 'A', 'M', 'E')
X	/* NAME chunk contains a CHAR [], the voice's name. */
X
X#define ID_Copyright MakeID('(','c',')',' ')
X	/* "(c) " chunk contains a CHAR [], the FORM's copyright notice. */
X
X#ifndef ID_AUTH
X#define ID_AUTH MakeID('A','U','T','H')
X#endif
X	/* AUTH chunk contains a CHAR [], the author's name. */
X
X#define ID_ANNO MakeID('A', 'N', 'N', 'O')
X	/* ANNO chunk contains a CHAR [], author's text annotations. */
X
X#define ID_ATAK MakeID('A', 'T', 'A', 'K')
X#define ID_RLSE MakeID('R', 'L', 'S', 'E')
X
Xtypedef struct {
X	UWORD duration;		/* segment duration in milliseconds, > 0 */
X	Fixed dest;			/* destination volume factor */
X	} EGPoint;
X
X/* ATAK and RLSE chunks contain an EGPoint[] piecewise-linear envelope. */
X/* The envelope defines a function of time returning Fixed values.  It's
X * used to scale the nominal volume specified in the Voice8Header.	*/
X
X#define ID_BODY MakeID('B', 'O', 'D', 'Y')
X
X/* BODY chunk contains a BYTE[], array of audio data samples. */
X
X#endif
X
X/* end of 8svx.h */
END_OF_FILE
if test 2262 -ne `wc -c <'8svx.h'`; then
    echo shar: \"'8svx.h'\" unpacked with wrong size!
fi
# end of '8svx.h'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(197 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#CFLAGS=	-n +p -DDEBUG +Iincludes.pre
X#CFLAGS=	+p +Iincludes.pre
XCFLAGS=	-so
X
XOFILES= fziff.o iff.o libraries.o
X
X.c.o:
X	cc $(CFLAGS) $*.c
X
Xall: fziff
X
Xfziff:	$(OFILES)
X	ln -g $(OFILES) -lhack -lc
X
END_OF_FILE
if test 197 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(3216 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X
XThis program includes source and executable for the program FZIFF,
Xa program for converting 16-bit samples downloaded from a Casio
XFZ-1 synthesizer to the IFF 8SVX sample format on the Amiga.
X
XTo use it, use the CASIO program to download a sample to a file,
Xas in "casio train_whistle.fz1", then use FZIFF to convert it,
Xas in "fziff train_whistle.fz1 train_whistle.iff"
X
XAlthough the program does convert the file into a IFF
X8SVX file, something is wrong with the result, so you have to
Xuse Audiomaster or the equivalent to clean it up.  Sorry about this,
Xbut I haven't had time to look at it and am not too likely to the
Xway things have been going.  Source is included if you want to give
Xit a try.
X
XWhen you use audiomaster to edit the sample, there will be some garbage
Xright at the beginning (possibly a noncompliant IFF header?), use the
Xcut-and-paste function to trim it out.  Also, set the playback frequency
Xto 18000.
X
XIf you sampled on the FZ-1 at 36000 samples per second, you can use
XAudiomaster at this point to downsample to 18K SPS.  (Note that the
XAmiga can't play a sample at faster than around 25K SPS.)  I have
Xfound that sampling at 36000 and downsampling with Audiomaster seems
Xto result in the best sound, regrettable because it doubles the transit
Xtime from the FZ-1, disk space used on the Amiga during the transfer
Xprocess, etc, etc.
X
XSource code is included, so the advanced experimenter may want to find
Xthe bug.  If you do so, please send me an update.  Also, this program
Xconverts 16-bit samples to 8-bit ones.  
X
XThe extremely advanced guru may want to write a sound player that can 
Xdiddle the 6-bit channel volume in a manner coordinated with the
Xplaying of the sounds to derive some sort of near-14-bit companded
Xaudio.  I would go about it by subdividing the sample into parts the
Xsize of which are selected such that between each part you can get out
Xto the volume register, extract an RMS volume from the subpart by doing
Xthe appropriate calculation, determine a 6-bit volume for the volume
Xregister and extract full-scale 8-bit samples for the sample portion.
XI was planning to do this but now I pretty much for sure will never get
Xaround to it.  It's a big, hard job, but if you do it, you'll learn a
Xton about audio and about the Amiga.  I might be able to help a little,
Xbut not much.  (If you do it, please send me a copy, or at least drop
Xa note)
X
XThese programs are more like works-in-progress than finished, quality
Xthings, but they are usable and, as I'm unlikely to ever finish them 
Xbeyond what they are now, I thought I'd make them available for those
Xwho could use them.  I would very much have liked to have gotten them 
Xfrom somewhere rather than writing them myself, even in their present
Xcondition, so I'll save the next guy some time.  Perhaps you'll do
Xthe same with some cool utility you've written, it's nice to at least
Xknow that someone is using it, rather than another great program sitting
Xthere rotting on your hard disk, plus its nice to see your name in the
XFred Fish lists and the Amazing Computing resource guides.
X
XShare And Enjoy,
X
XKarl Lehenbauer
X3918 Panorama
XMissouri City, TX, USA 77459
X
XInternet: karl@hackercorp.com
XUsenet: uunet!sugar!karl
END_OF_FILE
if test 3216 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'cleanup.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'cleanup.c'\"
else
echo shar: Extracting \"'cleanup.c'\" \(2258 characters\)
sed "s/^X//" >'cleanup.c' <<'END_OF_FILE'
X/* cleanup - Hackercorp Hackercore, standard cleanup management routines, v1.1
X  
X   This code is released to the public domain, 4/25/88, by Peter da Silva
X   and Karl Lehenbauer
X  
X   Usage:
X  
X  	add_cleanup(cleanup_routine);
X  	void cleanup_routine();
X
X  		Add a routine to the cleanup list.  When cleanup  is called, routines 
X		passed as arguments to add_cleanup will be executed  in the reverse 
X		order in which they were received.  See the source to  the IFF CAT 
X		archiver, iffar, for an example of how to use this.
X
X	void cleanup()
X
X		Execute all the routines passed as arguments to add_cleanup
X  	
X	panic(s)
X	char *s;
X
X		Abort the program by printing a panic message including string "s"
X		on stderr, flushing stdout and stderr, calling cleanup and exiting.
X
X	_abort()
X		By defining _abort to call panic, entering control-C while using
X		stdio will cause the program to abort, executing your cleanup
X		routines.  Also note that Manx sdb calls _abort when the user
X		requests an exit, so your cleanup routines will be executed then
X		as well.
X*/
X
X#include <exec/memory.h>
X#include <stdio.h>
X
Xstruct _clean 
X{
X	int (*function)();
X	struct _clean *next;
X} *cleanlist = NULL;
X
X/* add_cleanup
X * given a function, add it to a list of functions to call when cleanup
X * is executed
X */
Xadd_cleanup(function)
Xint (*function)();
X{
X	struct _clean *ptr;
X
X	ptr = AllocMem(sizeof(struct _clean), MEMF_PUBLIC);
X	if(!ptr)
X		return 0;
X	ptr->function = function;
X	ptr->next = cleanlist;
X	cleanlist = ptr;
X}
X
X/* cleanup
X * call all the functions that were passed as arguments to add_cleanup
X * this run
X */
Xcleanup()
X{
X	struct _clean *ptr;
X	int (*f)();
X
X	while(cleanlist) 
X	{
X		/* locate the next cleanup function and get the function pointer */
X		ptr = cleanlist;
X		cleanlist = cleanlist->next;
X		f = ptr->function;
X
X		/* cleanup must clean up after itself */
X		FreeMem(ptr, sizeof(struct _clean));
X
X		/* execute the function */
X		(*f)();
X	}
X}
X
X/* panic - abort with an error message */
X
Xshort panic_in_progress = 0;
X
Xpanic(s)
Xchar *s;
X{
X	fflush(stdout);
X	fprintf(stderr,"panic: %s\n",s);
X	fflush(stderr);
X	if (!panic_in_progress)
X	{
X		cleanup();
X		exit(10);
X	}
X	fprintf(stderr,"double panic!\n");
X	exit(11);
X}
X
X_abort()
X{
X	panic("^C or other C library abort");
X}
END_OF_FILE
if test 2258 -ne `wc -c <'cleanup.c'`; then
    echo shar: \"'cleanup.c'\" unpacked with wrong size!
fi
# end of 'cleanup.c'
fi
if test -f 'fziff.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fziff.c'\"
else
echo shar: Extracting \"'fziff.c'\" \(2223 characters\)
sed "s/^X//" >'fziff.c' <<'END_OF_FILE'
X/* hilo - print highest and lowest sample values */
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <functions.h>
X#include <hackercorp/iff.h>
X#include <hackercorp/8svx.h>
X
X#include "prototypes.h"
X
XVoice8Header v8head;
X
Xshort buffer[512];
X
Xchar *program_name = "fziff";
X
Xlong nsamples;
XUBYTE *bodyp;
X
Xvoid freebody(void)
X{
X	if (bodyp)
X		FreeMem(bodyp,nsamples);
X}
X
Xmain(int argc, char *argv[])
X{
X	int fzfd, svxfd;
X	UBYTE *outp;
X	int i;
X
X	if (argc != 3)
X	{
X		fprintf(stderr,"usage: fziff fz1dumpfilename new8svxfilename\n");
X		exit(1);
X	}
X
X	init_libs();
X
X	/* open the sample file read from the casio fz-1 by karl's fz-1 read stuff */
X	if ((fzfd = open(argv[1],O_RDONLY)) == -1)
X	{
X		perror(argv[1]);
X		exit(2);
X	}
X
X	/* eventually get the real number from the voice parameters */
X	nsamples = (lseek(fzfd,0L,2) - 1024) / 2;
X
X	/* initialize the VHDR chunk */
X	v8head.oneShotHiSamples = nsamples;
X	v8head.repeatHiSamples = 0;
X	v8head.samplesPerHiCycle = 0;
X	v8head.samplesPerSec = 17987;	/* get it out of the header eventually */
X	v8head.ctOctave = 0;
X	v8head.sCompression = 0;
X	v8head.volume = 65535;
X
X	/* skip the voice parameters for now - this assumes, as the casio dumper
X	 * does, only one voice and no banks */
X	if (lseek(fzfd, 1024L,0) == -1)
X	{
X		perror(argv[1]);
X		exit(3);
X	}
X
X	/* get that IFF file open, we have to cleanup from now on */
X	if ((svxfd = CreateIFF(argv[2],ID_FORM,ID_8SVX)) == -1)
X		panic("unable to create IFF 8SVX file\n");
X
X	if (!WriteChunk(svxfd,ID_VHDR,&v8head,sizeof(v8head)))
X		panic("unable to write VHDR chunk");
X
X	if (!WriteTextChunk(svxfd,ID_NAME,argv[2]))
X		panic("unable to write NAME chunk");
X
X/*
X	if (!WriteTextChunk(svxfd,ID_Copyright,"Copyright (C) 1989 Hackercorp.  All Rights Reserved."))
X		panic("unable to write Copyright chunk");
X
X	if (!WriteTextChunk(svxfd,ID_ANNO,"sampled on a 16-bit synth and converted for the Amiga by Karl Lehenbauer/Hackercorp"));
X
X*/
X
X	if ((bodyp = AllocMem(nsamples,0)) == NULL)
X		panic("unable to alloc sample memory");
X
X	add_cleanup(freebody);
X	outp = bodyp;
X	while (read(fzfd,&buffer[0],1024) == 1024)
X	{
X		for (i = 0; i < 512; i++)
X			*outp++ = buffer[i] & 0xff;
X	}
X	WriteChunk(svxfd,ID_BODY,bodyp,nsamples);
X
X	Rewrite_IFF_header(svxfd);
X	exit(0);
X}
X
END_OF_FILE
if test 2223 -ne `wc -c <'fziff.c'`; then
    echo shar: \"'fziff.c'\" unpacked with wrong size!
fi
# end of 'fziff.c'
fi
if test -f 'fziff.uu' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fziff.uu'\"
else
echo shar: Extracting \"'fziff.uu'\" \(13566 characters\)
sed "s/^X//" >'fziff.uu' <<'END_OF_FILE'
Xbegin 644 fziff
XM```#\P`````````#``````````(```AY```!YP````$```/I```(>4[Z"Y)*!
XMK(,F9Q0O#B`L@RHB;(,F+&R#+DZN_RXL7TYU2.<X,"1O`!P,KP````,`&&<88
XM2'H!ODAL@9!.N@BP2'@``4ZZ'VI/[P`,3KH%=$*G+RH`!$ZZ#VHF``R`____9
XM_U!/9A(O*@`$3KH(J$AX``).NA\\4$](>``"0J<O`TZZ'8`$@```!`!R`DZZU
XM&QHI0(,J*6R#*H,R0JR#-D*L@SHY?$9#@SY"+(-`0BR#02E\``#__X-"0J=(/
XM>`0`+P-.NAU`#(#_____3^\`&&82+RH`!$ZZ"#Y(>``#3KH>TE!/2'DX4U98H
XM2'E&3U)-+RH`"$ZZ`[XH``R`_____T_O``QF"DAZ`1Q.N@4X6$](>``42&R#?
XM,DAY5DA$4B\$3KH"8$J`3^\`$&8*2'H!%DZZ!1)83R\J``A(>4Y!344O!$ZZI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QLATY.KO]\3-]``"E`AT9P_V"*(`-@ADCG(`!(YP`">
XM(CP``!``<``L;(,N3J[^SDS?0``D``@```QG$DJLAUIF""`"3-\`!$YU3KKF2
XM=G``8/)*K(>"9Q0@;(>"(&@`!$Z0(&R'@BE0AX)@YDJLAW9G!B!LAW9.D"\OS
XM``1.N@`&6$].=4CG,``F+P`,2JR'4F<R=`!@"B\"3KH!<%A/4H(P;(,<L<)N#
XM[DCG``(P+(,<P?P`!B)LAU(L;(,N3J[_+DS?0`!*K(=^9P8@;(=^3I!*K(,B3
XM9Q1(YP`"(BR#(BQLATY.KO^F3-]``$JLAX9G""!LAX8@K(>*2JR'CF<42.<`U
XM`B)LAXXL;(,N3J[^8DS?0`!*K(>29Q1(YP`"(FR'DBQL@RY.KOYB3-]``$JL=
XMAY9G%$CG``(B;(>6+&R#+DZN_F),WT``2JR'FF<42.<``B)LAYHL;(,N3J[^Y
XM8DS?0`!(YP`&+'@`!`@N``0!*6<02_H`"$ZN_^)@!D*G\U].<RI?2JR'7F8\7
XM2JR';F<T2.<``B`LAVHB;(=N+&R#+DZN_RY,WT``2.<``B`LAV;E@%B`(FR'0
XM8BQL@RY.KO\N3-]``&`D2.<``BQL@RY.KO]\3-]``$CG``(B;(=>+&R#+DZN(
XM_H9,WT``2.<``B)LATXL;(,N3J[^8DS?0``@`RYLATI.=4S?``Q.=4CG("`DQ
XM+P`,<@8@`DZZ`$HD0-7LAU)*@FT,,&R#'+'";P1*DF80*7P````#AT9P_TS?L
XM!`1.=3`J``0"0(``9A)(YP`"(A(L;(=.3J[_W$S?0`!"DG``8-A(YW``-`'$+
XMP"8!2$/&P$A#0D/4@TA`P,%(0$)`T(),WP`.3G4``````^P````!`````0``Q
XM#`P````````#\@```^H```#)```![```````````````````"@H```H+```*C
XM)0``"C<```I+```*70``"FD```IZ```*C@``"J(```JP```*P@``"LP```KDG
XM```*]0``"PP```L>```+-```"T@````3`"`@("`@("`@(#`P,#`P("`@("`@T
XM("`@("`@("`@("`@D$!`0$!`0$!`0$!`0$!`0`P,#`P,#`P,#`Q`0$!`0$!`(
XM"0D)"0D)`0$!`0$!`0$!`0$!`0$!`0$!`0%`0$!`0$`*"@H*"@H"`@("`@("4
XM`@("`@("`@("`@("`D!`0$`@````````````````````````````````````Z
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````@````````$`````````````````#
XM``0``0`````!```````````````````$``(``````0``````````````````-
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM````%``````````````#[````!0``````````````!`````4````&````!P`O
XM```@````)````"@````L````,````#0````X````/````$````!$````2```\
XB`$P```!0````5````%@````````#\@```^L````!```#\D``A
X``
Xend
Xsize 9664
END_OF_FILE
if test 13566 -ne `wc -c <'fziff.uu'`; then
    echo shar: \"'fziff.uu'\" unpacked with wrong size!
fi
# end of 'fziff.uu'
fi
if test -f 'iff.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'iff.c'\"
else
echo shar: Extracting \"'iff.c'\" \(3195 characters\)
sed "s/^X//" >'iff.c' <<'END_OF_FILE'
X/* iffar - IFF CAT archiver, IFF support functions
X
X   By Karl Lehenbauer, 4/25/88.
X   This code is released to the public domain.
X   See the README file for more information.
X
X*/
X
X/* culled general purpose IFF file cracking routines for Karl's 
X * IFF Stuff by Karl Lehenbauer, based originally on public domain IFF 
X * code from Electronic Arts, 2/24/88
X */
X
X#include <exec/types.h>
X#include <exec/memory.h>
X#include <stdio.h>
X#include <fcntl.h>
X#include <ctype.h>
X#include <hackercorp/assert.h>
X
X#include <hackercorp/iff.h>
X
X#include "prototypes.h"
X
Xextern long lseek();
X
Xextern ULONG nextchunk();
X
X/* print a chunkID to stderr */
Xvoid PutID(ID id)
X{
X    fprintf(stderr,"%c%c%c%c",
X	   (char)((id>>24L) & 0x7f),
X	   (char)((id>>16L) & 0x7f),
X	   (char)((id>>8)   & 0x7f),
X	   (char)(id        & 0x7f) );
X}
X
X/* write a chunk header, that's the 4-byte chunk ID and a 4-byte 
X * chunk length 
X */
Xint WriteChunkHeader(int fd,ULONG chunktype,long length)
X{
X	ChunkHeader chunkheader;
X
X	chunkheader.ckID = chunktype;
X	chunkheader.ckSize = length;
X
X	if (write(fd,&chunkheader,sizeof(chunkheader)) == -1)
X	{
X		perror("WriteChunkHeader");
X		return(0);
X	}
X	return(1);
X}
X
X/* write a chunk that has a four character subtype, like FORM, CAT or LIST
X*/
Xint WriteSuperChunkHeader(int fd, ULONG chunktype, ULONG subtype, long length)
X{
X	if (!WriteChunkHeader(fd,chunktype,length+sizeof(subtype)))
X		return(0);
X	return(write(fd,&subtype,sizeof(subtype)) != -1);
X}
X
X/* write a chunk header and body, that's the 8-byte header and the data
X * to match the specified length
X */
Xint WriteChunk(int fd, ULONG chunktype, void *data, long length)
X{
X	static char zero = '\0';
X
X	if (!WriteChunkHeader(fd,chunktype,length))
X		return(0);
X
X	/* if there's a body, write it out */
X	if (length != 0)
X		if (write(fd,data,length) == -1)
X		{
X			perror("WriteChunk");
X			return(0);
X		}
X
X	/* if the length is odd, write out an additional zero byte */
X	if (length & 1)
X		if (write(fd,&zero,1) == -1)
X		{
X			perror("WriteChunk");
X			return(0);
X		}
X	return(1);
X}
X
Xint WriteTextChunk(int fd,ULONG chunktype,char *text)
X{
X	int len = strlen(text);
X	return(WriteChunk(fd,chunktype,text,len));
X}
X
X/* rewrite_IFF_header - write (filesize - sizeof(ChunkHeader)) into
X * IFF file's header, assumes file is open for write
X */
Xint Rewrite_IFF_header(int fd)
X{
X	long filesize;
X
X	/* get filesize by seeking to EOF */
X	if ((filesize = lseek(fd,0,2)) == -1)
X	{
X		perror("rewrite_IFF_header");
X		return(0);
X	}
X
X	/* go back to the beginning of the file */
X	if (lseek(fd,0,0) == -1)
X	{
X		perror("rewrite_IFF_header");
X		return(0);
X	}
X
X	if (!WriteChunkHeader(fd,ID_CAT,(filesize - sizeof(ChunkHeader))))
X	{
X		perror("rewrite_IFF_header: WriteChunkHeader");
X		return(0);
X	}
X
X	return(1);
X}
X
X/* create an IFF file by opening it for write and writing the type and subtype
X */
Xint CreateIFF(char *filename, ULONG type, ULONG subtype)
X{
X	int fd;
X
X	if ((fd = creat(filename, 0664)) == -1)
X	{
X		perror(filename);
X		return(-1);
X	}
X
X	if (!WriteSuperChunkHeader(fd,type,subtype,0L))
X	{
X		fprintf(stderr,"create_archive: couldn't write CAT chunkheader of new archive\n");
X		return(-1);
X	}
X
X	/* success, return the archive fd */
X	return(fd);
X}
X
X/* end of iff.c */
END_OF_FILE
if test 3195 -ne `wc -c <'iff.c'`; then
    echo shar: \"'iff.c'\" unpacked with wrong size!
fi
# end of 'iff.c'
fi
if test -f 'iff.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'iff.h'\"
else
echo shar: Extracting \"'iff.h'\" \(2280 characters\)
sed "s/^X//" >'iff.h' <<'END_OF_FILE'
X#ifndef IFF_H
X#define IFF_H
X/*----------------------------------------------------------------------*/
X/* IFF.H  defs for IFF-85 Interchange Format Files.	        	1/22/86 */
X/*																		*/
X/* By Jerry Morrison and Steve Shaw, Electronic Arts.					*/
X/* This software is in the public domain.								*/
X/*----------------------------------------------------------------------*/
X
X/* mods by Karl Lehenbauer, 1987, 1988 */
X
X#ifndef LIBRARIES_DOS_H
X#include "libraries/dos.h"
X#endif
X
Xtypedef LONG ID;
X
X/* Four-character IDentifier builder.*/
X#define MakeID(a,b,c,d)  ( (LONG)(a)<<24L | (LONG)(b)<<16L | (c)<<8 | (d) )
X
X/* Standard group IDs.  A chunk with one of these IDs contains a
X   SubTypeID followed by zero or more chunks.*/
X#define ID_FORM MakeID('F','O','R','M')
X#define ID_PROP MakeID('P','R','O','P')
X#define ID_LIST MakeID('L','I','S','T')
X#define ID_CAT  MakeID('C','A','T',' ')
X#define ID_FILLER MakeID(' ',' ',' ',' ')
X#define ID_FNAM MakeID('F','N','A','M')
X#define ID_MISC MakeID('M','I','S','C')
X
X/* The IDs "FOR1".."FOR9", "LIS1".."LIS9", & "CAT1".."CAT9" are reserved
X * for future standardization.*/
X
X/* ---------- Chunk ----------------------------------------------------*/
X
X/* All chunks start with a type ID and a count of the data bytes that 
X   follow--the chunk's "logicl size" or "data size". If that number is odd,
X   a 0 pad byte is written, too. */
X
Xtypedef struct {
X    ID	  ckID;
X    LONG  ckSize;
X    } ChunkHeader;
X
Xtypedef struct {
X    ID	  ckID;
X    LONG  ckSize;
X    UBYTE ckData[ 1 /*REALLY: ckSize*/ ];
X    } Chunk;
X
X/* define the maximum reasonable chunk size - the real max is around 2^32,
X * but we need some reasonability limit to check for */
X#define MAXCHUNKSIZE 900000
X
X/* The Grouping chunks (LIST, FORM, PROP, & CAT) contain concatenations of
X * chunks after a subtype ID that identifies the content chunks.
X * "FORM type XXXX", "LIST of FORM type XXXX", "PROPerties associated
X * with FORM type XXXX", or "conCATenation of XXXX".*/
Xtypedef struct {
X    ID	  ckID;
X    LONG  ckSize;	/* this ckSize includes "grpSubID".*/
X    ID    grpSubID;
X    } GroupHeader;
X
Xtypedef struct {
X    ID	  ckID;
X    LONG  ckSize;
X    ID    grpSubID;
X    UBYTE grpData[ 1 /*REALLY: ckSize-sizeof(grpSubID)*/ ];
X    } GroupChunk;
X
X
X#endif IFF_H
X
END_OF_FILE
if test 2280 -ne `wc -c <'iff.h'`; then
    echo shar: \"'iff.h'\" unpacked with wrong size!
fi
# end of 'iff.h'
fi
if test -f 'libraries.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'libraries.c'\"
else
echo shar: Extracting \"'libraries.c'\" \(430 characters\)
sed "s/^X//" >'libraries.c' <<'END_OF_FILE'
X#include <functions.h>
X#include <exec/types.h>
X#include <exec/devices.h>
X#include <intuition/intuition.h>
X#include <ctype.h>
X
Xstruct IntuitionBase *IntuitionBase = NULL;
X
Xvoid trash_libs(void)
X{
X	if (IntuitionBase) 
X		CloseLibrary(IntuitionBase);
X}
X
Xvoid init_libs(void)
X{
X	add_cleanup(trash_libs);
X
X	if (!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0L)))
X		panic("Can't open intuition.library");
X
X}
X
END_OF_FILE
if test 430 -ne `wc -c <'libraries.c'`; then
    echo shar: \"'libraries.c'\" unpacked with wrong size!
fi
# end of 'libraries.c'
fi
if test -f 'prototypes.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'prototypes.h'\"
else
echo shar: Extracting \"'prototypes.h'\" \(573 characters\)
sed "s/^X//" >'prototypes.h' <<'END_OF_FILE'
X/* iff.c */
Xvoid PutID(long id);
Xint WriteChunkHeader(int fd, unsigned long chunktype, long length);
Xint WriteSuperChunkHeader(int fd, unsigned long chunktype, unsigned long subtype, long length);
Xint WriteChunk(int fd, unsigned long chunktype, void *data, long length);
Xint WriteTextChunk(int fd, unsigned long chunktype, char *text);
Xint Rewrite_IFF_header(int fd);
Xint CreateIFF(char *filename, unsigned long type, unsigned long subtype);
X/* fziff.c */
Xvoid freebody(void);
Xint main(int argc, char **argv);
X/* libraries.c */
Xvoid trash_libs(void);
Xvoid init_libs(void);
END_OF_FILE
if test 573 -ne `wc -c <'prototypes.h'`; then
    echo shar: \"'prototypes.h'\" unpacked with wrong size!
fi
# end of 'prototypes.h'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
Mail comments to the moderator at <amiga-request@uunet.uu.net>.
Post requests for sources, and general discussion to comp.sys.amiga.misc.