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<H2>C Specification</H2> 13<DL> 14 <DD> 15<PRE><CODE>#include <revolution/gd.h></CODE></PRE> 16 <DD> 17<PRE><CODE>void 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 );</CODE></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>tlut_ptr</CODE></EM></STRONG></CODE></STRONG></EM></TD> 26<TD width="520">The pointer to the TLUT data in main memory. Internally this pointer will be converted from a cached to a physical pointer.</TD> 27 </TR> 28 <TR> 29<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE><STRONG><EM><CODE>tlut_ptr_raw</CODE></EM></STRONG></CODE></STRONG></EM></TD> 30<TD width="520">A U24 value to be inserted in place of <STRONG><EM><CODE>tlut_ptr</CODE></EM></STRONG>. This value will be inserted unchanged into the command output.</TD> 31 </TR> 32 <TR> 33<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE><STRONG><EM><CODE>tmem_addr</CODE></EM></STRONG></CODE></STRONG></EM></TD> 34<TD width="520">The location of the TLUT in TMEM. This address must reside in the upper half of TMEM and align to 512 bytes.</TD> 35 </TR> 36 <TR> 37<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE><STRONG><EM><CODE>size</CODE></EM></STRONG></CODE></STRONG></EM></TD> 38<TD width="520">The TLUT <a href="../gx/Enumerated_Types/GXTlutSize.html">size</a>.</TD> 39 </TR> 40 </TBODY> 41</TABLE> 42<H2>Return Values</H2> 43<P>None.</P> 44<H2>Description</H2> 45<P><code>GDLoadTlut</code> is used to load a TLUT from main memory into texture memory (TMEM). Unlike GX, which uses TLUT objects, GD just uses immediate pointers.</P> 46<P><code>GDLoadTlut</code> receives a pointer to the Revolution 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> 47<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>. The raw version of this function omits this process.</P> 48<P><code>GDPatchTlutPtr</code> 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> 49<P>Display list creation:</P> 50<BLOCKQUOTE> 51<PRE>// save the necessary offset 52savedOffset[0] = GDGetCurrOffset() + BP_CMD_LENGTH * 2 + BP_DATA_OFFSET; 53GDLoadTlutRaw( 0, MY_TMEM_ADDR, GX_TLUT_256 );</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 59GDPatchTlutPtr(tp); // patch in the base address ptr 60DCStoreRange(cp, BP_DATA_LENGTH); // flush to main memory</PRE> 61</BLOCKQUOTE> 62<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> 63<H2>See Also</H2> 64<P><A href="../gx/Texture/GXInitTlutObj.html"><CODE>GXInitTlutObj</CODE></A><BR> <A href="../gx/Texture/GXLoadTlut.html"><CODE>GXLoadTlut</CODE></A><BR> <BR> <A href="GDSetTexImgAttr.html"><CODE>GDSetTexImgAttr</CODE></A></P> 65<H2>Revision History</H2> 66<P>03/01/2006 Initial version.</P> 67</BODY> 68</HTML>