
#ifndef CLASSBASE_H
#define CLASSBASE_H 1

/*
**
**  $VER: classbase.h 1.1 (5.11.97)
**  mpegaudio.datatype 1.1
**
**  Header file for DataTypes class
**
**  Written 1996/97 by Roland 'Gizzy' Mainz
**  Original example source from David N. Junod
**
*/

/* amiga includes */
#include <exec/types.h>
#include <exec/ports.h>
#include <exec/memory.h>
#include <exec/lists.h>
#include <exec/semaphores.h>
#include <exec/execbase.h>
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <dos/rdargs.h>
#include <dos/dostags.h>
#include <intuition/classes.h>  /* must be $Id: classes.h,v 40.0 94/02/15 17:46:35 davidj Exp Locker: davidj $ */
#include <intuition/classusr.h>
#include <intuition/cghooks.h>
#include <intuition/icclass.h>
#include <intuition/gadgetclass.h>
#include <datatypes/datatypes.h>
#include <datatypes/datatypesclass.h>
#include <datatypes/soundclass.h>

/* amiga prototypes */
#include <clib/macros.h>
#include <clib/exec_protos.h>
#include <clib/utility_protos.h>
#include <clib/dos_protos.h>
#include <clib/intuition_protos.h>
#include <clib/datatypes_protos.h>
#include <clib/dtclass_protos.h>
#ifdef PARAMETERS_STACK
#include <clib/alib_protos.h>
#include <clib/alib_stdio_protos.h>
#endif /* PARAMETERS_STACK */

/* amiga pragmas */
#include <pragmas/exec_pragmas.h>
#include <pragmas/utility_pragmas.h>
#include <pragmas/dos_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/datatypes_pragmas.h>
#include <pragmas/dtclass_pragmas.h>
#include <pragmas/alib_pragmas.h> /* amiga.lib stubs (tagcall pragmas) */

/* ANSI includes */
#include <string.h>

/*****************************************************************************/

struct ClassBase
{
    struct ClassLibrary     cb_Lib;
    struct ExecBase        *cb_SysBase;
    struct Library         *cb_UtilityBase;
    struct Library         *cb_DOSBase;
    struct Library         *cb_IntuitionBase;
    struct Library         *cb_DataTypesBase;
    struct Library         *cb_SuperClassBase;
    BPTR                    cb_SegList;
    struct SignalSemaphore  cb_Lock;           /* Access lock */
};

/*****************************************************************************/

/* SASC specific defines */
#define DISPATCHERFLAGS __saveds __asm
#define ASM             __asm
#define REGD0 register __d0
/* ... */
#define REGA0 register __a0
#define REGA1 register __a1
#define REGA2 register __a2
/* ... */
#define REGA6 register __a6

/*****************************************************************************/

#define SysBase        (cb -> cb_SysBase)
#define UtilityBase    (cb -> cb_UtilityBase)
#define DOSBase        (cb -> cb_DOSBase)
#define IntuitionBase  (cb -> cb_IntuitionBase)
#define DataTypesBase  (cb -> cb_DataTypesBase)

/*****************************************************************************/

/* integer division, rounded */
#define INTDIVR( x, y ) (((x) + ((y) / 2)) / (y))

/* Align memory on 4 byte boundary */
#define ALIGN_LONG( mem ) ((APTR)((((ULONG)(mem)) + 3UL) & ~3UL))

/* Align memory on 16 byte boundary */
#define ALIGN_QUADLONG( mem ) ((APTR)((((ULONG)(mem)) + 15UL) & ~15UL))

/* Following ptr */
#define MEMORY_FOLLOWING( ptr )     ((void *)((ptr) + 1))

/* Memory after n bytes */
#define MEMORY_N_FOLLOWING( ptr, n ) ((void *)(((UBYTE *)ptr) + n ))

/* Memory after n bytes, longword aligned (Don't forget the 4 bytes in size for rounding !!) */
#define MEMORY_NAL_FOLLOWING( ptr, n ) (ALIGN_LONG( ((void *)(((UBYTE *)ptr) + n )) ))

/* casts */
#define V( x )    ((VOID *)(x))
#define G( o )    ((struct Gadget *)(o))
#define EXTG( o ) ((struct ExtGadget *)(o))

/* Exclude tag item */
#define XTAG( expr, tagid ) ((Tag)((expr)?(tagid):(TAG_IGNORE)))

/* Get data from pointer only if it is NOT NULL (and cast data to ULONG) */
#define XPTRDATA( x ) ((ULONG)((x)?(*(x)):(0UL)))

/* Boolean conversion */
#define MAKEBOOL( x ) ((BOOL)((x) != NULL))

/*****************************************************************************/

#ifndef PARAMETERS_STACK
#define PARAMETERS_STACK 1
#define  CLIB_ALIB_PROTOS_H
__stdargs void  NewList( struct List *list );
__stdargs ULONG DoMethodA( Object *obj, Msg message );
__stdargs ULONG DoMethod( Object *obj, unsigned long MethodID, ... );
__stdargs ULONG DoSuperMethodA( struct IClass *cl, Object *obj, Msg message );
__stdargs ULONG DoSuperMethod( struct IClass *cl, Object *obj, unsigned long MethodID, ... );
__stdargs ULONG CoerceMethodA( struct IClass *cl, Object *obj, Msg message );
__stdargs ULONG CoerceMethod( struct IClass *cl, Object *obj, unsigned long MethodID, ... );
__stdargs ULONG SetSuperAttrs( struct IClass *cl, Object *obj, unsigned long Tag1, ... );
#endif /* !PARAMETERS_STACK */

/*****************************************************************************/

#include "class_iprotos.h"

#endif /* !CLASSBASE_H */


