#ifndef BEAST_H
#define BEAST_H

/****h* Beast/Beast.h [0.1]
*
*	NAME
*	  Beast.h -- Beast types and constants
*
*	COPYRIGHT
*	  Maverick Software Development
*
*	FUNCTION
*
*	AUTHOR
*	  Jacco van Weert / Frans Slothouber
*	  GNU-C support by Jeroen Vermeulen
*
*	CREATION DATE
*	  3-May-95
*
*	MODIFICATION HISTORY
*
*	NOTES
*
******
*/

#include <exec/types.h>
#include <exec/lists.h>
#include <exec/nodes.h>

typedef unsigned long BST_Method  ;
typedef unsigned long BST_MethodFlags ;

#ifdef __SAS__
#define rfcall(fn,p1,p2,p3) BST_MethodFlags __asm fn (register __d3 p1, register __a2 p2, register __a3 p3)
#endif

#ifdef _DCC
#define rfcall(fn,p1,p2,p3) BST_MethodFlags fn ( __D3 p1, __A2 p2, __A3 p3)
#endif

#ifdef __GNUC__
#define rfcall(fn,p1,p2,p3) BST_MethodFlags fn (void);                  \
               static inline BST_MethodFlags real_ ## fn (              \
               BST_MethodFlags     p1, ULONG *p2, ULONG *p3)

#define self_call(result,fn,p1,p2,p3) {                                 \
        register BST_MethodFlags  selfcall_ ## p1 asm("d3") = p1;    \
        register ULONG		 *selfcall_ ## p2 asm("a2") = p2;    \
        register ULONG		 *selfcall_ ## p3 asm("a3") = p3;    \
        result = fn ();                                                 \
      }
#endif /* GCC section */



/****** Beast.h/BST_Class [0.1]
*
*	NAME
*	  BST_Class -- a beast class
*
************************************
*/
struct BST_Class
{
  struct Node       bc_Node;
  ULONG             bc_Size;
  struct MinList    bc_IntputPorts;
  struct MinList    bc_OutputPorts;
  struct MinList    bc_Methods;
  ULONG		    bc_ObjectCount;
  struct Library   *bc_ExtClass;
  ULONG             bc_Userdata;  /* NOT USED --  */
};


/****** Beast.h/class_MethodList [0.1]
*
*  NAME
*    class_MethodList -- list with methods
*
*****************************************
*/
struct class_MethodList
{
  struct MinNode  cml_Node ;
  BST_Method      cml_MethodID ;
  struct MinList *cml_HookList ;
};


/****** Beast.h/BST_Object [0.1]
*
*  NAME
*    BST_Object -- a standard object
*
************************************
*/
struct BST_Object
{
  struct MinNode     obj_Node;
  APTR		     obj_DataSection;
  struct MinList     obj_InputList;
  struct MinList     obj_OutputList;
  struct BST_Class  *obj_Class;
  struct BST_Object *obj_Parent;
  struct MinList     obj_Childs;
  ULONG		     obj_Flags;
};


/****** Beast.h/obj_InputLink [0.1]
*
*  NAME
*    obj_InputLink --
*
***********************************
*/
struct obj_InputLink
{
  struct MinNode          oil_Node ;
  struct BST_Object      *oil_Object ;
  struct obj_OutputLink  *oil_FromMethodOOL ;
  BST_Method              oil_InputMethod ;
} ;

/****** Beast.h/obj_OutputLink [0.1]
*
*  NAME
*    obj_OutputLink --
*
*************************************
*/
struct obj_OutputLink
{
  struct MinNode         ool_Node ;
  struct BST_Object     *ool_Object ;
  struct obj_InputLink  *ool_ToMethodOIL ;
  BST_Method             ool_OutputMethod ;
} ;




/****** Beast.h/BST_base [0.1]
*
*  NAME
*    BST_base --
*
******
*/

struct BST_base
{
  struct BST_Object  bb_Base ;
  struct MinList     bb_DefinedClasses ;
} ;





/********************************
 ****			     ****
 **** BEAST Standard methods ****
 ****			     ****
 ********************************/

#define	OBM_bits_FUNCTION 0xF0000000
#define	OBM_type_None	  0x00000000

#define	OBM_bits_FAMILY	  0x0F000000
#define	OBM_type_Plain	  0x00000000
#define	OBM_type_System	  0x01000000
#define	OBM_type_General  0x02000000
#define	OBM_type_B52	  0x03000000
#define	OBM_type_BeaVis	  0x04000000
#define	OBM_type_BFS	  0x05000000
#define	OBM_type_BeaMM	  0x06000000
#define	OBM_type_BEASTAR  0x07000000

	/**** Numbers   0x0000040 - 0x000007f Free */
#define OBM_local0	0x0000040
	/**** Numbers   0x0000100 - 0x00007ff Free */
#define OBM_local1	0x0000100
	/**** Numbers 	0x0004000 - 0x0004fff Free */
#define OBM_local2	0x0004000
	/**** Numbers   0x0100000 - 0x01fffff Free */
#define	OBM_local3	0x0100000


#define OBM_INPUT       0x0000080
#define OBM_OUTPUT      0x0000081
#define OBM_INPUT2      0x0000082
#define OBM_OUTPUT2     0x0000083
#define OBM_INPUT3      0x0000084
#define OBM_OUTPUT3     0x0000085
#define OBM_INPUT4      0x0000086
#define OBM_OUTPUT4     0x0000087
#define OBM_SYSINPUT    0x0000088
#define OBM_SYSOUTPUT   0x0000089
#define OBM_IDCMPINPUT	0x000008A
#define OBM_IDCMPOUTPUT	0x000008B
#define OBM_BVSINPUT	0x000008C
#define OBM_BVSOUTPUT	0x000008D
#define OBM_BEAMMINPUT  0x000008E
#define OBM_BEAMMOUTPUT	0x000008F
#define OBM_BFSINPUT	0x0000090
#define	OBM_BFSOUTPUT	0x0000091

