/***************************************************************************
 *
 * bengbi.h
 *
 ***************************************************************************
 *
 * GBI for new ucode
 *
 ***************************************************************************/

#ifndef BENGBI_H_INCLUDED
#define BENGBI_H_INCLUDED

#include <PR/gbi.h>

/*
 * commands
 */

#define BEN_LOADVTX	0
#define BEN_LOADMTX	1
#define BEN_SETPROJ	2
#define BEN_SETVPCTR	3
#define BEN_MARKVTX	4
#define BEN_FINISHLIST	5
#define BEN_POLY	6
#define BEN_CALLLIST	7
#define BEN_RETURNLIST	8
#define BEN_LOADUCODE	9

#define benLoadVtx(gp,ptr,ct)				\
{							\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(BEN_LOADVTX<<26) | (ct);		\
	_g->words.w1=(unsigned int)ptr;			\
}

#define benLoadMtx(gp,ptr)				\
{							\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(BEN_LOADMTX<<26);			\
	_g->words.w1=(unsigned int)ptr;			\
}

#define benSetProj(gp,val)				\
{							\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(BEN_SETPROJ<<26);			\
	_g->words.w1=(unsigned int)val;			\
}

#define benSetVpCtr(gp,x,y)				\
{							\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(BEN_SETVPCTR<<26);		\
	_g->words.w1=((unsigned int)x<<16) |		\
		     ((unsigned int)y&0xFFFF);		\
}

#define benMarkVtx(gp,which)				\
{							\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(BEN_MARKVTX<<26);			\
	_g->words.w1=(unsigned int)which;		\
}

#define benFinishList(gp)				\
{							\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(BEN_FINISHLIST<<26);		\
}

#define benPoly(gp,a,b,c)				\
{							\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(BEN_POLY<<26);			\
	_g->words.w1=(1 << 24) | ((int)(a)<<16) | ((int)(b)<<8) | (int)(c);	\
}

#define ben2Polys(gp,a,b,c,d,e,f)			\
{							\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(BEN_POLY<<26) | ((int)(d)<<16) | ((int)(e)<<8) | (int)(f); \
	_g->words.w1=((int)(a)<<16) | ((int)(b)<<8) | (int)(c);	\
}

#define benRenderMode(gp,pm,cyc,tp,td,tl,tt,tf,tc,ck,cd,ad,rm1,rm2,zs,ac) \
{									\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(0xef<<24) | (pm) | (cyc) | (tp) | (td) | (tl) | \
		     (tt) | (tf) | (tc) | (ck) | (cd) | (ad) | 0xf;   \
	_g->words.w1=(rm1) | (rm2) | (zs) | (ac);       \
}

#define benCallList(gp,list)				\
{							\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(BEN_CALLLIST<<26);			\
	_g->words.w1=(unsigned int)list;			\
}

#define benReturnList(gp)				\
{							\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(BEN_RETURNLIST<<26);			\
}

#define benLoadUcode(gp,code,data)			\
{							\
	Gfx	*_g=(Gfx *)(gp);			\
	_g->words.w0=(BEN_LOADUCODE<<26) | (code & 0x00FFFFFF); \
	_g->words.w1=(data & 0x00FFFFFF); \
}

#endif
