/*ProfiPacket - packet radio terminal program
  Copyright (C) 1999  Alexander Feigl

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  Author:

  Alexander Feigl
  Burachstraße 51

  D-88250 Weingarten

  Mail : Alexander.Feigl@gmx.de
*/


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <exec/types.h>
#include <utility/tagitem.h>
#include <libraries/mui.h>

#include <clib/muimaster_protos.h>
#include <clib/intuition_protos.h>


#ifdef __GNUC__

extern void *IntuitionBase;
extern void *MUIMasterBase;
#define NO_INLINE_STDARG
#include <inline/muimaster.h>
#include <inline/intuition.h>
#undef MUI_CreateCustomClass
#endif

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

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



Object *MUI_MakeObject(LONG type, ...)
{
  return(MUI_MakeObjectA(type, (ULONG *)(((ULONG)&type)+4)));
}

  Object* MUI_NewObject(char *class, Tag tag1, ...)
{
 return(MUI_NewObjectA(class, (struct TagItem *) &tag1));
}



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) ));
 }


APTR NewObject( struct IClass *classPtr, UBYTE *classID, unsigned long tag1, ... )
{
 return(NewObjectA((void *) classPtr, (void *) classID,(void *) &tag1));
}


struct MUI_CustomClass*
MUI_CreateCustomClass( struct Library *base, char *supername, struct MUI_CustomClass *supermcc, int datasize, APTR dispatcher)
{
  register struct MUI_CustomClass* res __asm("d0");
  register struct Library* a6 __asm("a6") = MUIMasterBase;
  register struct Library* a0 __asm("a0") = base;
  register char* a1 __asm("a1") = supername;
  register struct MUI_CustomClass* a2 __asm("a2") = supermcc;
  register int d0 __asm("d0") = datasize;
  register APTR a3 __asm("a3") = dispatcher;

  __asm volatile ("
  jsr a6@(-0x6c)"
  : "=r" (res)
  : "r" (a6), "r" (a0), "r" (a1), "r" (a2), "r" (d0), "r" (a3)
  : "d0", "d1", "a0", "a1", "a2", "a3" );
  return res;
}
