/*===================================*/
/*                                   */
/* MCC Configuration File Access     */
/*                                   */
/* Reads the file MQ.CFG to          */
/* determine the inerreupt level and */
/* base I/O address assigned to the  */
/* MCC.                              */
/*                                   */
/* This module can be used to write  */
/* an MCC application that works     */
/* in harmony with the rest of the   */
/* MIDI Starter System.              */
/*                                   */
/* Copyright (c) 1988                */
/* By Music Quest, Inc.              */
/*                                   */
/* Public Domain                     */
/* Subject to the same usage         */
/* requirements as the ToolKit.      */
/*                                   */
/*===================================*/

#define CONFIG  "MQ.CFG"

#include "fcntl.h"
#include "stat.h"

struct pro_data                         /* MQ.CFG structure */
  {
    int level;                          /* interrupt level index */
    int addr;                           /* card address index */
  };
struct pro_data p = {2,0x330};          /* default = irq2, 330 */

/*===================================*/
/* Configure the card                */
/*                                   */
/* Reads the MQ.CFG file.  Installs  */
/* the ToolKit according to the      */
/* current configuration.            */
/*                                   */
/* Returned values                   */
/*   0 = MCC not found or installed  */
/*   1 = ToolKit installed.          */
/*                                   */
/*===================================*/
mcc_config()
{
  int fx;

  if ((fx=open(CONFIG,O_RDONLY|O_BINARY)) >= 0) /* open config file */
    {
      read(fx,&p,sizeof(p));            /* read the IRQ and address */
      close(fx);
    }

  return(mcc_open(p.addr,p.level));     /* initialize MCC */
}

/*===================================*/
/* DeConfigure the card              */
/*===================================*/
mcc_deconfig()
{
  mcc_close();
}

/*===================================*/
/* Returns the base I/O address      */
/*===================================*/
mcc_addr()
{
  return(p.addr);
}

/*===================================*/
/* Returns the current IRQ number    */
/*===================================*/
mcc_level()
{
  return(p.level);
}
