/*-------------------------------------------------------*/
/* Originally part of SOUNDHAX v1 by John M. Trindle     */
/*                 FREEWARE 12/19/91                     */
/*-------------------------------------------------------*/

#include <stdio.h>


#define  CMS_AVAILABLE  1
#define  FM_AVAILABLE   2
#define  CV_AVAILABLE   4

#define  OFF            0
#define  ON             1

#define  FALSE          0
#define  TRUE           1

extern _ct_io_addx;
extern _ct_int_num;
extern _ct_music_status;
extern _ct_voice_status;

static int StatusWord;

char *VoiceDriver;

/* Add'l functions:
   _ctvd_pause() suspends sample play
   _ctvd_continue() resumes the sample where it left off
*/

main(int argc, char *argv[])
{
   int DriverFeatures,VersionCode,RetVal,i;

   char buffer[255];
   FILE *fp;


   _ct_io_addx = 0x220;    /* I/O Base */

   DriverFeatures = _ct_card_here();

   if (DriverFeatures & CMS_AVAILABLE)
      printf("C/MS Music Available\n");

   if (DriverFeatures & FM_AVAILABLE)
      printf("FM Music Available\n");

   if (DriverFeatures & CV_AVAILABLE)
      printf("Creative Voice Available\n");
   else
   {
      printf("Sound Blaster or Compatible NOT detected\n");
      exit(1);
   }

   VersionCode = _sbc_version();

   printf("SBV Version = %d.%d\n",VersionCode >> 8, VersionCode & 0xff);

   _sbc_scan_int();

   printf("Interrupt = %d\n",_ct_int_num);

   fp = fopen(argv[1],"rb");

   if (fp == NULL)
      printf("File %s not found\n",argv[1]);
   else
   {

      RetVal = _ctvd_init(6);
      printf("RetVal = %d\n",RetVal);

      _ctvd_speaker(ON);

      _ctvd_output(fp->_file);

      while(_ct_voice_status)
         if (kbhit())
         {
            if(!getch())
               getch();
            break;
         }

      _ctvd_speaker(OFF);

      _ctvd_terminate();
   }
}
