/*
 * NAME
 *   msgtypes.h - Friday 05-Apr-96 13:30:59
 *
 * AUTHOR
 *   Jon Rocatis
 *
 * DESCRIPTION
 *   Defines for and information on the communication between
 *   a PlugIn and Apache
 *
 */

#ifndef _MSGTYPES_H_
#define _MSGTYPES_H_

#define APACHEPORTNAME "APACHE.COMM"  // This is the name of the Apache msgport that you will be talking to..

////////////////////////////////////////////////////////////////////////////////////

enum ApacheMsgTypes
{
  AMT_HELLO,         // Send this message when your PlugIn is started
  AMT_QUIT,          // Send this message when your PlugIn quits
  AMT_MIDISEND,      // Private Apache msg. Do *not* use..
  AMT_HELP,          // Unused
  AMT_MIDIRECEIVE,   // Private Apache msg. Do *not* use..
  AMT_ACTIVATE,      // Send to you by Apache when your PlugIn should activate one if it's windows
  AMT_REALTIME,      // Send to you by Apache when user changes the "real time update" function in Apache..
  AMT_CONTROLMIDI,   // Private Apache msg. Do *not* use..
  
  AMT_NUMOF
};

////////////////////////////////////////////////////////////////////////////////////

// This is a standard header for all the message types

typedef struct apmMsgHeader
{
  struct Message header;
  ULONG  msgType;             // One of the numbers from "ApacheMsgTypes"
  LONG   status;              // Status code. Meaning depends on message type
} ApacheMsgHeader;

////////////////////////////////////////////////////////////////////////////////////

typedef struct apmHello
{
  ApacheMsgHeader amh;        // amh.msgType == AMT_HELLO

  struct MsgPort *msgPort;    // Replyport that Apache will use when replying to your messages
  UBYTE manufactorID;         // The MIDI manufactor ID
  UBYTE modelID;              // The MIDI model ID

  // The rest of the structure will be initialized by Apache. You can read these values
  // after you have received reply for this message from Apache
  
  struct Screen *screen;      // Ptr to Apache's screen. You can use this to open your PlugIn on
                              // the same screen as Apache..
  char *userName;             // Name of user. This is what the user has entered in the Apache
                              // settings window under "Author"               
  BOOL realtime;              // The status of the "real time update"
} apmHello;

////////////////////////////////////////////////////////////////////////////////////

typedef struct apmQuit
{
  ApacheMsgHeader amh;        // amh.msgType == AMT_QUIT

  UBYTE manufactorID;         // The MIDI manufactor ID
  UBYTE modelID;              // The MIDI model ID
  
  BOOL okToQuit;              // You must answer TRUE here if your PlugIn quits
  BOOL forceQuit;             // Apache sets this to TRUE if your PlugIn should quit without arguing!
} apmQuit;

// NOTE: If you refuse to quit you should activate one of your windows so the user
// will get control over the resisting PlugIn.

////////////////////////////////////////////////////////////////////////////////////

typedef struct apmSend        // This message is private - Do *not* use it for PlugIns
{
  ApacheMsgHeader amh;        // amh.msgType == AMT_MIDISEND

  UBYTE *data;                // Ptr to your MIDI data
  ULONG size;                 // Size in bytes of your MIDI data
} apmSend;

////////////////////////////////////////////////////////////////////////////////////

typedef struct apmReceive     // This message is private - Do *not* use it for PlugIns
{
  ApacheMsgHeader amh;        // amh.msgType == AMT_MIDIRECEIVE

  UBYTE *dataDest;            // Ptr to where you want the data
  ULONG size;                 // Expected size of SystemExclusive 
  UBYTE ManufactorID;         // Manufactor ID of device you want to receive data from
  UBYTE ModelID;              // Model ID of device you want to receive data from
  UBYTE DeviceID;             // Device ID of device you want to receive data from
                              // NOTE: If manufactorID, modelID and deviceID == 0 any SysEx is accepted
                              // and the timeout feature is disabled..
} apmReceive;

////////////////////////////////////////////////////////////////////////////////////

typedef struct apmActivate
{
  ApacheMsgHeader amh;        // amh.msgType == AMT_ACTIVATE
} apmActivate;

////////////////////////////////////////////////////////////////////////////////////

typedef struct apmRealTime
{
  ApacheMsgHeader amh;        // amh.msgType == AMT_REALTIME

  BOOL realtime;              // TRUE == Realtime updating is ON, FALSE == OFF
} apmRealTime;

////////////////////////////////////////////////////////////////////////////////////

typedef struct apmControlMIDI // This message is private - Do *not* use it for PlugIns
{
  ApacheMsgHeader amh;        // amh.msgType == AMT_CONTROLMIDI

  UBYTE command;
  UBYTE result;
} apmControlMIDI;

////////////////////////////////////////////////////////////////////////////////////

// Status codes returned by some messages

enum
{
  AL_STATUS_OKAY,
  AL_STATUS_BUSY,
  AL_STATUS_NOMIDIPORT,
  AL_STATUS_NOMEM,
  AL_STATUS_OVERFLOW,
  AL_STATUS_TIMEOUT,
  
  AL_STATUS_NUMOF
};

////////////////////////////////////////////////////////////////////////////////////

#endif

