#ifndef _INLINE_HRGRENDER_H
#define _INLINE_HRGRENDER_H

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

__BEGIN_DECLS

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

BASE_EXT_DECL0

/* Falsche FD/proto-Argumente !

	hrCvtRGB2PACKED8 gets 3 fd args and 1 proto.
	hrDithRGB2PACKED8 gets 5 fd args and 3 protos.
*/

extern __inline UBYTE
hrBestColor( BASE_PAR_DECL struct HRBitMap *hrbm, ULONG col)
{
	BASE_EXT_DECL
	register UBYTE _res __asm("d0");
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register struct HRBitMap *a0 __asm("a0") = hrbm;
	register ULONG d0 __asm("d0") = col;
	__asm __volatile ("jsr a6@(-0x66)"
	: "=r" (_res)
	: "r" (a6), "r" (a0), "r" (d0)
	: "d0", "d1", "a0", "a1");
	return _res;
}
extern __inline void
hrClearToCol( BASE_PAR_DECL struct HRBitMap *hrbm, ULONG color )
{
	BASE_EXT_DECL
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register struct HRBitMap *a0 __asm("a0") = hrbm;
	register ULONG d0 __asm("d0") = color;
	__asm __volatile ("jsr a6@(-0x7e)"
	: /* no output */
	: "r" (a6), "r" (a0), "r" (d0)
	: "d0", "d1", "a0", "a1");
}
extern __inline ULONG
hrCvtRGB2TARGA (BASE_PAR_DECL UBYTE r, UBYTE g, UBYTE b)
{
	BASE_EXT_DECL
	register ULONG _res __asm("d0");
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register UBYTE d0 __asm("d0") = r;
	register UBYTE d1 __asm("d1") = g;
	register UBYTE d2 __asm("d2") = b;
	__asm __volatile ("jsr a6@(-0x36)"
	: "=r" (_res)
	: "r" (a6), "r" (d0), "r" (d1), "r" (d2)
	: "d0", "d1", "a0", "a1", "d2");
	return _res;
}
extern __inline UBYTE
hrCvtRGBA2PACKED8 (BASE_PAR_DECL ULONG col)
{
	BASE_EXT_DECL
	register UBYTE _res __asm("d0");
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register ULONG d0 __asm("d0") = col;
	__asm __volatile ("jsr a6@(-0x54)"
	: "=r" (_res)
	: "r" (a6), "r" (d0)
	: "d0", "d1", "a0", "a1");
	return _res;
}
extern __inline ULONG
hrCvtRGBA2TARGA (BASE_PAR_DECL ULONG col)
{
	BASE_EXT_DECL
	register ULONG _res __asm("d0");
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register ULONG d0 __asm("d0") = col;
	__asm __volatile ("jsr a6@(-0x3c)"
	: "=r" (_res)
	: "r" (a6), "r" (d0)
	: "d0", "d1", "a0", "a1");
	return _res;
}
extern __inline ULONG
hrDithRGB2TARGA (BASE_PAR_DECL ULONG x, ULONG y, UBYTE r, UBYTE g, UBYTE b)
{
	BASE_EXT_DECL
	register ULONG _res __asm("d0");
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register ULONG d0 __asm("d0") = x;
	register ULONG d1 __asm("d1") = y;
	register UBYTE d2 __asm("d2") = r;
	register UBYTE d3 __asm("d3") = g;
	register UBYTE d4 __asm("d4") = b;
	__asm __volatile ("jsr a6@(-0x42)"
	: "=r" (_res)
	: "r" (a6), "r" (d0), "r" (d1), "r" (d2), "r" (d3), "r" (d4)
	: "d0", "d1", "a0", "a1", "d2", "d3", "d4");
	return _res;
}
extern __inline UBYTE
hrDithRGBA2PACKED8 (BASE_PAR_DECL ULONG x, ULONG y, ULONG col)
{
	BASE_EXT_DECL
	register UBYTE _res __asm("d0");
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register ULONG d0 __asm("d0") = x;
	register ULONG d1 __asm("d1") = y;
	register ULONG d2 __asm("d2") = col;
	__asm __volatile ("jsr a6@(-0x60)"
	: "=r" (_res)
	: "r" (a6), "r" (d0), "r" (d1), "r" (d2)
	: "d0", "d1", "a0", "a1", "d2");
	return _res;
}
extern __inline ULONG
hrDithRGBA2TARGA (BASE_PAR_DECL ULONG x, ULONG y, UBYTE r , UBYTE g, UBYTE b)
{
	BASE_EXT_DECL
	register ULONG _res __asm("d0");
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register ULONG d0 __asm("d0") = x;
	register ULONG d1 __asm("d1") = y;
	register UBYTE d2 __asm("d2") = r;
	register UBYTE d3 __asm("d3") = g;
	register UBYTE d4 __asm("d4") = b;
	__asm __volatile ("jsr a6@(-0x48)"
	: "=r" (_res)
	: "r" (a6), "r" (d0), "r" (d1), "r" (d2), "r" (d3), "r" (d4)
	: "d0", "d1", "a0", "a1", "d2", "d3", "d4");
	return _res;
}
extern __inline BOOL
hrDoDither( BASE_PAR_DECL struct HRBitMap *hrbm, BOOL flag )
{
	BASE_EXT_DECL
	register BOOL _res __asm("d0");
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register struct HRBitMap *a0 __asm("a0") = hrbm;
	register BOOL d0 __asm("d0") = flag;
	__asm __volatile ("jsr a6@(-0x1e)"
	: "=r" (_res)
	: "r" (a6), "r" (a0), "r" (d0)
	: "d0", "d1", "a0", "a1");
	return _res;
}
extern __inline BOOL
hrDrawLine( BASE_PAR_DECL struct HRBitMap *hrbm,
				ULONG x0, ULONG y0,
				ULONG x1, ULONG y1, ULONG col )
{
	BASE_EXT_DECL
	register BOOL _res __asm("d0");
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register struct HRBitMap *a0 __asm("a0") = hrbm;
	register ULONG d0 __asm("d0") = x0;
	register ULONG d1 __asm("d1") = y0;
	register ULONG d2 __asm("d2") = x1;
	register ULONG d3 __asm("d3") = y1;
	register ULONG d4 __asm("d4") = col;
	__asm __volatile ("jsr a6@(-0x30)"
	: "=r" (_res)
	: "r" (a6), "r" (a0), "r" (d0), "r" (d1), "r" (d2), "r" (d3), "r" (d4)
	: "d0", "d1", "a0", "a1", "d2", "d3", "d4");
	return _res;
}
extern __inline void
hrFillRect( BASE_PAR_DECL struct HRBitMap *hrbm,
									ULONG xpos, ULONG ypos,
									ULONG width, ULONG height,
									ULONG color )
{	BASE_EXT_DECL
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register struct HRBitMap *a0 __asm("a0") = hrbm;
	register ULONG d0 __asm("d0") = xpos;
	register ULONG d1 __asm("d1") = ypos;
	register ULONG d2 __asm("d2") = width;
	register ULONG d3 __asm("d3") = height;
	register ULONG d4 __asm("d4") = color;
	__asm __volatile ("jsr a6@(-0x84)"
	:
	: "r" (a6), "r" (a0), "r" (d0), "r" (d1), "r" (d2), "r" (d3), "r" (d4)
	: "d0", "d1", "a0", "a1", "d2", "d3", "d4");
}
extern __inline ULONG
hrGetPixel( BASE_PAR_DECL struct HRBitMap *hrbm, ULONG x, ULONG y )
{
	BASE_EXT_DECL
	register ULONG _res __asm("d0");
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register struct HRBitMap *a0 __asm("a0") = hrbm;
	register ULONG d0 __asm("d0") = x;
	register ULONG d1 __asm("d1") = y;
	__asm __volatile ("jsr a6@(-0x2a)"
	: "=r" (_res)
	: "r" (a6), "r" (a0), "r" (d0), "r" (d1)
	: "d0", "d1", "a0", "a1");
	return _res;
}
extern __inline void
hrReadRectRGB( BASE_PAR_DECL struct HRBitMap *hrbm,
										UBYTE *rdat, UBYTE *gdat, UBYTE *bdat,
										ULONG xpos,		ULONG ypos,
										ULONG width,	ULONG height,
										ULONG pixmod,	ULONG rowmod )
{	BASE_EXT_DECL
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register struct HRBitMap *a0 __asm("a0") = hrbm;
	register UBYTE *a1 __asm("a1") = rdat;
	register UBYTE *a2 __asm("a2") = gdat;
	register UBYTE *a3 __asm("a3") = bdat;
	register ULONG d0 __asm("d0") = xpos;
	register ULONG d1 __asm("d1") = ypos;
	register ULONG d2 __asm("d2") = width;
	register ULONG d3 __asm("d3") = height;
	register ULONG d4 __asm("d4") = pixmod;
	register ULONG d5 __asm("d5") = rowmod;
	__asm __volatile ("jsr a6@(-0x8a)"
	:
	: "r" (a6), "r" (a0), "r" (a1), "r" (a2), "r" (a3), "r" (d0), "r" (d1), "r" (d2), "r" (d3), "r" (d4), "r" (d5)
	: "d0", "d1", "a0", "a1", "a2", "a3", "d2", "d3", "d4", "d5");
}
extern __inline void
hrSetPixel( BASE_PAR_DECL struct HRBitMap *hrbm, ULONG x, ULONG y, ULONG col )
{
	BASE_EXT_DECL
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register struct HRBitMap *a0 __asm("a0") = hrbm;
	register ULONG d0 __asm("d0") = x;
	register ULONG d1 __asm("d1") = y;
	register ULONG d2 __asm("d2") = col;
	__asm __volatile ("jsr a6@(-0x24)"
	:
	: "r" (a6), "r" (a0), "r" (d0), "r" (d1), "r" (d2)
	: "d0", "d1", "a0", "a1", "d2" );
}
extern __inline void
hrWriteBitMap( BASE_PAR_DECL struct HRBitMap *hrbm, struct BitMap *bmp,
					ULONG XPosDest, ULONG YPosDest,
					ULONG XPosSrc,  ULONG YPosSrc,
					ULONG WidthSrc, ULONG HeightScr, ULONG Mode )
{
	BASE_EXT_DECL
	register struct Library  *a6 __asm("a6") = BASE_NAME;
	register struct HRBitMap *a0 __asm("a0") = hrbm;
	register struct BitMap   *a1 __asm("a1") = bmp;
	register ULONG d0 __asm("d0") = XPosDest;
	register ULONG d1 __asm("d1") = YPosDest;
	register ULONG d2 __asm("d2") = XPosSrc;
	register ULONG d3 __asm("d3") = YPosSrc;
	register ULONG d4 __asm("d4") = WidthSrc;
	register ULONG d5 __asm("d5") = HeightScr;
	register ULONG d6 __asm("d6") = Mode;
	__asm __volatile ("jsr a6@(-0x6c)"
	:
	: "r" (a6), "r" (a0), "r" (a1), "r" (d0), "r" (d1), "r" (d2), "r" (d3), "r" (d4), "r" (d5), "r" (d6)
	: "d0", "d1", "a0", "a1", "d2", "d3", "d4", "d5", "d6");
}
extern __inline void
hrWriteRectPK8( BASE_PAR_DECL struct HRBitMap *hrbm, UBYTE *dat,
										ULONG xdest, ULONG ydest,
										ULONG width, ULONG height,
										ULONG pixoff, ULONG rowmod )
{	BASE_EXT_DECL
	register struct Library  *a6 __asm("a6") = BASE_NAME;
	register struct HRBitMap *a0 __asm("a0") = hrbm;
	register UBYTE *a1 __asm("a1") = dat;
	register ULONG d0 __asm("d0") = xdest;
	register ULONG d1 __asm("d1") = ydest;
	register ULONG d2 __asm("d2") = width;
	register ULONG d3 __asm("d3") = height;
	register ULONG d4 __asm("d4") = pixoff;
	register ULONG d5 __asm("d5") = rowmod;
	__asm __volatile ("jsr a6@(-0x78)"
	:
	: "r" (a6), "r" (a0), "r" (a1), "r" (d0), "r" (d1), "r" (d2), "r" (d3), "r" (d4), "r" (d5)
	: "d0", "d1", "a0", "a1", "d2", "d3", "d4", "d5");
}
extern __inline void
hrWriteRectRGB( BASE_PAR_DECL struct HRBitMap *hrbm,
					 UBYTE *rdat, UBYTE *gdat, UBYTE *bdat,
					 ULONG xdest, ULONG ydest, ULONG width,
					 ULONG height, ULONG pixmod,
					 ULONG rowmod )
{	BASE_EXT_DECL
	register struct Library *a6 __asm("a6") = BASE_NAME;
	register struct HRBitMap *a0 __asm("a0") = hrbm;
	register UBYTE *a1 __asm("a1") = rdat;
	register UBYTE *a2 __asm("a2") = gdat;
	register UBYTE *a3 __asm("a3") = bdat;
	register ULONG d0 __asm("d0") = xdest;
	register ULONG d1 __asm("d1") = ydest;
	register ULONG d2 __asm("d2") = width;
	register ULONG d3 __asm("d3") = height;
	register ULONG d4 __asm("d4") = pixmod;
	register ULONG d5 __asm("d5") = rowmod;
	__asm __volatile ("jsr a6@(-0x72)"
	:
	: "r" (a6), "r" (a0), "r" (a1), "r" (a2), "r" (a3), "r" (d0), "r" (d1), "r" (d2), "r" (d3), "r" (d4), "r" (d5)
	: "d0", "d1", "a0", "a1", "a2", "a3", "d2", "d3", "d4", "d5");
}

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

__END_DECLS

#endif /* _INLINE_HRGRENDER_H */
