#include <revolution/gd.h> void GDLoadTlut ( void *tlut_ptr, u32 tmem_addr, GXTlutSize size ); void GDLoadTlutRaw( u32 tlut_ptr_raw, u32 tmem_addr, GXTlutSize size ); static inline void GDPatchTlutPtr ( void *tlut_ptr );
tlut_ptr |
The pointer to the TLUT data in main memory. Internally this pointer will be converted from a cached to a physical pointer. |
|---|---|
tlut_ptr_raw |
A U24 value to be inserted in place of tlut_ptr. This value will be inserted unchanged into the command output. |
tmem_addr |
The location of the TLUT in TMEM. This address must reside in the upper half of TMEM and align to 512 bytes. |
| size | The TLUT size. |
None.
GDLoadTlut 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.
GDLoadTlut 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.
The GDLoadTlutRaw 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 GDLoadTlut function. The raw version of this function omits this process.
GDPatchTlutPtr 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 GDPatchTlutPtr. Finally, the newly written data is flushed back into main memory. The following code illustrates the correct sequence of operations:
Display list creation:
// save the necessary offset savedOffset[0] = GDGetCurrOffset() + BP_CMD_LENGTH * 2 + BP_DATA_OFFSET; GDLoadTlutRaw( 0, MY_TMEM_ADDR, GX_TLUT_256 );
Display list patching:
GDSetCurrOffset(savedOffset[0]); // set the offset cp = GDGetCurrPointer(); // save ptr for flushing later GDPatchTlutPtr(tp); // patch in the base address ptr DCStoreRange(cp, BP_DATA_LENGTH); // flush to main memory
Because the GDSetTexImgPtr function issues a BP command, BP_DATA_OFFSET and BP_DATA_LENGTH 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.
GXInitTlutObj, GXLoadTlut, GDSetTexImgAttr
2006/03/01 Initial version.
CONFIDENTIAL