示例#1
0
// TODO: Remove all this and replace with a custom format that is sent to vu1 for
// transformation, lighting and being able to deal with other prim types!
MF_API void MFBegin(uint32 vertexCount)
{
	MFCALLSTACK;

	packet_reset(&packet);
	beginCount = vertexCount;
	currentVert = 0;

	MFMat_Standard_Data *pData = (MFMat_Standard_Data*)pSetMaterial->pInstanceData;
	MFTexture *pTexture = pData->pTextures[pData->diffuseMapIndex];
	width = pTexture->pTemplateData->pSurfaces[0].width;
	height = pTexture->pTemplateData->pSurfaces[0].height;

	int tw = mylog2(width);
	int th = mylog2(height);

	int num = vertexCount*2 + 9;

	packet_append_64(&packet, DMA_SET_TAG(num, 0, DMA_TAG_END, 0, 0, 0));
	packet_append_64(&packet, 0);

	packet_append_64(&packet, GIF_SET_TAG(num-1, 1, 0, 0, 0, 1 ));
	packet_append_64(&packet, GIF_AD);

	/* GIF_SET_TEX0(tex base, tex width, tex psm, width, height, texcure alpha component, texture function, CLUT stuff */
	packet_append_64(&packet, GIF_SET_TEX0( tex_addr>>8,  width >> 6, 0,tw,th,1,1,0,0,0,0,0));
	packet_append_64(&packet, GIF_REG_TEX0_1);

	packet_append_64(&packet, GIF_SET_TEX1(1, 0, 1, 1, 0, 0, 0));
	packet_append_64(&packet, GIF_REG_TEX1_1);

	packet_append_64(&packet, GIF_SET_TEXA(0, 1, 255));
	packet_append_64(&packet, GIF_REG_TEXA);

	packet_append_64(&packet, GIF_SET_CLAMP(0, 0, 0, 0, 0, 0));
	packet_append_64(&packet, GIF_REG_CLAMP_1);

	float one = 1.0f; /* cludgy way to obtain 1.0f as a u32 */
	packet_append_64(&packet, GIF_SET_RGBAQ( r, g, b, a, *((int*)(&one)) )  );
	packet_append_64(&packet, GIF_REG_RGBAQ);

	packet_append_64(&packet, GIF_SET_ALPHA(0, 1,0,1,0));
	packet_append_64(&packet, GIF_REG_ALPHA_1);

	/* GIF_SET_PRIM(prim type, Shading, Texture, Fog, Alpha, AA, STQ/UV, context, fragmtnt*/
	packet_append_64(&packet, GIF_SET_PRIM (6, 0, 1, 0, 1, 0, 1, 0, 0));
	packet_append_64(&packet, GIF_REG_PRIM);
}
示例#2
0
文件: draw3d.c 项目: AKuHAK2/ps2sdk
qword_t *draw_prim_end(qword_t *q,int nreg, unsigned long reglist)
{

	float lpq = 2.0f / (float)nreg;

	// Determine number qwords that were needed minus the reglist giftag
	__vertex_qwords = q - __prim_start - 1;

	// Determine number of loops based on qwords used and loops per qword
	__vertex_loops = (int)(__vertex_qwords * lpq);

	// Now set the giftag of the vertex reglist chain
	__prim_start->dw[0] = GIF_SET_TAG(__vertex_loops,1,0,0,GIF_FLG_REGLIST,nreg);

	// Set the higher 64bits to the reglist
	__prim_start->dw[1] = reglist;

	// Return the current qword pointer
	return q;

}
示例#3
0
文件: draw3d.c 项目: AKuHAK2/ps2sdk
qword_t *draw_prim_start(qword_t *q, int context, prim_t *prim, color_t *color)
{

	// Set the primitive register in packed mode, but don't end the packet
	PACK_GIFTAG(q,GIF_SET_TAG(2,0,0,0,GIF_FLG_PACKED,1),GIF_REG_AD);
	q++;
	PACK_GIFTAG(q,GS_SET_PRIM(prim->type,prim->shading,prim->mapping,prim->fogging,
							  prim->blending,prim->antialiasing,prim->mapping_type,
							  context,prim->colorfix),GS_REG_PRIM);
	q++;
	PACK_GIFTAG(q,color->rgbaq,GIF_REG_RGBAQ);
	q++;

	// Save the position for the reglist giftag that draw_primitive_end will add
	__prim_start = q;
	q++;

	// Return the current qword pointer
	return q;

}
示例#4
0
文件: mpeg.c 项目: AzagraMac/PS2_SDK
/* data (anything).  */
static void* InitCB ( void* apParam, MPEGSequenceInfo* apInfo ) {

 int          lDataSize = apInfo -> m_Width * apInfo -> m_Height * 4;
 char*        retVal    = ( char* )malloc ( lDataSize );
 InitCBParam* lpParam   = ( InitCBParam* )apParam;
 int          lMBW      = ( apInfo -> m_Width  ) >> 4;
 int          lMBH      = ( apInfo -> m_Height ) >> 4;
 int          lTBW      = ( apInfo -> m_Width + 63 ) >> 6;
 int          lTW       = draw_log2 ( apInfo -> m_Width  );
 int          lTH       = draw_log2 ( apInfo -> m_Height );
 int          lX, lY;
 char*        lpImg;
 QWORD*       q;

 lpParam -> m_TexAddr >>= 6;

 lpParam -> m_pData = lpImg = retVal;
 lpParam -> m_pInfo = apInfo;
 SyncDCache ( retVal, retVal + lDataSize );
/* This initializes picture transfer packet.      */
/* Decoded picture is a sequence of 16x16 pixels  */
/* 'subpictures' (macroblocks) and DMA controller */
/* will transfer them all at once using source    */
/* chain transfer mode.                           */
 packet_allocate(&lpParam -> m_XFerPck,(10 + 12 * lMBW * lMBH )>>1,0,0);

 q = lpParam-> m_XFerPck.data;

 DMATAG_CNT(q, 3, 0, 0, 0);
 q++;
 PACK_GIFTAG(q,GIF_SET_TAG( 2, 0, 0, 0, 0, 1 ),GIF_REG_AD);
 q++;
 PACK_GIFTAG(q,GS_SET_TRXREG( 16, 16 ), GS_REG_TRXREG);
 q++;
 PACK_GIFTAG(q,GS_SET_BITBLTBUF( 0, 0, 0, lpParam -> m_TexAddr, lTBW, GS_PSM_32 ), GS_REG_BITBLTBUF);
 q++;

 for ( lY = 0; lY < apInfo -> m_Height; lY += 16 ) {
  for ( lX = 0; lX < apInfo -> m_Width; lX += 16, lpImg  += 1024 ) {
   DMATAG_CNT(q, 4, 0, 0, 0 );
   q++;
   PACK_GIFTAG(q,GIF_SET_TAG( 2, 0, 0, 0, 0, 1 ), GIF_REG_AD );
   q++;
   PACK_GIFTAG(q,GS_SET_TRXPOS( 0, 0, lX, lY, 0 ), GS_REG_TRXPOS );
   q++;
   PACK_GIFTAG(q,GS_SET_TRXDIR( 0 ), GS_REG_TRXDIR );
   q++;
   PACK_GIFTAG(q,GIF_SET_TAG( 64, 1, 0, 0, 2, 0),0);
   q++;
   DMATAG_REF(q, 64, ( unsigned )lpImg, 0, 0, 0);
   q++;
  }  /* end for */
 }  /* end for */

 //DMATAG_END(q,0,0,0,0);
 //q++;

 lpParam-> m_XFerPck.qwc = q - lpParam-> m_XFerPck.data;

/* This initializes picture drawing packet. Just textrured sprite */
/* that occupies the whole screen (no aspect ratio is taken into  */
/* account for simplicity.                                        */
 packet_allocate(&lpParam -> m_DrawPck,7,0,0);
 q = lpParam -> m_DrawPck.data;
 PACK_GIFTAG(q, GIF_SET_TAG( 6, 1, 0, 0, 0, 1 ), GIF_REG_AD );
 q++;
 PACK_GIFTAG(q, GS_SET_TEX0( lpParam -> m_TexAddr, lTBW, GS_PSM_32, lTW, lTH, 1, 1, 0, 0, 0, 0, 0 ), GS_REG_TEX0_1 );
 q++;
 PACK_GIFTAG(q, GS_SET_PRIM( 6, 0, 1, 0, 0, 0, 1, 0, 0 ), GS_REG_PRIM );
 q++;
 PACK_GIFTAG(q, GS_SET_UV( 0, 0 ), GS_REG_UV  );
 q++;
 PACK_GIFTAG(q, GS_SET_XYZ( 0, 0, 0 ), GS_REG_XYZ2 );
 q++;
 PACK_GIFTAG(q, GS_SET_UV( apInfo -> m_Width << 4, apInfo -> m_Height << 4 ), GS_REG_UV );
 q++;
 PACK_GIFTAG(q, GS_SET_XYZ(  640 << 4, 512 << 4, 0 ), GS_REG_XYZ2 );
 q++;

 lpParam -> m_DrawPck.qwc = q - lpParam -> m_DrawPck.data;

 return retVal;

}  /* end InitCB */