/*
*	convertsound.c - Converts raw sound data back and
*	forth from a Macintosh/Apple IIgs format to the Amiga
*   format.
*
*	John Orr - May 90
*/

#include <exec/types.h>
#include <libraries/dosextens.h>

#define BUFSIZE 32767

struct FileHandle *Open(char *, LONG);

UBYTE buffer[BUFSIZE];

void main(int argc, char **argv)
{
	struct FileHandle *fh_in, *fh_out;
	WORD count_in, count_out, x = 0;
		
	if (argc != 3)
	{
		printf("usage:   %s <infile> <outfile>\n",argv[0]);
		exit(30);
	}
	if (fh_in = Open(argv[1], MODE_OLDFILE))
	{
		if (fh_out = Open(argv[2], MODE_NEWFILE))
		{
			do
			{
				count_in = Read(fh_in, buffer, BUFSIZE);
				for (x=0; x < count_in; x++) 
								buffer[x] ^= 0x80;
				count_out = Write(fh_out, buffer, count_in);
			} while (count_in > 0);
			
			Close(fh_out);
		}
		Close(fh_in);
	}
}
