#include<ultra64.h>

extern Vtx MC_Gate_v[];

extern unsigned short MC_Gake_txt[];
extern unsigned char MC_PointTX01_CI8_txt[];
extern unsigned short MC_TX02_txt[];



#define gs_Nin_LoadTextureImage(timg,fmt,siz,width,height,tmem,tt)	\
	gsDPSetTextureImage(fmt,siz,1,timg),	\
	gsDPTileSync(),	\
	gsDPSetTile(fmt,siz,0,tmem,tt,0,0,0,0,0,0,0),	\
	gsDPLoadSync(),	\
	gsDPLoadBlock(tt,0,0,width*height-1,CALC_DXT(width,siz##_BYTES))

#define gs_Nin_SetUpTileDescrip(fmt,siz,width,height,tmem,tt,cs,ms,ss,ct,mt,st)	\
	gsDPTileSync(),	\
	gsDPSetTile(fmt,siz,((((width)*siz##_LINE_BYTES)+7)>>3),tmem,tt,0,ct,mt,st,cs,ms,ss),	\
	gsDPSetTileSize(tt,0,0,(width-1)<<G_TEXTURE_IMAGE_FRAC,(height-1)<<G_TEXTURE_IMAGE_FRAC)

#define G_CC_PRIMSHADE PRIMITIVE,0,SHADE,0,0,0,0,SHADE

/* main display list */


/* ======== o2 ======== */

Gfx MC_Gate[]={

	gs_Nin_SetUpTileDescrip(G_IM_FMT_RGBA,G_IM_SIZ_16b,32,64,0,0,G_TX_WRAP,5,0,G_TX_WRAP,6,0),
	gs_Nin_LoadTextureImage(MC_Gake_txt,G_IM_FMT_RGBA,G_IM_SIZ_16b,32,64,0,7),

	gsSPVertex(&MC_Gate_v[0], 8, 0),
	gsSP1Triangle(0, 1, 2, 0),
	gsSP1Triangle(0, 2, 3, 0),
	gsSP1Triangle(4, 5, 6, 0),
	gsSP1Triangle(4, 6, 7, 0),

	gs_Nin_SetUpTileDescrip(G_IM_FMT_RGBA,G_IM_SIZ_16b,32,32,0,0,G_TX_WRAP,5,0,G_TX_WRAP,5,0),
	gs_Nin_LoadTextureImage(MC_TX02_txt,G_IM_FMT_RGBA,G_IM_SIZ_16b,32,32,0,7),

	gsSPVertex(&MC_Gate_v[8], 16, 0),
	gsSP1Triangle(0, 1, 2, 0),
	gsSP1Triangle(0, 2, 3, 0),
	gsSP1Triangle(4, 5, 6, 0),
	gsSP1Triangle(4, 6, 7, 0),
	gsSP1Triangle(8, 9, 10, 0),
	gsSP1Triangle(8, 10, 11, 0),
	gsSP1Triangle(12, 13, 14, 0),
	gsSP1Triangle(12, 14, 15, 0),
	gsSPVertex(&MC_Gate_v[24], 4, 0),
	gsSP1Triangle(0, 1, 2, 0),
	gsSP1Triangle(0, 2, 3, 0),

	gsDPLoadTLUT_pal256(&MC_PointTX01_CI8_txt[256]),
	gsDPLoadTextureBlock(MC_PointTX01_CI8_txt,G_IM_FMT_CI,G_IM_SIZ_8b,16,16,0,G_TX_WRAP,G_TX_WRAP,4,4,0,0),
	gsDPSetTextureLUT(G_TT_RGBA16),

	gsSPVertex(&MC_Gate_v[28], 16, 0),
	gsSP1Triangle(0, 1, 2, 0),
	gsSP1Triangle(2, 3, 0, 0),
	gsSP1Triangle(4, 1, 0, 0),
	gsSP1Triangle(5, 6, 7, 0),
	gsSP1Triangle(5, 7, 8, 0),
	gsSP1Triangle(9, 10, 11, 0),
	gsSP1Triangle(9, 11, 12, 0),
	gsSP1Triangle(13, 14, 15, 0),
	gsSPVertex(&MC_Gate_v[41], 1, 0),
	gsSPVertex(&MC_Gate_v[43], 3, 1),
	gsSP1Triangle(0, 2, 3, 0),
	gsSP1Triangle(1, 2, 0, 0),
	gsDPPipeSync(),
        gsDPSetTextureLUT(G_TT_NONE),
	gsSPEndDisplayList(),
}; /* o2 */ 

#undef G_CC_PRIMSHADE

#undef gs_Nin_LoadTextureImage

#undef gs_Nin_SetUpTileDescrip

/* 46 vertices */
Vtx MC_Gate_v[]={
	{ -160,0,-170,0, 1976, 2048, 120,0,0,255 },   /* v0 used p14/V1 2 times */
	{ -160,220,-170,0, 1988, 1024, 120,0,0,255 },   /* v1 used p14/V2 2 times */
	{ -160,220,170,0, 83, 1024, 120,0,0,255 },   /* v2 used p14/V3 2 times */
	{ -160,0,170,0, 71, 2048, 120,0,0,255 },   /* v3 used p14/V4 2 times */
	{ 160,0,170,0, 71, 2048, -119,0,0,255 },   /* v4 used p27/V1 2 times */
	{ 160,220,170,0, 83, 1024, -119,0,0,255 },   /* v5 used p27/V2 2 times */
	{ 160,220,-170,0, 1988, 1024, -119,0,0,255 },   /* v6 used p27/V3 2 times */
	{ 160,0,-170,0, 1976, 2048, -119,0,0,255 },   /* v7 used p27/V4 2 times */
	{ 240,380,170,0, -95, 72, 118,21,0,255 },   /* v8 used p16/V1 2 times */
	{ 240,0,170,0, -106, 764, 120,0,0,255 },   /* v9 used p16/V2 2 times */
	{ 240,0,-170,0, 1154, 764, 120,0,0,255 },   /* v10 used p16/V3 2 times */
	{ 240,380,-170,0, 1164, 72, 118,21,0,255 },   /* v11 used p16/V4 2 times */
	{ -160,220,170,0, 120, 990, 0,0,119,255 },   /* v12 used p19/V1 2 times */
	{ 160,220,170,0, 1927, 990, 0,0,119,255 },   /* v13 used p19/V2 2 times */
	{ 160,440,170,0, 1927, 0, 0,0,119,255 },   /* v14 used p19/V3 2 times */
	{ -160,440,170,0, 120, 0, 0,0,119,255 },   /* v15 used p19/V4 2 times */
	{ -160,440,170,0, 105, 1024, -17,119,0,255 },   /* v16 used p20/V1 2 times */
	{ 160,440,170,0, 892, 1024, 18,119,0,255 },   /* v17 used p20/V2 2 times */
	{ 160,440,-170,0, 892, -99, 18,119,0,255 },   /* v18 used p20/V3 2 times */
	{ -160,440,-170,0, 105, -99, -17,119,0,255 },   /* v19 used p20/V4 2 times */
	{ -240,380,-170,0, 1164, 72, -117,21,0,255 },   /* v20 used p28/V1 2 times */
	{ -240,0,-170,0, 1154, 764, -119,0,0,255 },   /* v21 used p28/V2 2 times */
	{ -240,0,170,0, -106, 764, -119,0,0,255 },   /* v22 used p28/V3 2 times */
	{ -240,380,170,0, -95, 72, -117,21,0,255 },   /* v23 used p28/V4 2 times */
	{ -160,220,170,0, 105, -56, 0,-119,0,255 },   /* v24 used p10/V1 2 times */
	{ -160,220,-170,0, 105, 1032, 0,-119,0,255 },   /* v25 used p10/V2 2 times */
	{ 160,220,-170,0, 892, 1032, 0,-119,0,255 },   /* v26 used p10/V3 2 times */
	{ 160,220,170,0, 892, -56, 0,-119,0,255 },   /* v27 used p10/V4 2 times */
	{ -160,220,170,0, 419, -395, 0,0,119,255 },   /* v28 used p21/V1 3 times */
	{ -240,380,170,0, 79, -1026, 0,0,119,255 },   /* v29 used p21/V2 2 times */
	{ -240,0,170,0, 76, 469, 0,0,119,255 },   /* v30 used p21/V3 2 times */
	{ -160,0,170,0, 418, 470, 0,0,119,255 },   /* v31 used p25/V2 2 times */
	{ -160,440,170,0, 420, -1262, 0,0,119,255 },   /* v32 used p24/V1 2 times */
	{ -160,440,-170,0, 412, -925, -17,119,0,255 },   /* v33 used p31/V1 2 times */
	{ -240,380,-170,0, 82, -925, -117,21,0,255 },   /* v34 used p31/V2 2 times */
	{ -240,380,170,0, 82, 413, -117,21,0,255 },   /* v35 used p31/V3 2 times */
	{ -160,440,170,0, 412, 413, -17,119,0,255 },   /* v36 used p31/V4 2 times */
	{ 160,440,170,0, 85, 393, 18,119,0,255 },   /* v37 used p17/V1 2 times */
	{ 240,380,170,0, 426, 393, 118,21,0,255 },   /* v38 used p17/V2 2 times */
	{ 240,380,-170,0, 426, -945, 118,21,0,255 },   /* v39 used p17/V3 2 times */
	{ 160,440,-170,0, 85, -945, 18,119,0,255 },   /* v40 used p17/V4 2 times */
	{ 160,220,170,0, 95, -393, 0,0,119,255 },   /* v41 used p7/V1 6 times */
	{ 160,0,170,0, 94, 472, 0,0,119,255 },   /* v42 used p7/V2 2 times */
	{ 240,0,170,0, 422, 472, 0,0,119,255 },   /* v43 used p7/V3 4 times */
	{ 240,380,170,0, 424, -1023, 0,0,119,255 },   /* v44 used p9/V2 4 times */
	{ 160,440,170,0, 96, -1260, 0,0,119,255 },   /* v45 used p9/V3 2 times */
};


/*   0 vertices */
/*   1 Materials */

#define	LDIRX	0
#define	LDIRY	0
#define	LDIRZ	120
#define	AMBDIV	1
