/*********************	   GLOBAL.MM		   **************************/
/*  global data structures and constants for MM.C */
#define  MAXFUNCS 50	 /* maximum board[] slots active */
#define  MAXBAG   10	 /* number of defined MIDI functions in FUNKY.H */
#define  MAXPARAMS 10	 /* number of value variables for each knob struct */
#define  MAXHEADROOM 50  /* number of tracks[] I/O data spaces */

/******* "Track" definitions and structures **************/

/* define indices of MPU record and play tracks in array */
#define  MPU_IN        0
#define  MPU_OUT_0     1
#define  MPU_OUT_1     2
#define  MPU_OUT_2     3
#define  MPU_OUT_3     4
#define  MPU_OUT_4     5
#define  MPU_OUT_5     6
#define  MPU_OUT_6     7
#define  MPU_OUT_7     8
#define  MPU_COND_OUT  9


struct {uchar tlabel[20];	/* track space label - up to 19 chars */
	unsigned int tsize;	/* number of bytes in track space */
	unsigned int tcount;	/* number of active data bytes */
	uchar *tloc;		/* pointer to start of track space */
	uchar media;		/* code: 0 = track in RAM, 1 = on disk file */
	} tracks[MAXHEADROOM];	/* array of allocated tracks */

/* set up direct MPU-401 data buffers */
uchar mpu_inbuf[256];	   /* mpu data: becomes first tracks */
uchar mpu0_out[64], mpu1_out[64], mpu2_out[64], mpu3_out[64], mpu4_out[64]; 
uchar mpu5_out[64], mpu6_out[64], mpu7_out[64], cond_out[64]; 


/******* Structures related to MIDI functions and "patchboard" **********/

/* define "knobs" (MIDI function parameter block) type */
struct knob_space {int slot;		   /* index to board[] function */
		   int type;		   /* index to bag[] function */
		   unsigned int *inctr, *outctr; /* track data counter ptrs */
		   uchar *input, *output;  /* I/O track start-data ptrs */
		   uchar *endin, *endout;  /* ptrs to last byte in tracks */ 
		   int value[MAXPARAMS];   /* knob settings */
		   };

/* define "patchboard" type and array for active MIDI functions */
struct patch{uchar whatsit[20]; 	/* name of installed function */
	     int (*funky)();		/* pointer to function code */
	     struct knob_space *knobs;	/* pointer to knobs data stucture */
	     int in, out;	  /* index to tracks[] for input and output */
	     int active;	  /* switch installed unit on or off */
	     int next;		  /* board[] index for next function to run */
	     } board[MAXFUNCS];   /* array of active midi functions */

/* define array to hold descriptions and pointers to MIDI functions */
struct {uchar geek[20]; 	   /* name of midi function */
	int (*finger)();	   /* pointer to function code */
	unsigned int ksize;	   /* knob data space needed to activate */
	uchar set[MAXPARAMS][30];  /* names for knob value settings */
	} bag[MAXBAG];	       /* array of available functions */
			       /* initialize all defined in FUNKY.H*/

/******** Structures for IBM function-key menus ************/

/* define function menu structure and current arrays */
#define NO_D "                   "

struct menu {uchar descrip[20];  /* title for function key action in menu */
	     int (*doit)();	 /* pointer to menu function code */
	     uchar *doarg;	 /* argument for doit(); NULL if none */
	     };     /* struct type for function-key menus */

struct menu root[11], m_show[11];  /* currently available menus */
