/*
   myheader.h - Useful #defines and typedefs for tool/accessory programs.
*/

#ifndef MYHEADER_H
#define MYHEADER_H

/* Length of tool/accessory id. */
#define ID_LEN 4

/* Make an id out of four characters. */
#define MAKE_ID(a, b, c, d)	((ULONG) ((((a << 8) + b << 8) + c << 8) + d))

/* Make an id out of a string. */
#define MAKE_IDS(s)		(MAKE_ID(s[0], s[1], s[2], s[3]))

/* Split an id into four characters. */
#define SPLIT_ID(id, a, b, c, d)	\
do {					\
  a = (UBYTE) ((id >> 24) & 0xff);	\
  b = (UBYTE) ((id >> 16) & 0xff);	\
  c = (UBYTE) ((id >> 8) & 0xff);	\
  d = (UBYTE) (id & 0xff);		\
} while (0)

/* Split an id into a string. */
#define SPLIT_IDS(id, s)		\
do {					\
  SPLIT_ID(id, s[0], s[1], s[2], s[3]);	\
} while (0)

/* Maximum MIDI note # */
#define MIDI_NOTE_MAX (127)

/* Number of MIDI notes. */
#define MIDI_NOTE_NUM (MIDI_NOTE_MAX + 1)

/* Flags for use in the BRB file requester. */
#define FILES_DELETE	1		/* Delete button */
#define FILES_OPEN	2		/* Open button */
#define FILES_SAVE	4		/* Save button */
#define	FILES_TEST	8		/* ??? */
#define FILES_TYPE	16		/* Type string gadget */
#define	FILES_PATH	32		/* Path string gadget */

/* Initial placement of tool/accessory windows. */
#define INITIAL_LEFT	50
#define INITIAL_TOP	50

/* Unprototyping cast. */
typedef __geta4 long (*no_prototype)();

/* Void cast. */
typedef __geta4 void (*void_prototype)();

/* Event *cast. */
typedef __geta4 struct Event *(*event_prototype)();

/* For non-stdio debugging messages. */
#define DEBUG(message)						\
do {								\
  struct EasyStruct es = {					\
    sizeof(struct EasyStruct),					\
    0,								\
    "Debugging information",					\
    "Message: %s",						\
    "OK"							\
    };								\
  (void) EasyRequest(functions->window, &es, 0, message);	\
} while (0)

#define NOTE_LENGTH(x)	(768 >> (x))

#define MBC_STRING_LENGTH 12

#define CLOCKSPERMEASURE 768L
  
#endif	/* MYHEADER_H */
