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>GDLoadTlut, etc.</TITLE> 9</HEAD> 10<BODY> 11<H1 align="left">GDLoadTlut, etc.</H1> 12 13<H2>Syntax</H2> 14<dl><dd><pre class="construction"> 15#include <revolution/gd.h> 16 17void GDLoadTlut ( void *tlut_ptr, u32 tmem_addr, <A href="../gx/Enumerated_Types/GXTlutSize.html">GXTlutSize</A> size ); 18void GDLoadTlutRaw( u32 tlut_ptr_raw, u32 tmem_addr, <A href="../gx/Enumerated_Types/GXTlutSize.html">GXTlutSize</A> size ); 19static inline void GDPatchTlutPtr ( void *tlut_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>tlut_ptr</CODE></EM></STRONG></TH> 27<TD>The pointer to the TLUT data in main memory. Internally this pointer will be converted from a cached to a physical pointer.</TD> 28 </TR> 29 <TR> 30<TH><STRONG><EM><CODE>tlut_ptr_raw</CODE></EM></STRONG></TH> 31<TD>A U24 value to be inserted in place of <SPAN class="argument">tlut_ptr</SPAN>. This value will be inserted unchanged into the command output.</TD> 32 </TR> 33 <TR> 34<TH><STRONG><EM><CODE>tmem_addr</CODE></EM></STRONG></TH> 35<TD>The location of the TLUT in TMEM. This address must reside in the upper half of TMEM and align to 512 bytes.</TD> 36 </TR> 37 <TR> 38<TH>size</TH> 39<TD>The TLUT <a href="../gx/Enumerated_Types/GXTlutSize.html">size</a>.</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>GDLoadTlut</code> function is used to load a TLUT from main memory into texture memory (TMEM). Unlike GX library, which uses TLUT objects, GD library just uses immediate pointers.</P> 49<P><code>GDLoadTlut</code> function receives a pointer to the Wii main memory as an argument and uses it when writing to the display list. Although the desired address is not known when the display list is generated, additional functions are available to simplify patching the display list. </P> 50<P>The <code>GDLoadTlutRaw</code> function allows a raw (U24) data value to be written in place of the TLUT data pointer. Normally, the logical address is converted into a physical address with <CODE>GDLoadTlut</CODE> function. The raw version of this function omits this process.</P> 51<P><code>GDPatchTlutPtr</code> function writes out a converted address only. 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>GDPatchTlutPtr</code>. Finally, the newly written data is flushed back into main memory. The following code illustrates the correct sequence of operations:</P> 52<P>Display list creation:</P> 53<dl><dd><pre class="construction"> 54// save the necessary offset 55savedOffset[0] = GDGetCurrOffset() + BP_CMD_LENGTH * 2 + BP_DATA_OFFSET; 56GDLoadTlutRaw( 0, MY_TMEM_ADDR, GX_TLUT_256 ); 57</pre></dd></dl> 58<P>Display list patching:</P> 59<dl><dd><pre class="construction"> 60GDSetCurrOffset(savedOffset[0]); // set the offset 61cp = GDGetCurrPointer(); // save ptr for flushing later 62GDPatchTlutPtr(tp); // patch in the base address ptr 63DCStoreRange(cp, BP_DATA_LENGTH); // flush to main memory 64</pre></dd></dl> 65<P>Because the <CODE><A href="GDSetTexImgPtr.html">GDSetTexImgPtr</A></CODE> function issues a BP command, <CODE><A href="GDSetTexImgPtr.html">BP_DATA_OFFSET</A></CODE> and <CODE><A href="GDSetTexImgPtr.html">BP_DATA_LENGTH</A></CODE> are used in the above code segments. In saving the offset, two BP commands must be skipped because the actual command you want to change is the third one issued.</P> 66 67<H2>See Also</H2> 68<P class="reference"> 69<A href="../gx/Texture/GXInitTlutObj.html">GXInitTlutObj</A>, 70<A href="../gx/Texture/GXLoadTlut.html">GXLoadTlut</A>, 71<A href="GDSetTexImgAttr.html">GDSetTexImgAttr</A> 72</P> 73 74<H2>Revision History</H2> 75<P> 762006/03/01 Initial version.<BR> 77</P> 78 79<hr><p>CONFIDENTIAL</p></body> 80</HTML>