home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 428.lha / RandSam / src / QuitRand.c < prev    next >
C/C++ Source or Header  |  1990-10-06  |  2KB  |  73 lines

  1. #include <exec/types.h>
  2. #include <exec/ports.h>
  3. #include "randcmd.h"
  4.  
  5. struct MsgPort        *CreatePort();
  6. struct MsgPort        *cmdport,*replyport;
  7. struct MsgPort        *FindPort();
  8. struct commandrequest cmdreq,*messback;
  9.  
  10. struct SampleData *sam;
  11. struct Values     *var;
  12. long no;
  13. char RandSamVers[50] = {"Randsam v1.1 , by Steven Lagerweij 030490"};
  14.  
  15. VOID main(argc,argv)
  16. int argc;
  17. char *argv[];
  18. {
  19.     printf("Cmd program for randsam by Steven Lagerweij\n");
  20.  
  21.     if(argc < 2)
  22.      {
  23.        printf("Usage : %s keyword\n",argv[0]);
  24.        printf("Keywords : \n");
  25.        printf("           quit\tQuit signal\n");
  26.        printf("           play\tPlay all samples\n");
  27.        printf("           conf\tDisplay the current config\n");
  28.        exit(0);
  29.      }
  30.     if((replyport=CreatePort("replyport randsam",0))==NULL)
  31.      { printf("Couldn't create port\n"); exit(0); };
  32.  
  33.     cmdreq.cmd_Msg.mn_Node.ln_Type   = NT_MESSAGE;
  34.     cmdreq.cmd_Msg.mn_ReplyPort      = replyport;
  35.     cmdreq.cmd_Msg.mn_Length         = sizeof(struct commandrequest);
  36.     if(stcpma("play",argv[1])) cmdreq.Command = COM_PLAY;
  37.     else if(stcpma("conf",argv[1])) cmdreq.Command = COM_CONF;
  38.     else cmdreq.Command = COM_QUIT;
  39.     cmdport = FindPort(CMDPORTNAME);
  40.     if(!cmdport)
  41.       {
  42.         printf("Couldn't contact program!\n");
  43.         DeletePort(replyport);
  44.         exit(0);
  45.       }
  46.  
  47.     PutMsg(cmdport,&cmdreq);
  48.     WaitPort(replyport);
  49.     messback = (struct commandrequest *)GetMsg(replyport);
  50.     DeletePort(replyport);
  51.  
  52.     if(cmdreq.Command == COM_CONF)
  53.       {
  54.         sam = (struct SampleData *)cmdreq.data1;
  55.         var = (struct Values     *)cmdreq.data2;
  56.         no  = var->vl_cur;
  57.         printf("\fRandsam settings\n");
  58.         printf(  "----------------\n");
  59.         printf("Next sound will be in +/- %ld seconds\n",var->vl_waittime);
  60.         printf("Min delay  %-4ld, Max delay  %-4ld\n",var->vl_mindelay,var->vl_maxdelay);
  61.         printf("Min cycles %-4ld, Max cycles %-4ld\n",var->vl_mincyc,var->vl_maxcyc);
  62.         printf("Maximum diff %d\n",var->vl_maxdiff);
  63.         printf("Number of samples available is %ld\n",var->vl_num);
  64.         printf("Using random seed : %ld\n",var->vl_randseed);
  65.         printf("Last played sample %ld\n",no);
  66.         printf("Name : %s, period %d Cycles %d Volume %d\n",
  67.                 sam->Name,sam->Period,sam->Cycles,sam->Vol);
  68.  
  69.       }
  70.  
  71. exit(0);
  72. }
  73.