#ifndef _INLINE_MUIMASTER_H
#define _INLINE_MUIMASTER_H

#include <sys/cdefs.h>
#include <inline/stubs.h>

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif
#ifndef INTUITION_CLASSES_H
#include <intuition/classes.h>
#endif
#ifndef UTILITY_TAGITEM_H
#include <utility/tagitem.h>
#endif

#define static

__BEGIN_DECLS

#ifndef BASE_EXT_DECL
#define BASE_EXT_DECL extern struct Library*  MUIMasterBase;
#endif
#ifndef BASE_PAR_DECL
#define BASE_PAR_DECL
#define BASE_PAR_DECL0 void
#endif
#ifndef BASE_NAME
#define BASE_NAME MUIMasterBase
#endif

static __inline APTR
MUI_AllocAslRequest (BASE_PAR_DECL unsigned long type,struct TagItem *tags)
{
  BASE_EXT_DECL
  register APTR  _res  __asm("d0");
  register struct Library* a6 __asm("a6") = BASE_NAME;
  register unsigned long d0 __asm("d0") = type;
  register struct TagItem *a0 __asm("a0") = tags;
  __asm __volatile ("jsr a6@(-0x30)"
  : "=r" (_res)
  : "r" (a6), "r" (d0), "r" (a0)
  : "a0","a1","d0","d1", "memory");
  return _res;
}

APTR MUI_AllocAslRequestTags(ULONG type, Tag tag1, ...)
{
 return(MUI_AllocAslRequest(type, (struct TagItem *) &tag1));
}

static __inline VOID
MUI_DisposeObject (BASE_PAR_DECL APTR obj)
{
  BASE_EXT_DECL
  register struct Library* a6 __asm("a6") = BASE_NAME;
  register APTR a0 __asm("a0") = obj;
  __asm __volatile ("jsr a6@(-0x24)"
  : /* no output */
  : "r" (a6), "r" (a0)
  : "a0","a1","d0","d1", "memory");
}

static __inline BOOL
MUI_AslRequest (BASE_PAR_DECL APTR req,struct TagItem *tags)
{
  BASE_EXT_DECL
  register BOOL  _res  __asm("d0");
  register struct Library* a6 __asm("a6") = BASE_NAME;
  register APTR a0 __asm("a0") = req;
  register struct TagItem *a1 __asm("a1") = tags;
  __asm __volatile ("jsr a6@(-0x36)"
  : "=r" (_res)
  : "r" (a6), "r" (a0), "r" (a1)
  : "a0","a1","d0","d1", "memory");
  return _res;
}

BOOL MUI_AslRequestTags(APTR req, Tag tag1, ...)
{
 return(MUI_AslRequest(req, (struct TagItem *) &tag1));
}

static __inline LONG
MUI_Error (BASE_PAR_DECL0)
{
  BASE_EXT_DECL
  register LONG  _res  __asm("d0");
  register struct Library* a6 __asm("a6") = BASE_NAME;
  __asm __volatile ("jsr a6@(-0x42)"
  : "=r" (_res)
  : "r" (a6)
  : "a0","a1","d0","d1", "memory");
  return _res;
}
static __inline VOID
MUI_FreeAslRequest (BASE_PAR_DECL APTR req)
{
  BASE_EXT_DECL
  register struct Library* a6 __asm("a6") = BASE_NAME;
  register APTR a0 __asm("a0") = req;
  __asm __volatile ("jsr a6@(-0x3c)"
  : /* no output */
  : "r" (a6), "r" (a0)
  : "a0","a1","d0","d1", "memory");
}
static __inline APTR
MUI_NewObjectA (BASE_PAR_DECL char *class,struct TagItem *tags)
{
  BASE_EXT_DECL
  register APTR  _res  __asm("d0");
  register struct Library* a6 __asm("a6") = BASE_NAME;
  register char *a0 __asm("a0") = class;
  register struct TagItem *a1 __asm("a1") = tags;
  __asm __volatile ("jsr a6@(-0x1e)"
  : "=r" (_res)
  : "r" (a6), "r" (a0), "r" (a1)
  : "a0","a1","d0","d1", "memory");
  return _res;
}
APTR MUI_NewObject(char *class, Tag tag1, ...)
{
 return(MUI_NewObjectA(class, (struct TagItem *) &tag1));
}

static __inline LONG
MUI_RequestA (BASE_PAR_DECL APTR app,APTR win,LONGBITS flags,char *title,char *gadgets,char *format,APTR params)
{
  BASE_EXT_DECL
  register LONG  _res  __asm("d0");
  register struct Library* a6 __asm("a6") = BASE_NAME;
  register APTR d0 __asm("d0") = app;
  register APTR d1 __asm("d1") = win;
  register LONGBITS d2 __asm("d2") = flags;
  register char *a0 __asm("a0") = title;
  register char *a1 __asm("a1") = gadgets;
  register char *a2 __asm("a2") = format;
  register APTR a3 __asm("a3") = params;
  __asm __volatile ("jsr a6@(-0x2a)"
  : "=r" (_res)
  : "r" (a6), "r" (d0), "r" (d1), "r" (d2), "r" (a0), "r" (a1), "r" (a2), "r" (a3)
  : "a0","a1","a2","a3","d0","d1","d2", "memory");
  return _res;
}
LONG MUI_Request(APTR app, APTR win, LONGBITS flags, char *title, char *gadgets, char *format, ...)
{
 return(MUI_RequestA(app, win, flags, title, gadgets, format, (APTR) (((ULONG)&format)+4) ));
}
#undef BASE_EXT_DECL
#undef BASE_PAR_DECL
#undef BASE_PAR_DECL0
#undef BASE_NAME

__END_DECLS

#endif /* _INLINE_MUIMASTER_H */
