/***********************************************\
*						*
*	   CDx Audio Access Sample Code		*
*						*
*  Plays between two specified points, both	*
*  given in MSF (Minute/Second/Frame) format	*
*						*
*  This version uses the cdx.device		*
\***********************************************/

#include <exec/types.h>
#include <exec/io.h>
#include <CDx.h>

int   PlayMSF(ULONG,ULONG);
int   String2Int(char *);

extern   struct   IOStdReq       *Req;

main(argc,argv)
int   argc;
char **argv;
{
   ULONG startMSF,endMSF;
   int   min1,sec1,frm1,min2,sec2,frm2,result;

   if (argc!=7) {
      printf("Usage: CDplay <start Min> <Sec> <Frm> <end Min> <Sec> <Frm>\n");
      exit(0);
   }   

   min1 = String2Int(argv[1]);
   sec1 = String2Int(argv[2]);
   frm1 = String2Int(argv[3]);
   min2 = String2Int(argv[4]);
   sec2 = String2Int(argv[5]);
   frm2 = String2Int(argv[6]);

   startMSF = (min1<<16)+(sec1<<8)+(frm1);
   endMSF = (min2<<16)+(sec2<<8)+(frm2);

   if (OpenCDx())
      Cleanup("Couldn't open cdx.device");

   result = PlayMSF(startMSF,endMSF);

   if (result)
      printf("Returned error %ld\n",result);
   else
      printf("Playing...\n");

   Cleanup(0);
}


int PlayMSF(start,end)
ULONG start,end;
{
   Req->io_Command = CD_PLAYSEGMSF;
   Req->io_Offset = start;
   Req->io_Length = end;
   DoIO((struct IORequest *)Req);

   return((int)Req->io_Error);
}
