/* conditional compilation flags */
#define OPTOUT 1

/* Device codes to pass to Bconstat(), Bconin() and Bconout() */
#define CON 2	/* Console (ie screen and keyboard) */
#define MIDI 3

/*
 *	Defines for the various command bytes
 */
/* Command 80 - E0 have the channel number in the bottom 4 bits */
#define KEYOFF	0x80		/* we map this into KEYON, velocity = 0 */
#define KEYON	0x90
#define CONTROL 0xB0
		/* subcodes for control commands */
#define		MODWHEEL	1	/* tremolo depth on PF80 */
#define		BREATH		2	/* breath controller */
#define		FOOT		4	/* tremolo speed on PF80 */
#define		DATAENTRY	6	/* data entry knob on DX7 */
#define		VOLUME		7
#define		SUSTAIN		64
#define		PORTAMENTO	65
#define		KEYHOLD		66
#define		SOFT		67
#define		TREMOLO 	92
#define		CHORUS		93
#define		DATAPLUS	96
#define		DATAMINUS	97

#define PROGRAM 0xC0
#define AFTERTOUCH 0xD0
#define PITCHBEND 0xE0

/* F0 - FF are separate commands. Those which need channel info encode it
 * elsewhere in the arguments */
#define SYSEXCL	0xF0		/* system exclusive data follows */
#define EOX	0xF7		/* end of system exclusive data */
#define ACTIVE 	0xFE		/* Idle handshake */

/* Is this byte the first one of a midi command */
#define iscmd(x)	((x)&0x80)

#ifdef OPTOUT
extern int lastocmd;
  /* send a byte out of the midi port */
# define midiout(c)	(Bconout(MIDI, (c)), lastocmd = 0)
#else
# define midiout(c)	Bconout(MIDI, (c))
#endif

/* receive a byte from the midi port */
#define midiin()	(Bconin(MIDI) & 0xFF)
/* is there any midi data waiting to be read? */
#define mididatap()	(Bconstat(MIDI) != 0)
/* Has a key been pressed on the keyboard? */
#define kbddatap()	(Bconstat(CON) != 0)
