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; }
/* 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 */