#define	OBM_ALLOCMEM	0x0000100
#define	OBM_FREEMEM	0x0000101
#define	OBM_LOCKMEM	0x0000102
#define	OBM_UNLOCKMEM	0x0000103


#define OBM_GETATTR     0x0001000
#define OBM_SETATTR     0x0001001

#define OBM_INIT        0x0040000
#define OBM_DISPOSE     0x0040001

/**********************************
 **** Beast General classes methods
 ****/
#define	OBM_GETEACH	0x0000000|OBM_bits_System
#define	OBM_FOREACH	0x0000001|OBM_bits_System


/***********************************
 ****			     	****
 **** BEAST Standard Attributes ****
 ****			     	****
 ***********************************/

#define BST_bits_System	0x7F000000
#define BST_TAG (TAG_USER+0x40000000)

#define BTB_Ignore		29
#define BTF_Ignore		(1L<<29)
#define	BTB_Attributes		28
#define BTF_Attributes		(1L<<28)
#define BTB_UserTag		27
#define BTF_UserTag		(1L<<27)

#define	BST_bits_Types		0x00F00000
#define	BTA_type_Plain		0x00000000
#define	BTA_type_CString	0x00100000
#define	BTA_type_Object		0x00200000
#define	BTA_type_Pointer	0x00300000

/************
 **** Control
 ****/
#define BTA_CONTROL		BST_TAG|BTF_Attributes|0x000
#define	BTA_NumberOf		BTA_CONTROL+0x01

/*************
 **** Position
 ****/
#define BTA_POSITION		BST_TAG|BTF_Attributes|0x100
#define	BTA_X			BTA_POSITION+0x00|BTA_type_Plain
#define	BTA_Y			BTA_POSITION+0x01|BTA_type_Plain
#define	BTA_Width		BTA_POSITION+0x02|BTA_type_Plain
#define BTA_Height		BTA_POSITION+0x03|BTA_type_Plain
#define	BTA_Size		BTA_POSITION+0x04|BTA_type_Plain

/**********
 **** Types
 ****/
#define	BTA_TYPES		BST_TAG|BTF_Attributes|0x200
#define BTA_LongNumber		BTA_TYPES+0x00

/***************
 **** Identifier
 ****/
#define	BTA_IDENTIFIER		BST_TAG|BTF_Attributes|0x300
#define	BTA_Title		BTA_IDENTIFIER+0x00|BTA_type_CString
#define	BTA_MainObject		BTA_IDENTIFIER+0x01|BTA_type_Object
#define	BTA_Object1		BTA_IDENTIFIER+0x02|BTA_type_Object
#define	BTA_Object2		BTA_IDENTIFIER+0x03|BTA_type_Object
#define	BTA_Object3		BTA_IDENTIFIER+0x04|BTA_type_Object
#define	BTA_Object4		BTA_IDENTIFIER+0x05|BTA_type_Object
#define	BTA_Object5		BTA_IDENTIFIER+0x06|BTA_type_Object
#define	BTA_Object6		BTA_IDENTIFIER+0x07|BTA_type_Object
#define	BTA_Object7		BTA_IDENTIFIER+0x08|BTA_type_Object
#define	BTA_Object8		BTA_IDENTIFIER+0x09|BTA_type_Object
#define	BTA_Object9		BTA_IDENTIFIER+0x0A|BTA_type_Object
#define	BTA_Method		BTA_IDENTIFIER+0x0B|BTA_type_Plain
#define	BFS_UserName		BTA_IDENTIFIER+0x0C|BTA_type_CString

/***********
 **** System
 ****/
#define	BTA_SYSTEM		BST_TAG|BTF_Attributes|0x400
#define	BTA_MemBlock		BTA_SYSTEM+0x00|BTA_type_Pointer
#define	BTA_MemHandle		BTA_SYSTEM+0x01|BTA_type_Pointer
#define	BTA_MemFlags		BTA_SYSTEM+0x02|BTA_type_Plain
#define		MEMB_MOVEABLE		25
#define		MEMF_MOVEABLE		(1L<<25)
#define		MEMB_DISCARDABLE	26
#define		MEMF_DISCARDABLE	(1L<<26)

/**********************************************
 **** Method Flags for the OBJ_DoMethod routine
 ****/

#define MTHF_DOCHILDREN		0x00000001
#define MTHF_DOPARENTS		0x00000002
#define MTHF_DISPOSED     	0x00000004	/* INTERNAL: Somewhere an object must be disposed */
#define MTHF_EVENTDISPOSE	0x00000008 	/* INTERNAL: MUST be used in combination with the MTHF_DISPOSED
						   flag, now *also* the eventobject will be disposed. */
#define MTHF_PASSTOCHILD	0x00000010

#define	MTHF_ERROR	  	0x00000040
#define MTHF_FATALERROR		0x00000080
#define MTHF_BREAK		0x00000100

#define	MTHF_B52_bits		0x0000F000	/* Methodflags used by B52 */

/*****************
 **** Beast macros
 ****/
#define eq ==
#define Macro_GetInstance Object->obj_DataSection;
#define Macro_SetAttr( Structure, Attribute ) case Attribute: Structure = cur_ti->ti_Data; break;
#define Macro_GetAttr( Structure, Attribute ) case Attribute: cur_ti->ti_Data = Structure; break;

#endif	 /* BEAST_BEAST_H */
