1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META http-equiv="Content-Style-Type" content="text/css"> 6<META name="GENERATOR" content="Microsoft FrontPage 5.0"> 7<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css"> 8<TITLE>GDSetArray, etc.</TITLE> 9</HEAD> 10<BODY> 11<H1 align="left">GDSetArray, etc.</H1> 12 13<H2>Syntax</H2> 14<dl><dd><pre class="construction"> 15#include <revolution/gd.h> 16 17void GDSetArray( <A href="../gx/Enumerated_Types/GXAttr.html">GXAttr</A> attr, const void* base_ptr, u8 stride ); 18void GDSetArrayRaw( <A href="../gx/Enumerated_Types/GXAttr.html">GXAttr</A> attr, u32 base_ptr_raw, u8 stride ); 19void GDPatchArrayBase( const void* base_ptr ); 20</pre></dd></dl> 21 22<H2>Arguments</H2> 23<TABLE class="arguments" border="1" > 24 <TBODY> 25 <TR> 26<TH><STRONG><EM><CODE>attr</CODE></EM></STRONG></TH> 27<TD>Specifies the attribute array name. Accepted values are: <code>GX_VA_POSMTXARRAY, GX_VA_NRMMTXARRAY, GX_VA_TEXMTXARRAY, GX_VA_LIGHTARRAY, GX_VA_POS, GX_VA_NRM, GX_VA_CLR0, GX_VA_CLR1, GX_VA_TEX0, GX_VA_TEX1, GX_VA_TEX2, GX_VA_TEX3, GX_VA_TEX4, GX_VA_TEX5, GX_VA_TEX6, GX_VA_TEX7</code>.</TD> 28 </TR> 29 <TR> 30<TH><STRONG><EM><CODE>base_ptr</CODE></EM></STRONG></TH> 31<TD>pointer to the first element in the attribute data array</TD> 32 </TR> 33 <TR> 34<TH><STRONG><EM><CODE>base_ptr_raw</CODE></EM></STRONG></TH> 35<TD>A U32 value to insert in place of the actual base pointer, <SPAN class="argument">base_ptr</SPAN>.</TD> 36 </TR> 37 <TR> 38<TH><STRONG><EM><CODE>stride</CODE></EM></STRONG></TH> 39<TD>Stride between attribute data elements in bytes.</TD> 40 </TR> 41 </TBODY> 42</TABLE> 43 44<H2>Return Values</H2> 45<P>None.</P> 46 47<H2>Description</H2> 48<P><CODE>GDSetArray</CODE> function sets the array base pointer and stride for a single attribute. The array base pointer and stride are used to compute the address of the indexed attribute data using the following equation:</P> 49<BLOCKQUOTE> 50<P><EM>attr_addr = <SPAN class="argument">base_ptr</SPAN> + attr_idx * <SPAN class="argument">stride</SPAN></EM></P> 51</BLOCKQUOTE> 52<P>This function corresponds exactly to <a href="../gx/Geometry/GXSetArray.html"><CODE>GXSetArray</CODE></a>. Because the array base pointer is unknown when the display list is created, being able to write a dummy base pointer value now and patch in the real pointer later is necessary. <CODE>GDSetArrayRaw</CODE> function and <CODE>GDPatchArrayBase</CODE> function are provided for this purpose.</P> 53<P><CODE>GDSetArrayRaw</CODE> function allows a raw (U32) data value to be written in place of the array base pointer. The <A href="../gx/Geometry/GXSetArray.html"><CODE>GXSetArray</CODE></A> function converts the logical address into a physical address. The raw version of this function omits this process.</P> 54<P><CODE>GDPatchArrayBase</CODE> function only writes out a converted address. To use it correctly, you must first save the correct patch location (when the display list was created) and then reset the current offset to this patch location before calling <CODE>GDPatchArrayBase<CODE> function. Finally, the newly written data is flushed back into main memory. The following code illustrates the correct operation sequence.</P> 55<P>Display list creation:</P> 56<dl><dd><pre class="construction"> 57savedOffset[0] = GDGetCurrOffset() + CP_DATA_OFFSET; // save the necessary offset 58GDSetArrayRaw( GX_VA_POS, 0, 12 ); 59</pre></dd></dl> 60 61<P>Display list patching:</P> 62<dl><dd><pre class="construction"> 63GDSetCurrOffset(savedOffset[0]); // set the offset 64cp = GDGetCurrPointer(); // save ptr for flushing later 65GDPatchArrayBase(tp); // patch in the base address ptr 66DCStoreRange(cp, CP_DATA_LENGTH); // flush to main memory 67</pre></dd></dl> 68<P>Because <CODE>GDSetArray</CODE> function issues CP commands, we use <CODE>CP_DATA_OFFSET</CODE> and <CODE>CP_DATA_LENGTH</CODE> in the above code segments.</P> 69 70<H2>See Also</H2> 71<P class="reference"> 72<A href="../gx/Geometry/GXSetArray.html">GXSetArray</A>, 73<A href="../gx/Geometry/GXSetVtxAttrFmt.html">GXSetVtxAttrFmt</A>, 74<A href="../gx/Geometry/GXSetVtxDesc.html">GXSetVtxDesc</A> 75</P> 76 77<H2>Revision History</H2> 78<P> 792006/03/01 Initial version.<BR> 80</P> 81 82<hr><p>CONFIDENTIAL</p></body> 83</HTML>