/****************************************************************/
/*                                                              */
/*             Digitized Voice Programmer's Toolkit             */
/*             ------------------------------------             */
/*                                                              */
/*                 Embedded voice data example                  */
/*                                                              */
/*            Copyright (c) 1991, Farpoint Software             */
/*                                                              */
/****************************************************************/

#include "vpmod.h"

#include <stdlib.h>
#include <stdio.h>

/*-------------------------------------------------------------------*/

extern unsigned char EMB_DATA;       /* voice data array from ASM program */
extern unsigned int EMB_DATA_SIZE;   /* length of the array */

char logo[] = "Embedded Digitized Voice Playback Test Program\r\n"
 "Copyright(c) 1991, Farpoint Software\r\n";

/*-------------------------------------------------------------------*/

void main(void)

{
int delayctr;                    /* internal timing delay from PCALIBRATE */
int calflag;                     /* status word returned from PCALIBRATE */
long retval;

/* display the logo */

puts(logo);

/* calibrate for CPU speed */

puts("Calibrating...");
retval = PCALIBRATE();
calflag = (int)(retval & 0xFFFF);
delayctr = (int)(retval >> 16);
switch ( calflag )
	{
	case 1:
		puts("This computer is too slow to perform adequately with this program.");
		printf("Speed rating = %d    Minimum = 64\n", delayctr);
		exit(1);
	case 2:
		puts("This program will not function properly under Enhanced-mode Microsoft Windows.");
		exit(1);
	case 3:
		puts("Unusual speaker circuit detected; proper operation is uncertain.");
		break;
	}

/* inform the user */

puts("Press any key to stop.");
puts("Starting...");

/* perform the playback */

PLAYVOICE(&EMB_DATA, (long)EMB_DATA_SIZE);

/* finished */

puts("Done.");
}
