#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "module.h"

/**********************************************************************
Undocumented code... horrors.
**********************************************************************/

main(int argc, char ** argv)
{
	int c;
	char * filename;

	while ((c = getopt(argc, argv, "vf:")) != -1)
	{
		switch(c)
		{
			case 'v':
				printf("jol v0.1 (c) 1995 Nathan Hand\n");
				exit(1);
				break;
			case 'f':
				if (sscanf(optarg, "%d", &samplerate) != 1)
				{
					printf("error: bad frequency value\n");
					exit(1);
				}
				break;
			default:
				exit(1);
				break;
		}
	}

	if (optind != argc-1)
	{
		printf("usage: jol [-v] [-f freq] filename.mod\n");
		exit(1);
	}

	SoundInit();
	moduleinfo mymodule;
	ModLoad(&mymodule, argv[optind]);
	ModPlay(&mymodule);
	SoundDest();
	exit(0);
}
