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<H2>C Specification</H2>
13<DL>
14  <DD>
15<PRE><CODE>#include &lt;revolution/gd.h&gt;</CODE></PRE>
16  <DD>
17<PRE>void 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 );</PRE>
20</DL>
21<H2>Arguments</H2>
22<TABLE border="1" cellpadding="3" cellspacing="0.1">
23  <TBODY>
24    <TR>
25<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE><STRONG><EM><CODE>attr</CODE></EM></STRONG></CODE></STRONG></EM></TD>
26<TD width="520">Specifies the attribute array name. Values that can be specified 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>
27    </TR>
28    <TR>
29<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE><STRONG><EM><CODE>base_ptr</CODE></EM></STRONG></CODE></STRONG></EM></TD>
30<TD width="520">Pointer to first element in attribute data array.</TD>
31    </TR>
32    <TR>
33<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE><STRONG><EM><CODE>base_ptr_raw</CODE></EM></STRONG></CODE></STRONG></EM></TD>
34<TD width="520">A type U32 value to insert in place of the actual <STRONG><EM><CODE>base_ptr</CODE></EM></STRONG>.</TD>
35    </TR>
36    <TR>
37<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE><STRONG><EM><CODE>stride</CODE></EM></STRONG></CODE></STRONG></EM></TD>
38<TD width="520">Stride between attribute data elements in bytes.</TD>
39    </TR>
40  </TBODY>
41</TABLE>
42<H2>Return Values</H2>
43<P>None.</P>
44<H2>Description</H2>
45<P><CODE>GDSetArray</CODE> 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>
46<P>attr_addr = <STRONG><EM><CODE>base_ptr</CODE></EM></STRONG> + attr_idx * <STRONG><EM><CODE>stride</CODE></EM></STRONG></P>
47<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.&nbsp;<CODE>GDSetArrayRaw</CODE> and <CODE>GDPatchArrayBase</CODE> are provided for this purpose.</P>
48<P><CODE>GDSetArrayRaw</CODE> allows a raw (U32) data value to be written in place of the array base pointer. GXSetArray converts the logical address into a physical address. The raw version of this function omits this process.</P>
49<P><CODE>GDPatchArrayBase</CODE> only writes out a converted address.&nbsp;To properly use this function, 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>. Finally, the newly written data is flushed back into main memory. The following code illustrates the correct operation sequence.</P>
50<P>Display list creation:</P>
51<BLOCKQUOTE>
52<PRE>savedOffset[0] = GDGetCurrOffset() + CP_DATA_OFFSET;  // save the necessary offset
53GDSetArrayRaw( GX_VA_POS, 0, 12 );</PRE>
54</BLOCKQUOTE>
55<P>Display list patching:</P>
56<BLOCKQUOTE>
57<PRE>GDSetCurrOffset(savedOffset[0]);  // set the offset
58cp = GDGetCurrPointer();          // save ptr for flushing later
59GDPatchArrayBase(tp);             // patch in the base address ptr
60DCStoreRange(cp, CP_DATA_LENGTH); // flush to main memory</PRE>
61</BLOCKQUOTE>
62<P>Because <CODE>GDSetArray</CODE> issues CP commands, we use <CODE>CP_DATA_OFFSET</CODE> and <CODE>CP_DATA_LENGTH</CODE> in the above code segments.</P>
63<H2>See Also</H2>
64<P><A href="../gx/Geometry/GXSetArray.html"><CODE>GXSetArray</CODE></A><BR> <A href="../gx/Geometry/GXSetVtxAttrFmt.html"><CODE>GXSetVtxAttrFmt</CODE></A><BR> <A href="../gx/Geometry/GXSetVtxDesc.html"><CODE>GXSetVtxDesc</CODE></A></P>
65<H2>Revision History</H2>
66<P>03/01/2006 Initial version.</P>
67</BODY>
68</HTML>