#ifndef _INLINE_MINREQTOOLS_H
#define _INLINE_MINREQTOOLS_H

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

__BEGIN_DECLS

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

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

static __inline
void rtFreeRequest( APTR req )
{
  BASE_EXT_DECL
  register struct Library * a6 __asm("a6") = BASE_NAME;
  
  register APTR a1 __asm("a1") = req;
  
  __asm __volatile ("jsr a6@(-0x24)"
  : /* void */
  : "r" (a6), "r" (a1)
  : "a0","a1","d0","d1", "memory");
}

static __inline
BOOL rtScreenModeRequestA( struct rtScreenModeRequester *req,
	char *title, struct TagItem *tags )
{
  BASE_EXT_DECL
  register BOOL _res  __asm("d0");
  register struct Library * a6 __asm("a6") = BASE_NAME;
  
  register struct rtScreenModeRequester * a1 __asm("a1") = req;
  register char * a3 __asm("a3") = title;
  register struct TagItem * a0 __asm("a0") = tags;
  
  __asm __volatile ("jsr a6@(-0x90)"
  : "=r" (_res)
  : "r" (a6), "r" (a1), "r" (a3), "r" (a0)
  : "a0","a1","d0","d1", "memory");
  return _res;
}

#ifndef NO_INLINE_STDARG
#define rtScreenModeRequest(a0, a1, tags...) \
  ({ struct TagItem _tags[] = { tags }; rtScreenModeRequestA((a0), (a1), _tags); })
#endif /* not NO_INLINE_STDARG */

#undef BASE_EXT_DECL
#undef BASE_PAR_DECL
#undef BASE_PAR_DECL0
#undef BASE_NAME

__END_DECLS

#endif /* _INLINE_REQTOOLS_H */
