home *** CD-ROM | disk | FTP | other *** search
/ Chestnut's Multimedia Mania / MM_MANIA.ISO / midi / cmtcmu / adagio.c next >
Encoding:
C/C++ Source or Header  |  1990-06-28  |  4.1 KB  |  130 lines

  1. /*   Adagio compiler -- scan command line, call phase1, phase2 */
  2.  
  3. /*****************************************************************************
  4. *        Change Log
  5. *  Date        | Change
  6. *-----------+-----------------------------------------------------------------
  7. * 12-Mar-86 | Created
  8. * 28-May-86 | Added calls to cmdline.c for command line parsing
  9. *****************************************************************************/
  10.  
  11. #include "cext.h"
  12. #include "stdio.h"
  13. #include "adagio.h"
  14. #include "phase1.h"
  15. #include "phase2.h"
  16. #include "atxt.h"
  17. #include "userio.h"
  18. #include "cmdline.h"
  19.  
  20. char score_na[name_length];  /* this will be available to phase1 and 2 */
  21.  
  22. /****************************************************************************
  23. * Variables set by command line switches
  24. ****************************************************************************/
  25. extern int IsAT;
  26. boolean no_mpu = false;        /* true if simulated */
  27.  
  28. /****************************************************************************
  29. * Data for command line parsing
  30. ****************************************************************************/
  31. #define nswitches 15
  32. private char *switches[nswitches] = 
  33.     { "-debug", "-d", "-help", "-miditrace", "-m", "-trace", "-t", "-at",
  34.       "-metronome", "-met", "-simulated", "-s", "-xt", "-print", "-block" };
  35.  
  36. #define noptions 3
  37. private char *options[noptions] = { "-c", "-control", "-tune" };
  38.  
  39. #define nmsw 2
  40. private char *msw[nmsw] = { "-met", "-metronome" };
  41.  
  42. #define nssw 2
  43. private char *ssw[nssw] = { "-simulated", "-s" };
  44.  
  45. /****************************************************************************
  46. *    Routines local to this module
  47. ****************************************************************************/
  48. private void cmdline_help();
  49.  
  50. /****************************************************************************
  51. *                 cmdline_help
  52. * Effect: 
  53. *    Prints out command line help
  54. ****************************************************************************/
  55.  
  56. private void cmdline_help()
  57. {
  58.     fprintf(stderr,"adagio [options] filename [options]\n");
  59.     fprintf(stderr,"     Options are below.  Those with * are for wizrds:\n");
  60.     fprintf(stderr,"*       -at             PC/AT (secondary interrupt channel)\n");
  61.     fprintf(stderr,"       -block         disable MIDI thru\n");
  62.     fprintf(stderr,"       -debug (-d)         enable verbose debug mode\n");
  63.     fprintf(stderr,"       -help         this message\n");
  64.     fprintf(stderr,"       -metronome (-met) turn on MPU-401 metronome\n");
  65.     fprintf(stderr,"       -miditrace (-m)   turn on MIDI command trace\n");
  66.     fprintf(stderr,"       -print         print note data\n");
  67.     fprintf(stderr,"       -tune file         use tuning from file\n");
  68.     fprintf(stderr,"       -simulated (-s)   run with simulated MPU-401\n");
  69.     fprintf(stderr,"       -trace (-t)         trace music\n");
  70.     fprintf(stderr,"*       -xt             PC/XT (no secondary interrupt channel)\n");
  71. }
  72.  
  73. /****************************************************************************
  74. *                     main
  75. * Inputs:
  76. *    int argc: Count of arguments
  77. *    char * argv[]: Vector of argument pointers
  78. * Effect: 
  79. *    Runs adagio
  80. ****************************************************************************/
  81.  
  82. void main(argc,argv)
  83.    int argc;
  84.    char * argv[];
  85. {
  86.     FILE *fp = NULL;
  87.     char *s;    /* temp pointer to input file name */
  88.  
  89.     cl_init(switches, nswitches, options, noptions, argv, argc);
  90.  
  91.     score_na[0] = 0;
  92.  
  93.     if (cl_switch("-help")) {
  94.     cmdline_help(); 
  95.     return;
  96.     }
  97.  
  98.     IsAT = (atxt() == ISAT);
  99.     if (cl_switch("-at")) {
  100.     if (!IsAT) { /* lie! */
  101.         fprintf(stderr,"-at but not running on PC/AT!\n");
  102.         return;
  103.     }
  104.     IsAT = true;
  105.     }
  106.  
  107.     if (cl_nswitch(msw, nmsw) != NULL)
  108.      metronome(true);
  109.  
  110.     if (cl_switch("-help")) {
  111.     cmdline_help(); 
  112.     return;
  113.     }
  114.  
  115.     if (cl_nswitch(ssw, nssw) != NULL) no_mpu = true;
  116.  
  117.     if (cl_switch("-xt")) {
  118.     if (IsAT) { /* lie! */
  119.         fprintf(stderr,"-xt but running on PC/AT!\n");
  120.         return;
  121.     }
  122.     }
  123.  
  124.     /* get input file: */
  125.     if ((s = cl_arg(1)) != NULL) strcpy(score_na, s);
  126.     fp = fileopen(score_na, "gio", "r", "Name of Adagio score file");
  127.  
  128.     phase2(phase1(fp));
  129. }
  130.