/*************************************************************/
/* Includes and other common stuff for the MUI demo programs */
/*************************************************************/
/* modified for MaxonC++ by Daniel Hirscher, 9.10.96         */

/* Maxon */
#include <wbstartup.h>

/* MUI */
#include <libraries/mui.h>

/* System */
#include <dos/dos.h>
#include <graphics/gfxmacros.h>
#include <workbench/workbench.h>

/* Prototypes */
#include <clib/alib_protos.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#include <clib/icon_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/utility_protos.h>
#include <clib/asl_protos.h>
#include <clib/muimaster_protos.h>

/* ANSI C */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>


/* Compiler specific stuff */

#define REG(x) register __ ## x
#define ASM
#define SAVEDS

#include <pragma/exec_lib.h>
#include <pragma/dos_lib.h>
#include <pragma/icon_lib.h>
#include <pragma/graphics_lib.h>
#include <pragma/intuition_lib.h>
#include <pragma/gadtools_lib.h>
#include <pragma/utility_lib.h>
#include <pragma/asl_lib.h>
#include <pragma/muimaster_lib.h>

extern struct Library *SysBase,*IntuitionBase,*UtilityBase,*GfxBase,*DOSBase,*IconBase;
struct Library *MUIMasterBase;



/*************************/
/* Init & Fail Functions */
/*************************/

static VOID fail(APTR app,char *str)
{
        if (app)
                MUI_DisposeObject(app);

        if (MUIMasterBase)
                CloseLibrary(MUIMasterBase);

        if (str)
        {
                puts(str);
                exit(20);
        }
        exit(0);
}


static VOID init(VOID)
{
        if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
                fail(NULL,"Failed to open "MUIMASTER_NAME".");
}


static VOID stccpy(char *dest,char *source,int len)
{
        strncpy(dest,source,len);
        dest[len-1]='\0';
}


#ifndef MAKE_ID
#define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
#endif


LONG __stack = 8192;

